nemequ / munit

µnit is a small testing framework for C
https://nemequ.github.io/munit/
Other
578 stars 76 forks source link

unnecessary (or faulty?) conditional #39

Open dbeecham opened 6 years ago

dbeecham commented 6 years ago

This is a fun one! Check this one out: https://github.com/nemequ/munit/blob/master/munit.c#L755

r - (start - stop)... is mathematically equal to r + (stop - start). The conditional is unnecessary. :)

Found it using gcc -Wduplicated-branches.

nemequ commented 6 years ago

This seems like a false positive to me. The variables are all unsigned 64-bit integers. If, for example, start < stop, then start - stop will be a very large positive number, not a negative.