Powered by Linux
[PATCH 1/2] Correct FP minimum handling — Semantic Matching Tool

[PATCH 1/2] Correct FP minimum handling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: John Levon <john.levon@xxxxxxxxxx>

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(-)

diff --git a/smatch_sval.c b/smatch_sval.c
index 7a2e74cc..2ef3551c 100644
--- a/smatch_sval.c
+++ b/smatch_sval.c
@@ -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;
 }
diff --git a/smatch_type.c b/smatch_type.c
index e3da7627..7e2e29ad 100644
--- a/smatch_type.c
+++ b/smatch_type.c
@@ -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;
 }
-- 
2.17.1




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux