Fixed compile warning in bacnet_strtof() from double fabs() to float FLT_MAX by using same pattern as Channel and Timer objects for float range validation.

This commit is contained in:
Steve Karg
2026-02-10 14:05:50 -06:00
parent a4ba359fde
commit 576cac784e
+9 -9
View File
@@ -1572,10 +1572,10 @@ bool bacnet_strtol(const char *str, long *long_value)
bool bacnet_strtof(const char *str, float *float_value) bool bacnet_strtof(const char *str, float *float_value)
{ {
char *endptr; char *endptr;
double value; double double_value;
errno = 0; errno = 0;
value = strtod(str, &endptr); double_value = strtod(str, &endptr);
if (endptr == str) { if (endptr == str) {
/* No digits found */ /* No digits found */
return false; return false;
@@ -1589,15 +1589,15 @@ bool bacnet_strtof(const char *str, float *float_value)
/* Extra text found */ /* Extra text found */
return false; return false;
} }
if (fabs(value) > FLT_MAX) { if (isgreaterequal(double_value, -FLT_MAX) &&
/* Value exceeds float range */ islessequal(double_value, FLT_MAX)) {
return false; if (float_value) {
} *float_value = (float)double_value;
if (float_value) { }
*float_value = (float)value; return true;
} }
return true; return false;
} }
/** /**