]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
misc: Add parentheses around ALIGN_UP() and ALIGN_DOWN() arguments
authorGlenn Washburn <development@efficientek.com>
Tue, 8 Dec 2020 22:45:33 +0000 (16:45 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Sat, 12 Dec 2020 00:19:04 +0000 (01:19 +0100)
This ensures that expected order of operations is preserved when arguments
are expressions.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
include/grub/misc.h

index b7ca6dd586e7a061ed15a0ac88e79d9225034364..780a34e90395a11fa959032f51947cd751171c9e 100644 (file)
 #include <grub/compiler.h>
 
 #define ALIGN_UP(addr, align) \
-       ((addr + (typeof (addr)) align - 1) & ~((typeof (addr)) align - 1))
+       (((addr) + (typeof (addr)) (align) - 1) & ~((typeof (addr)) (align) - 1))
 #define ALIGN_UP_OVERHEAD(addr, align) ((-(addr)) & ((typeof (addr)) (align) - 1))
 #define ALIGN_DOWN(addr, align) \
-       ((addr) & ~((typeof (addr)) align - 1))
+       ((addr) & ~((typeof (addr)) (align) - 1))
 #define ARRAY_SIZE(array) (sizeof (array) / sizeof (array[0]))
 #define COMPILE_TIME_ASSERT(cond) switch (0) { case 1: case !(cond): ; }