Menu

#25 asn_bits.c:348: bad compare ?

open
nobody
None
5
2020-07-09
2020-07-09
dcb
No

asn_bits.c:348:64: warning: self-comparison always evaluates to true [-Wtautological-compare]

Source code is

return ( (b1->bitLen == b2->bitLen) &&
         (memcmp(b1->bits, b2->bits, octetsLessOne) == 0) &&
         (( b1->bits[octetsLessOne] & (0xFF << octetBits)) ==
          ( b1->bits[octetsLessOne] & (0xFF << octetBits))));

Maybe better code:

return ( (b1->bitLen == b2->bitLen) &&
         (memcmp(b1->bits, b2->bits, octetsLessOne) == 0) &&
         (( b1->bits[octetsLessOne] & (0xFF << octetBits)) ==
          ( b2->bits[octetsLessOne] & (0xFF << octetBits))));

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.