39 lines
1.4 KiB
Diff
39 lines
1.4 KiB
Diff
From 2e5e020db1e1ced5038c5ca9b847f62a224383ff Mon Sep 17 00:00:00 2001
|
|
From: Glenn Washburn <development@efficientek.com>
|
|
Date: Tue, 8 Dec 2020 16:45:33 -0600
|
|
Subject: [PATCH] misc: Add parentheses around ALIGN_UP() and ALIGN_DOWN()
|
|
arguments
|
|
|
|
This ensures that expected order of operations is preserved when arguments
|
|
are expressions.
|
|
|
|
Reference: http://git.savannah.gnu.org/cgit/grub.git/commit/?id=8e8b2316acbaef8c4e6c0839cf27a42217dfb7c3
|
|
|
|
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 | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/include/grub/misc.h b/include/grub/misc.h
|
|
index 998e47e..08ea894 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.19.1
|
|
|