This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Make FITS_IN_8_BITS() always true under Coverity
authorJarkko Hietaniemi <jhi@iki.fi>
Thu, 22 Oct 2015 11:31:58 +0000 (07:31 -0400)
committerJarkko Hietaniemi <jhi@iki.fi>
Sat, 24 Oct 2015 00:55:58 +0000 (20:55 -0400)
Similar in spirit to 3e94db23

Coverity id #28938
Coverity id #104778
Coverity id #131329

handy.h

diff --git a/handy.h b/handy.h
index 79e9cfd..228662f 100644 (file)
--- a/handy.h
+++ b/handy.h
@@ -894,8 +894,16 @@ patched there.  The file as of this writing is cpan/Devel-PPPort/parts/inc/misc
  * compiler to optimize it out if possible.  This is because Configure makes
  * sure that the machine has an 8-bit byte, so if c is stored in a byte, the
  * sizeof() guarantees that this evaluates to a constant true at compile time.
+ *
+ * For Coverity, be always true, because otherwise Coverity thinks
+ * it finds several expressions that are always true, independent
+ * of operands.  Well, they are, but that is kind of the point.
  */
+#ifndef __COVERITY__
 #define FITS_IN_8_BITS(c) ((sizeof(c) == 1) || !(((WIDEST_UTYPE)(c)) & ~0xFF))
+#else
+#define FITS_IN_8_BITS(c) (1)
+#endif
 
 #ifdef EBCDIC
 #   ifndef _ALL_SOURCE