]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
efi: Allow expression as func argument to efi_call_* macros on all platforms
authorGlenn Washburn <development@efficientek.com>
Tue, 21 Feb 2023 18:20:32 +0000 (12:20 -0600)
committerDaniel Kiper <daniel.kiper@oracle.com>
Tue, 28 Feb 2023 12:32:26 +0000 (13:32 +0100)
On EFI platforms where EFI calls do not require a wrapper (notably i386-efi
and arm64-efi), the func argument needs to be wrapped in parenthesis to
allow valid syntax when func is an expression which evaluates to a function
pointer. On EFI platforms that do need a wrapper, this was never an issue
because func is passed to the C function wrapper as an argument and thus
does not need parenthesis to be evaluated.

Signed-off-by: Glenn Washburn <development@efficientek.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
include/grub/efi/api.h

index ad2680341b705af1b532fb38d49537b801721eab..b4c4646651cd53f5fc5f3e65393987c344fb9f5e 100644 (file)
@@ -1799,15 +1799,15 @@ typedef struct initrd_media_device_path initrd_media_device_path_t;
   || defined (__aarch64__) || defined (__MINGW64__) || defined (__CYGWIN__) \
   || defined(__riscv)
 
-#define efi_call_0(func)               func()
-#define efi_call_1(func, a)            func(a)
-#define efi_call_2(func, a, b)         func(a, b)
-#define efi_call_3(func, a, b, c)      func(a, b, c)
-#define efi_call_4(func, a, b, c, d)   func(a, b, c, d)
-#define efi_call_5(func, a, b, c, d, e)        func(a, b, c, d, e)
-#define efi_call_6(func, a, b, c, d, e, f) func(a, b, c, d, e, f)
-#define efi_call_7(func, a, b, c, d, e, f, g) func(a, b, c, d, e, f, g)
-#define efi_call_10(func, a, b, c, d, e, f, g, h, i, j)        func(a, b, c, d, e, f, g, h, i, j)
+#define efi_call_0(func)               (func)()
+#define efi_call_1(func, a)            (func)(a)
+#define efi_call_2(func, a, b)         (func)(a, b)
+#define efi_call_3(func, a, b, c)      (func)(a, b, c)
+#define efi_call_4(func, a, b, c, d)   (func)(a, b, c, d)
+#define efi_call_5(func, a, b, c, d, e)        (func)(a, b, c, d, e)
+#define efi_call_6(func, a, b, c, d, e, f) (func)(a, b, c, d, e, f)
+#define efi_call_7(func, a, b, c, d, e, f, g) (func)(a, b, c, d, e, f, g)
+#define efi_call_10(func, a, b, c, d, e, f, g, h, i, j)        (func)(a, b, c, d, e, f, g, h, i, j)
 
 #else