summaryrefslogtreecommitdiff
path: root/handy.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2021-07-18 12:58:02 -0600
committerKarl Williamson <khw@cpan.org>2021-07-30 06:11:45 -0600
commit9555181b32f9b30122a8ea4e779c2c9916cec9f8 (patch)
treeedcab20c8e53c7bf95d50f3e88114fc080ebc894 /handy.h
parent4a1b7bb2bdf3d5a25e306752e4471e21093db314 (diff)
downloadperl-9555181b32f9b30122a8ea4e779c2c9916cec9f8.tar.gz
handy.h: Refactor FITS_IN_8_BITS()
By using a cast to U8, the '&' operation can be elminated, and the macro easier to read.
Diffstat (limited to 'handy.h')
-rw-r--r--handy.h6
1 files changed, 3 insertions, 3 deletions
diff --git a/handy.h b/handy.h
index acd1929f97..91dec76340 100644
--- a/handy.h
+++ b/handy.h
@@ -1438,10 +1438,10 @@ or casts
#ifndef __COVERITY__
/* The '| 0' part ensures a compiler error if c is not integer (like e.g., a
* pointer) */
-#define FITS_IN_8_BITS(c) ( (sizeof(c) == 1) \
- || !(((WIDEST_UTYPE)((c) | 0)) & ~0xFF))
+# define FITS_IN_8_BITS(c) ( (sizeof(c) == 1) \
+ || ((WIDEST_UTYPE)((c) | 0) == ((U8)(c))))
#else
-#define FITS_IN_8_BITS(c) (1)
+# define FITS_IN_8_BITS(c) (1)
#endif
/* Returns true if l <= c <= (l + n), where 'l' and 'n' are non-negative