On Wed, Sep 15, 2021 at 02:45:42AM +0000, scan-admin@coverity.com wrote:
CID 240103: (CONSTANT_EXPRESSION_RESULT) "val < -9223372036854775808LL /* -9223372036854775807L - 1 */" is always false regardless of the values of its operands. This occurs as the logical operand of "if".1434 if (val < INT64_MIN) { 1435 if (result) 1436 *result = INT64_MIN; 1437 return -ERANGE; 1438 }
Yes I know, but is it guaranteed on all archs in past and future that long long int is 64 bit?
CID 240103: (CONSTANT_EXPRESSION_RESULT) "val > 9223372036854775807L" is always false regardless of the values of its operands. This occurs as the logical operand of "if".1439 if (val > INT64_MAX) { 1440 if (result) 1441 *result = INT64_MAX; 1442 return -ERANGE; 1443 }
same.
I'd just ignore these warnings if that's ok with everyone else.
~N
Hi Neels,
On Wed, Sep 15, 2021 at 08:18:52AM +0200, Neels Hofmeyr wrote:
On Wed, Sep 15, 2021 at 02:45:42AM +0000, scan-admin@coverity.com wrote:
CID 240103: (CONSTANT_EXPRESSION_RESULT) "val < -9223372036854775808LL /* -9223372036854775807L - 1 */" is always false regardless of the values of its operands. This occurs as the logical operand of "if".1434 if (val < INT64_MIN) { 1435 if (result) 1436 *result = INT64_MIN; 1437 return -ERANGE; 1438 }
Yes I know, but is it guaranteed on all archs in past and future that long long int is 64 bit?
it seems anything except IBM 370, PDP-11 etc. from that area (which has no long long) has long long int as 64bit in the future who knows, maybe it gets even longer, who knows.
I'd just ignore these warnings if that's ok with everyone else.
Wouldn't they go away with a simple change from INT64_MIN/MAX to LLONG_MIN/MAX?
On Wed, Sep 15, 2021 at 12:22:20PM +0200, Harald Welte wrote:
1434 if (val < INT64_MIN) {
Wouldn't they go away with a simple change from INT64_MIN/MAX to LLONG_MIN/MAX?
I want to specifically use INT64_MIN to check whether the long long value, which theoretically might be higher range than int64_t, surpasses int64_t range.
It also wouldn't go away, because a 64 bit signed int val can never be smaller than INT64_MIN. I'm aware of that, but still want to have that check there for I guess autistic obsessive perfectionism, just in case long long gets longer.