nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0099-Add-PRIxGRUB_EFI_STATUS-and-use-it.patch

d9d99f
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
d9d99f
From: Peter Jones <pjones@redhat.com>
d9d99f
Date: Thu, 1 Jun 2017 10:07:50 -0400
d9d99f
Subject: [PATCH] Add PRIxGRUB_EFI_STATUS and use it.
d9d99f
d9d99f
This avoids syntax checkers getting confused about if it's llx or lx.
d9d99f
d9d99f
Signed-off-by: Peter Jones <pjones@redhat.com>
d9d99f
---
d9d99f
 grub-core/loader/efi/chainloader.c | 3 ++-
d9d99f
 include/grub/efi/api.h             | 8 ++++++++
d9d99f
 2 files changed, 10 insertions(+), 1 deletion(-)
d9d99f
d9d99f
diff --git a/grub-core/loader/efi/chainloader.c b/grub-core/loader/efi/chainloader.c
b71686
index 106eb10a3..3630b0cbf 100644
d9d99f
--- a/grub-core/loader/efi/chainloader.c
d9d99f
+++ b/grub-core/loader/efi/chainloader.c
d9d99f
@@ -783,7 +783,8 @@ handle_image (void *data, grub_efi_uint32_t datasize)
d9d99f
   efi_status = efi_call_2 (entry_point, grub_efi_image_handle,
d9d99f
 			   grub_efi_system_table);
d9d99f
 
d9d99f
-  grub_dprintf ("chain", "entry_point returned %ld\n", efi_status);
d9d99f
+  grub_dprintf ("chain", "entry_point returned 0x%"PRIxGRUB_EFI_STATUS"\n",
d9d99f
+		efi_status);
d9d99f
   grub_memcpy (li, &li_bak, sizeof (grub_efi_loaded_image_t));
d9d99f
   efi_status = grub_efi_free_pool (buffer);
d9d99f
 
d9d99f
diff --git a/include/grub/efi/api.h b/include/grub/efi/api.h
b71686
index 28b6adf76..e5b521bd9 100644
d9d99f
--- a/include/grub/efi/api.h
d9d99f
+++ b/include/grub/efi/api.h
d9d99f
@@ -527,6 +527,14 @@ typedef grub_uint8_t grub_efi_char8_t;
d9d99f
 typedef grub_uint16_t grub_efi_char16_t;
d9d99f
 
d9d99f
 typedef grub_efi_intn_t grub_efi_status_t;
d9d99f
+/* Make grub_efi_status_t reasonably printable. */
d9d99f
+#if GRUB_CPU_SIZEOF_VOID_P == 8
d9d99f
+#define PRIxGRUB_EFI_STATUS "lx"
d9d99f
+#define PRIdGRUB_EFI_STATUS "ld"
d9d99f
+#else
d9d99f
+#define PRIxGRUB_EFI_STATUS "llx"
d9d99f
+#define PRIdGRUB_EFI_STATUS "lld"
d9d99f
+#endif
d9d99f
 
d9d99f
 #define GRUB_EFI_ERROR_CODE(value)	\
d9d99f
   ((((grub_efi_status_t) 1) << (sizeof (grub_efi_status_t) * 8 - 1)) | (value))