Correct FP minimum handling
PATCH 1/2 Correct FP minimum handling
From: John Levon <[email protected]>
FP_MIN and friends are the minimum *positive* value: what we really want is -FP_MAX.
--- smatch_sval.c | 6 +++--- smatch_type.c | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
smatch_sval.c +3 -3
@@ -142,11 +142,11 @@ int sval_is_positive(sval_t sval)static bool fp_is_min (sval_t sval) {if (sval.type == &float_ctype) -return sval.fvalue ==FLT_MIN ; +return sval.fvalue == -FLT_MAX ;if (sval.type == &double_ctype) -return sval.dvalue ==DBL_MIN ; +return sval.dvalue == -DBL_MAX ;if (sval.type == &ldouble_ctype) -return sval.ldvalue ==LDBL_MIN ; +return sval.ldvalue == -LDBL_MAX ;sm_perror ("%s: bad type: '%s'" , __func__,type_to_str (sval.type));return false; }
smatch_type.c +3 -3
@@ -475,11 +475,11 @@ static sval_t fp_min(struct symbol *type)sval_t ret = { .type = type };if (type == &float_ctype) - ret.fvalue =FLT_MIN ; + ret.fvalue = -FLT_MAX ;else if (type == &double_ctype) - ret.dvalue =DBL_MIN ; + ret.dvalue = -DBL_MAX ;else - ret.ldvalue =LDBL_MIN ; + ret.ldvalue = -LDBL_MAX ;return ret; }
Signature · 1 line
2.17.1