trace-cmd: Fix out of range comparison
PATCH 1/1 trace-cmd: Fix out of range comparison
Comparing an unsigned int with a uint64_t causes zero extension of the unsigned int. This doesn't allow the unsigned int to ever equal LONG_MIN or LONG_MAX, i.e the branch is always false.
This issue was caught by clang:
tracecmd/trace-vm.c:340:37: error: result of comparison of constant 9223372036854775807 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if ((cid_id == LONG_MIN || cid_id == LONG_MAX) && errno == ERANGE)
~~~~~~ ^ ~~~~~~~~
tracecmd/trace-vm.c:340:15: error: result of comparison of constant -9223372036854775808 with expression of type 'unsigned int' is always false [-Werror,-Wtautological-constant-out-of-range-compare]
if ((cid_id == LONG_MIN || cid_id == LONG_MAX) && errno == ERANGE)Signed-off-by Ian Rogers <[email protected]>
--- tracecmd/trace-vm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
tracecmd/trace-vm.c +1 -1
@@ -337,7 +337,7 @@ static void read_guest_cid(char *name)if (!cid)continue ; cid_id =strtol (cid +strlen (VM_CID_ID ),NULL ,10 ); -if ((cid_id ==LONG_MIN || cid_id ==LONG_MAX ) && errno ==ERANGE ) +if ((cid_id ==INT_MIN || cid_id ==INT_MAX ) && errno ==ERANGE )continue ; guest =add_guest (cid_id, name);if (guest)
Signature · 1 line
2.32.0.605.g8dce9f2422-goog