[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v8 02/18] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN ar
From: |
Glenn Washburn |
Subject: |
[PATCH v8 02/18] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN arguments |
Date: |
Tue, 8 Dec 2020 16:45:33 -0600 |
This ensures that expected order of operations is preserved when arguments
are expressions.
Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
Reviewed-by: Patrick Steinhardt <ps@pks.im>
---
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
- [PATCH v8 12/18] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors, (continued)
- [PATCH v8 12/18] luks2: grub_cryptodisk_t->total_sectors is the max number of device native sectors, Glenn Washburn, 2020/12/08
- [PATCH v8 05/18] luks2: Make sure all fields of output argument in luks2_parse_digest() are written to, Glenn Washburn, 2020/12/08
- [PATCH v8 13/18] cryptodisk: Properly handle non-512 byte sized sectors, Glenn Washburn, 2020/12/08
- [PATCH v8 06/18] luks2: Add idx member to struct grub_luks2_keyslot/segment/digest, Glenn Washburn, 2020/12/08
- [PATCH v8 17/18] misc: Add grub_log2ull macro for calculating log base 2 of 64-bit integers, Glenn Washburn, 2020/12/08
- [PATCH v8 02/18] misc: Add parentheses around ALIGN_UP and ALIGN_DOWN arguments,
Glenn Washburn <=
- [PATCH v8 09/18] luks2: Add string "index" to user strings using a json index., Glenn Washburn, 2020/12/08
- [PATCH v8 10/18] cryptodisk: Add macro GRUB_TYPE_BITS() to replace some literals, Glenn Washburn, 2020/12/08
- [PATCH v8 14/18] luks2: Better error handling when setting up the cryptodisk, Glenn Washburn, 2020/12/08