summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
54f85c2)
When using the endian swapping marcos with multiple arguments that are
or'd together:
CPU_TO_BE64(THIS_THING | THAT_THING)
gcc will emit this warning:
warning: suggest parentheses around arithmetic in operand
of ‘|’ [-Wparentheses]
Wrap the arugments in braces to avoid this.
Signed-off-by: Joel Stanley <joel@jms.id.au>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
* };
*/
#define BSWAP_16(val) \
* };
*/
#define BSWAP_16(val) \
- ((((uint16_t)val & 0x00ff) << 8) \
- | (((uint16_t)val & 0xff00) >> 8))
+ ((((uint16_t)(val) & 0x00ff) << 8) \
+ | (((uint16_t)(val) & 0xff00) >> 8))
/**
* BSWAP_32 - reverse bytes in a constant uint32_t value.
/**
* BSWAP_32 - reverse bytes in a constant uint32_t value.
* };
*/
#define BSWAP_32(val) \
* };
*/
#define BSWAP_32(val) \
- ((((uint32_t)val & 0x000000ff) << 24) \
- | (((uint32_t)val & 0x0000ff00) << 8) \
- | (((uint32_t)val & 0x00ff0000) >> 8) \
- | (((uint32_t)val & 0xff000000) >> 24))
+ ((((uint32_t)(val) & 0x000000ff) << 24) \
+ | (((uint32_t)(val) & 0x0000ff00) << 8) \
+ | (((uint32_t)(val) & 0x00ff0000) >> 8) \
+ | (((uint32_t)(val) & 0xff000000) >> 24))
/**
* BSWAP_64 - reverse bytes in a constant uint64_t value.
/**
* BSWAP_64 - reverse bytes in a constant uint64_t value.
* };
*/
#define BSWAP_64(val) \
* };
*/
#define BSWAP_64(val) \
- ((((uint64_t)val & 0x00000000000000ffULL) << 56) \
- | (((uint64_t)val & 0x000000000000ff00ULL) << 40) \
- | (((uint64_t)val & 0x0000000000ff0000ULL) << 24) \
- | (((uint64_t)val & 0x00000000ff000000ULL) << 8) \
- | (((uint64_t)val & 0x000000ff00000000ULL) >> 8) \
- | (((uint64_t)val & 0x0000ff0000000000ULL) >> 24) \
- | (((uint64_t)val & 0x00ff000000000000ULL) >> 40) \
- | (((uint64_t)val & 0xff00000000000000ULL) >> 56))
+ ((((uint64_t)(val) & 0x00000000000000ffULL) << 56) \
+ | (((uint64_t)(val) & 0x000000000000ff00ULL) << 40) \
+ | (((uint64_t)(val) & 0x0000000000ff0000ULL) << 24) \
+ | (((uint64_t)(val) & 0x00000000ff000000ULL) << 8) \
+ | (((uint64_t)(val) & 0x000000ff00000000ULL) >> 8) \
+ | (((uint64_t)(val) & 0x0000ff0000000000ULL) >> 24) \
+ | (((uint64_t)(val) & 0x00ff000000000000ULL) >> 40) \
+ | (((uint64_t)(val) & 0xff00000000000000ULL) >> 56))
#if HAVE_BYTESWAP_H
#include <byteswap.h>
#if HAVE_BYTESWAP_H
#include <byteswap.h>