Skip to content

Commit

Permalink
handy.h: Refactor FITS_IN_8_BITS()
Browse files Browse the repository at this point in the history
By using a cast to U8, the '&' operation can be elminated, and the macro
easier to read.
  • Loading branch information
khwilliamson committed Jul 24, 2021
1 parent 907eab3 commit 320fd64
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions handy.h
Expand Up @@ -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
Expand Down

0 comments on commit 320fd64

Please sign in to comment.