]> The Tcpdump Group git mirrors - libpcap/commitdiff
With MSVC, abort if _BitScanForward() returns 0.
authorGuy Harris <[email protected]>
Thu, 3 Oct 2019 16:27:36 +0000 (09:27 -0700)
committerGuy Harris <[email protected]>
Thu, 3 Oct 2019 16:27:36 +0000 (09:27 -0700)
It should never return zero, as never pass a value of 0 to
lowest_set_bit(), but this should keep Coverity from getting upset (as a
result of not understanding _BitScanForward() well enough to realize
that if it's passed a non-zero value it will never return 0).

Reported by Charles Smith at Tangible Security.

optimize.c

index 283a6de30fa3f6b99f576cc043a68b98a6722e34..e38d2d7c4e28c78a2d11a58964582bf221efe889 100644 (file)
@@ -137,7 +137,7 @@ lowest_set_bit(int mask)
         * (It's currently not, in MSVC, even on 64-bit platforms, but....)
         */
        if (_BitScanForward(&bit, (unsigned int)mask) == 0)
-               return -1;      /* mask is zero */
+               abort();        /* mask is zero */
        return (int)bit;
 }
 #elif defined(MSDOS) && defined(__DJGPP__)