mirror of
https://github.com/opnsense/src.git
synced 2026-05-28 04:12:45 -04:00
Add casts to __uint16_t to the __bswap16() macros on all arches which
didn't already have them. This is because the ternary expression will return int, due to the Usual Arithmetic Conversions. Such casts are not needed for the 32 and 64 bit variants. While here, add additional parentheses around the x86 variant, to protect against unintended consequences. MFC after: 2 weeks
This commit is contained in:
parent
ad47abd20c
commit
63d094a7e2
3 changed files with 6 additions and 6 deletions
|
|
@ -124,8 +124,8 @@ __bswap64_var(__uint64_t _x)
|
|||
((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
|
||||
}
|
||||
|
||||
#define __bswap16(x) (__is_constant(x) ? __bswap16_const(x) : \
|
||||
__bswap16_var(x))
|
||||
#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \
|
||||
__bswap16_var(x)))
|
||||
#define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \
|
||||
__bswap32_var(x))
|
||||
#define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \
|
||||
|
|
|
|||
|
|
@ -109,8 +109,8 @@ __bswap64_var(__uint64_t _x)
|
|||
((_x << 40) & ((__uint64_t)0xff << 48)) | ((_x << 56)));
|
||||
}
|
||||
|
||||
#define __bswap16(x) (__is_constant(x) ? __bswap16_const(x) : \
|
||||
__bswap16_var(x))
|
||||
#define __bswap16(x) ((__uint16_t)(__is_constant(x) ? __bswap16_const(x) : \
|
||||
__bswap16_var(x)))
|
||||
#define __bswap32(x) (__is_constant(x) ? __bswap32_const(x) : \
|
||||
__bswap32_var(x))
|
||||
#define __bswap64(x) (__is_constant(x) ? __bswap64_const(x) : \
|
||||
|
|
|
|||
|
|
@ -71,8 +71,8 @@
|
|||
|
||||
#ifdef __GNUCLIKE_BUILTIN_CONSTANT_P
|
||||
#define __bswap16(x) \
|
||||
(__uint16_t)(__builtin_constant_p(x) ? \
|
||||
__bswap16_gen((__uint16_t)(x)) : __bswap16_var(x))
|
||||
((__uint16_t)(__builtin_constant_p(x) ? \
|
||||
__bswap16_gen((__uint16_t)(x)) : __bswap16_var(x)))
|
||||
#define __bswap32(x) \
|
||||
(__builtin_constant_p(x) ? \
|
||||
__bswap32_gen((__uint32_t)(x)) : __bswap32_var(x))
|
||||
|
|
|
|||
Loading…
Reference in a new issue