diff options
author | Karl Williamson <khw@cpan.org> | 2016-07-28 11:40:50 -0600 |
---|---|---|
committer | Karl Williamson <khw@cpan.org> | 2016-07-28 12:01:42 -0600 |
commit | 6c5b02ac7a9ff1c91f2ca46bedd89ba9012bb34f (patch) | |
tree | bbd9905b62ab03daef5e1e5e9d3bfa83fbed4b80 /handy.h | |
parent | 6f39eb491a3f31125ff9f8ab6b6a53e62255ac6c (diff) | |
download | perl-6c5b02ac7a9ff1c91f2ca46bedd89ba9012bb34f.tar.gz |
handy.h: Generate compile error if macros called wrong
This extends the mechanism we added in 5.24 to more macros to make sure
that a macro is called with an integer and not a pointer. It adds a
"| 0"
to the macro parameter, which is illegal if the parameter is a pointer.
Diffstat (limited to 'handy.h')
-rw-r--r-- | handy.h | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -910,7 +910,10 @@ patched there. The file as of this writing is cpan/Devel-PPPort/parts/inc/misc * 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)) + /* 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)) #else #define FITS_IN_8_BITS(c) (1) #endif |