From 2def2625e0b49ea3ae85ae8b821979e5901c6638 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Thu, 31 Jan 2013 04:27:39 -0800 Subject: libpayload: Add more parenthesis to the endian conversion macros There weren't enough parenthesis in the macros so operations might only apply to the last part of an expression passed in as an argument. Change-Id: I5afb406f9409986e45bbbc598bcbd0dd8507ed35 Signed-off-by: Gabe Black Reviewed-on: http://review.coreboot.org/2665 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones --- payloads/libpayload/include/endian.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'payloads') diff --git a/payloads/libpayload/include/endian.h b/payloads/libpayload/include/endian.h index 941dd1012f..ee9cf136a0 100644 --- a/payloads/libpayload/include/endian.h +++ b/payloads/libpayload/include/endian.h @@ -26,9 +26,10 @@ #include #include -#define swap_bytes16(in) (((in & 0xFF) << 8) | ((in & 0xFF00) >> 8)) -#define swap_bytes32(in) (((in & 0xFF) << 24) | ((in & 0xFF00) << 8) | \ - ((in & 0xFF0000) >> 8) | ((in & 0xFF000000) >> 24)) +#define swap_bytes16(in) ((((in) & 0xFF) << 8) | (((in) & 0xFF00) >> 8)) +#define swap_bytes32(in) ((((in) & 0xFF) << 24) | (((in) & 0xFF00) << 8) | \ + (((in) & 0xFF0000) >> 8) | \ + (((in) & 0xFF000000) >> 24)) #define swap_bytes64(in) (((uint64_t)swap_bytes32((uint32_t)(in)) << 32) | \ ((uint64_t)swap_bytes32((uint32_t)((in) >> 32)))) -- cgit v1.2.3