summaryrefslogtreecommitdiff
path: root/payloads/libpayload/include
diff options
context:
space:
mode:
authorGabe Black <gabeblack@google.com>2013-01-31 04:27:39 -0800
committerStefan Reinauer <stefan.reinauer@coreboot.org>2013-03-13 19:12:31 +0100
commit2def2625e0b49ea3ae85ae8b821979e5901c6638 (patch)
treea8187d8a1a83b99c531772b01540c6458a68a289 /payloads/libpayload/include
parentb53a73ef7726ccbaea73cb560b6f72cdb166eb50 (diff)
downloadcoreboot-2def2625e0b49ea3ae85ae8b821979e5901c6638.tar.xz
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 <gabeblack@google.com> Reviewed-on: http://review.coreboot.org/2665 Tested-by: build bot (Jenkins) Reviewed-by: Marc Jones <marc.jones@se-eng.com>
Diffstat (limited to 'payloads/libpayload/include')
-rw-r--r--payloads/libpayload/include/endian.h7
1 files changed, 4 insertions, 3 deletions
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 <arch/types.h>
#include <libpayload-config.h>
-#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))))