grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v7 02/17] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN ar


From: Glenn Washburn
Subject: [PATCH v7 02/17] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN arguments
Date: Fri, 4 Dec 2020 10:43:31 -0600

This ensures that expected order of operations is preserved when arguments
are expressions.

Signed-off-by: Glenn Washburn <development@efficientek.com>
---
 include/grub/misc.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/grub/misc.h b/include/grub/misc.h
index b7ca6dd58..780a34e90 100644
--- a/include/grub/misc.h
+++ b/include/grub/misc.h
@@ -28,10 +28,10 @@
 #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): ; }
 
-- 
2.27.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]