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:
+9
-9
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user