Skip to content

Commit 7378bae

Browse files
committed
unit_evaluate_dbl: fixed err check
arm64 (Apple silicon) needs the comparison with NAN with isnan(). Fixes also failing test misc_test_unit_evaluate on GH macos-14 runner (arm64 mac),
1 parent 7d52ed0 commit 7378bae

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/utils/misc.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,8 @@ unit_evaluate(const char *str, const char **endptr)
8282
{
8383
double ret = unit_evaluate_dbl(str, false, endptr);
8484

85-
if (ret == NAN || ret >= nexttoward((double) LLONG_MAX, LLONG_MAX)) {
85+
if (std::isnan(ret) ||
86+
ret >= nexttoward((double) LLONG_MAX, LLONG_MAX)) {
8687
return LLONG_MIN;
8788
}
8889

@@ -96,7 +97,7 @@ unit_evaluate(const char *str, const char **endptr)
9697
* @param case_sensitive if true 'm' will be considered as milli, otherwise mega
9798
* @param endptr if not NULL, point to suffix after parse
9899
* @returns positive floating point representation of the string
99-
* @returns NAN if error
100+
* @returns NAN if error (isnan() must be called to check ret val)
100101
*/
101102
double
102103
unit_evaluate_dbl(const char *str, bool case_sensitive, const char **endptr)

src/video_compress/cmpto_j2k.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,8 +506,8 @@ static void usage() {
506506

507507
#define ASSIGN_CHECK_VAL(var, str, minval) \
508508
do { \
509-
long long val = unit_evaluate_dbl(str, false, nullptr); \
510-
if (val < (minval) || val > UINT_MAX) { \
509+
const double val = unit_evaluate_dbl(str, false, nullptr); \
510+
if (std::isnan(val) || val < (minval) || val > UINT_MAX) { \
511511
LOG(LOG_LEVEL_ERROR) \
512512
<< "[J2K] Wrong value " << (str) \
513513
<< " for " #var "! Value must be >= " << (minval) \

0 commit comments

Comments
 (0)