From 7baaa7c4786076684c7d33f79f8481ac92daf2be Mon Sep 17 00:00:00 2001 From: TheSomeMan Date: Mon, 15 Jul 2024 20:45:25 +0700 Subject: [PATCH] Revert "Replace: isinf -> isinff, isnan -> isnanf" This reverts commit 119bca2205f283dd28f27d5c8129e7edb56b6f69. --- src/ruuvi_endpoint_3.c | 14 +++++++------- src/ruuvi_endpoint_5.c | 10 +++++----- src/ruuvi_endpoint_6.c | 12 ++++++------ src/ruuvi_endpoint_8.c | 8 ++++---- src/ruuvi_endpoint_c5.c | 8 ++++---- src/ruuvi_endpoints.c | 2 +- 6 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/ruuvi_endpoint_3.c b/src/ruuvi_endpoint_3.c index 26ee466..50a0279 100644 --- a/src/ruuvi_endpoint_3.c +++ b/src/ruuvi_endpoint_3.c @@ -24,9 +24,9 @@ static re_float re_3_encode_check_invalid (const re_float data, { re_float result; - if (isnanf (invalid)) + if (isnan (invalid)) { - if (!isnanf (data)) + if (!isnan (data)) { result = RE_3_ENCODE_INVALID_PRECISION; } @@ -55,7 +55,7 @@ static re_float re_3_encode_check_invalid (const re_float data, static void re_3_encode_acceleration (uint8_t * const buffer, const re_float acceleration, const re_float invalid) { - if (!isnanf (re_3_encode_check_invalid (acceleration, invalid))) + if (!isnan (re_3_encode_check_invalid (acceleration, invalid))) { int16_t decimal = (int16_t) roundf (acceleration * RE_3_ENCODE_ACC_CONVERT_RATIO); buffer[0] = ( (uint16_t) decimal) >> RE_3_BYTE_OFFSET; @@ -74,7 +74,7 @@ static void re_3_encode_data (uint8_t * const buffer, buffer[RE_3_OFFSET_HEADER] = RE_3_DESTINATION; // HUMIDITY - if (!isnanf (re_3_encode_check_invalid (data->humidity_rh, invalid))) + if (!isnan (re_3_encode_check_invalid (data->humidity_rh, invalid))) { //Humidity (one lsb is 0.5%, e.g. 128 is 64%). Round the value buffer[RE_3_OFFSET_HUMIDITY] = (uint8_t) roundf (data->humidity_rh * @@ -87,7 +87,7 @@ static void re_3_encode_data (uint8_t * const buffer, // Temperature - if (!isnanf (re_3_encode_check_invalid (data->temperature_c, invalid))) + if (!isnan (re_3_encode_check_invalid (data->temperature_c, invalid))) { //Temperature (MSB is sign, next 7 bits are decimal value) re_float temperature = data->temperature_c; @@ -126,7 +126,7 @@ static void re_3_encode_data (uint8_t * const buffer, // Pressure - if (!isnanf (re_3_encode_check_invalid (data->pressure_pa, invalid))) + if (!isnan (re_3_encode_check_invalid (data->pressure_pa, invalid))) { uint32_t pressure = (uint32_t) data->pressure_pa; pressure -= RE_3_ENCODE_PRESSURE_INIT_OFFSET; @@ -148,7 +148,7 @@ static void re_3_encode_data (uint8_t * const buffer, data->accelerationz_g, invalid); // voltage - if (!isnanf (re_3_encode_check_invalid (data->battery_v, invalid))) + if (!isnan (re_3_encode_check_invalid (data->battery_v, invalid))) { uint32_t voltage = 0; re_float voltage_in_mv = (data->battery_v * diff --git a/src/ruuvi_endpoint_5.c b/src/ruuvi_endpoint_5.c index 6128eeb..7dcce72 100644 --- a/src/ruuvi_endpoint_5.c +++ b/src/ruuvi_endpoint_5.c @@ -69,7 +69,7 @@ static void re_5_encode_acceleration (uint8_t * const acceleration_slot, { uint16_t coded_acceleration = RE_5_INVALID_ACCELERATION; - if (!isnanf (acceleration)) + if (!isnan (acceleration)) { re_clip (&acceleration, RE_5_ACC_MIN, RE_5_ACC_MAX); int16_t rounded_acceleration = (int16_t) roundf (acceleration * RE_5_ACC_RATIO); @@ -149,7 +149,7 @@ static void re_5_encode_humidity (uint8_t * const buffer, const re_5_data_t * da uint16_t coded_humidity = RE_5_INVALID_HUMIDITY; re_float humidity = data->humidity_rh; - if (!isnanf (humidity)) + if (!isnan (humidity)) { re_clip (&humidity, RE_5_HUMI_MIN, RE_5_HUMI_MAX); coded_humidity = (uint16_t) roundf (humidity * RE_5_HUMI_RATIO); @@ -179,7 +179,7 @@ static void re_5_encode_temperature (uint8_t * const buffer, const re_5_data_t * uint16_t coded_temperature = RE_5_INVALID_TEMPERATURE; re_float temperature = data->temperature_c; - if (!isnanf (temperature)) + if (!isnan (temperature)) { re_clip (&temperature, RE_5_TEMP_MIN, RE_5_TEMP_MAX); int16_t rounded_temperature = (int16_t) roundf (temperature * RE_5_TEMP_RATIO); @@ -211,7 +211,7 @@ static void re_5_encode_pressure (uint8_t * const buffer, const re_5_data_t * da uint16_t coded_pressure = RE_5_INVALID_PRESSURE; re_float pressure = data->pressure_pa; - if (!isnanf (pressure)) + if (!isnan (pressure)) { re_clip (&pressure, RE_5_PRES_MIN, RE_5_PRES_MAX); pressure += RE_5_PRES_OFFSET; @@ -244,7 +244,7 @@ static void re_5_encode_pwr (uint8_t * const buffer, const re_5_data_t * data) uint16_t coded_tx_power = RE_5_INVALID_POWER; re_float tx_power = (re_float) data->tx_power; - if (!isnanf (voltage)) + if (!isnan (voltage)) { re_clip (&voltage, RE_5_VOLTAGE_MIN, RE_5_VOLTAGE_MAX); coded_voltage = (uint16_t) roundf ( (voltage * RE_5_BATT_RATIO) diff --git a/src/ruuvi_endpoint_6.c b/src/ruuvi_endpoint_6.c index 733a3f3..916dbc2 100644 --- a/src/ruuvi_endpoint_6.c +++ b/src/ruuvi_endpoint_6.c @@ -59,7 +59,7 @@ static void re_6_encode_pm (uint8_t * const p_slot, re_float val, const uint32_t { uint16_t coded_val = RE_6_INVALID_PM; - if (!isnanf (val)) + if (!isnan (val)) { re_clip (&val, RE_6_PM_MIN, RE_6_PM_MAX); coded_val = (uint16_t) lrintf (val * RE_6_PM_RATIO); @@ -91,7 +91,7 @@ static void re_6_encode_co2 (uint8_t * const p_slot, re_float val) { uint16_t coded_val = RE_6_INVALID_CO2; - if (!isnanf (val)) + if (!isnan (val)) { re_clip (&val, RE_6_CO2_MIN, RE_6_CO2_MAX); coded_val = (uint16_t) lrintf (val * RE_6_CO2_RATIO); @@ -123,7 +123,7 @@ static void re_6_encode_humidity (uint8_t * const p_slot, re_float val) { uint16_t coded_val = RE_6_INVALID_HUMIDITY; - if (!isnanf (val)) + if (!isnan (val)) { re_clip (&val, RE_6_HUMIDITY_MIN, RE_6_HUMIDITY_MAX); coded_val = (uint16_t) lrintf (val * RE_6_HUMIDITY_RATIO); @@ -155,7 +155,7 @@ static void re_6_encode_voc (uint8_t * const p_slot, re_float val) { uint16_t coded_val = RE_6_INVALID_VOC_INDEX; - if ( (!isnanf (val)) && (val >= RE_6_VOC_INDEX_MIN) && (val <= RE_6_VOC_INDEX_MAX)) + if ( (!isnan (val)) && (val >= RE_6_VOC_INDEX_MIN) && (val <= RE_6_VOC_INDEX_MAX)) { coded_val = (uint16_t) lrintf (val * RE_6_VOC_RATIO); } @@ -186,7 +186,7 @@ static void re_6_encode_nox (uint8_t * const p_slot, re_float val) { uint16_t coded_val = RE_6_INVALID_NOX_INDEX; - if ( (!isnanf (val)) && (val >= RE_6_NOX_INDEX_MIN) && (val <= RE_6_NOX_INDEX_MAX)) + if ( (!isnan (val)) && (val >= RE_6_NOX_INDEX_MIN) && (val <= RE_6_NOX_INDEX_MAX)) { coded_val = (uint16_t) lrintf (val * RE_6_NOX_RATIO); } @@ -217,7 +217,7 @@ static void re_6_encode_temperature (uint8_t * const p_slot, re_float val) { uint16_t coded_val = RE_6_INVALID_TEMPERATURE; - if (!isnanf (val)) + if (!isnan (val)) { re_clip (&val, RE_6_TEMPERATURE_MIN, RE_6_TEMPERATURE_MAX); coded_val = (uint16_t) lrintf (val * RE_6_TEMPERATURE_RATIO); diff --git a/src/ruuvi_endpoint_8.c b/src/ruuvi_endpoint_8.c index 213fff2..c3a71f8 100644 --- a/src/ruuvi_endpoint_8.c +++ b/src/ruuvi_endpoint_8.c @@ -41,7 +41,7 @@ static void re_8_encode_humidity (uint8_t * const buffer, const re_8_data_t * da uint16_t coded_humidity = RE_8_INVALID_HUMIDITY; float humidity = data->humidity_rh; - if (!isnanf (humidity)) + if (!isnan (humidity)) { re_clip (&humidity, RE_8_HUMI_MIN, RE_8_HUMI_MAX); coded_humidity = (uint16_t) roundf (humidity * RE_8_HUMI_RATIO); @@ -56,7 +56,7 @@ static void re_8_encode_temperature (uint8_t * const buffer, const re_8_data_t * uint16_t coded_temperature = RE_8_INVALID_TEMPERATURE; float temperature = data->temperature_c; - if (!isnanf (temperature)) + if (!isnan (temperature)) { re_clip (&temperature, RE_8_TEMP_MIN, RE_8_TEMP_MAX); coded_temperature = (uint16_t) roundf (temperature * RE_8_TEMP_RATIO); @@ -71,7 +71,7 @@ static void re_8_encode_pressure (uint8_t * const buffer, const re_8_data_t * da uint16_t coded_pressure = RE_8_INVALID_PRESSURE; float pressure = data->pressure_pa; - if (!isnanf (pressure)) + if (!isnan (pressure)) { re_clip (&pressure, RE_8_PRES_MIN, RE_8_PRES_MAX); pressure += RE_8_PRES_OFFSET; @@ -89,7 +89,7 @@ static void re_8_encode_pwr (uint8_t * const buffer, const re_8_data_t * data) uint16_t coded_tx_power = RE_8_INVALID_POWER; float tx_power = (float) data->tx_power; - if (!isnanf (voltage)) + if (!isnan (voltage)) { re_clip (&voltage, RE_8_VOLTAGE_MIN, RE_8_VOLTAGE_MAX); coded_voltage = (uint16_t) roundf ( (voltage * RE_8_BATT_RATIO) diff --git a/src/ruuvi_endpoint_c5.c b/src/ruuvi_endpoint_c5.c index b58c2f7..af7c2b4 100644 --- a/src/ruuvi_endpoint_c5.c +++ b/src/ruuvi_endpoint_c5.c @@ -79,7 +79,7 @@ static void re_c5_encode_humidity (uint8_t * const buffer, const re_c5_data_t * uint16_t coded_humidity = RE_C5_INVALID_HUMIDITY; re_float humidity = data->humidity_rh; - if (!isnanf (humidity)) + if (!isnan (humidity)) { re_clip (&humidity, RE_C5_HUMI_MIN, RE_C5_HUMI_MAX); coded_humidity = (uint16_t) roundf (humidity * RE_C5_HUMI_RATIO); @@ -94,7 +94,7 @@ static void re_c5_encode_temperature (uint8_t * const buffer, const re_c5_data_t uint16_t coded_temperature = RE_C5_INVALID_TEMPERATURE; re_float temperature = data->temperature_c; - if (!isnanf (temperature)) + if (!isnan (temperature)) { re_clip (&temperature, RE_C5_TEMP_MIN, RE_C5_TEMP_MAX); int16_t rounded_temperature = (int16_t) roundf (temperature * RE_C5_TEMP_RATIO); @@ -111,7 +111,7 @@ static void re_c5_encode_pressure (uint8_t * const buffer, const re_c5_data_t * uint16_t coded_pressure = RE_C5_INVALID_PRESSURE; re_float pressure = data->pressure_pa; - if (!isnanf (pressure)) + if (!isnan (pressure)) { re_clip (&pressure, RE_C5_PRES_MIN, RE_C5_PRES_MAX); pressure += RE_C5_PRES_OFFSET; @@ -130,7 +130,7 @@ static void re_c5_encode_pwr (uint8_t * const buffer, const re_c5_data_t * data) uint16_t coded_tx_power = RE_C5_INVALID_POWER; re_float tx_power = (re_float) data->tx_power; - if (!isnanf (voltage)) + if (!isnan (voltage)) { re_clip (&voltage, RE_C5_VOLTAGE_MIN, RE_C5_VOLTAGE_MAX); coded_voltage = (uint16_t) roundf ( (voltage * RE_C5_BATT_RATIO) diff --git a/src/ruuvi_endpoints.c b/src/ruuvi_endpoints.c index f248068..7d07a44 100644 --- a/src/ruuvi_endpoints.c +++ b/src/ruuvi_endpoints.c @@ -193,7 +193,7 @@ re_status_t re_log_write_data (uint8_t * const buffer, const re_float data, { err_code |= RE_ERROR_NULL; } - else if (isnanf (data) || isinff (data)) + else if (isnan (data) || isinf (data)) { err_code |= RE_ERROR_INVALID_PARAM; }