From: Christian Storm <[email protected]>

__builtin_unreachable() is available since gcc 4.5, released 2010.
__attribute__((noreturn)) is available since gcc 2.5.0, released 1993.
__attribute__((unused)) is available since gcc 2.7, released 1995.

Any reasonable modern compiler supports these directly, so the wrapping
constructs can be dropped entirely.

Using a sufficiently modern compiler is encouraged nonetheless to benefit
from MS_ABI support giving type checking for EFI calls.

Signed-off-by: Christian Storm <[email protected]>
---
 include/bootguard.h | 10 ----------
 include/ebgpart.h   |  4 ----
 include/utils.h     |  2 +-
 tools/ebgpart.c     |  2 +-
 utils.c             |  4 ++--
 5 files changed, 4 insertions(+), 18 deletions(-)

diff --git a/include/bootguard.h b/include/bootguard.h
index 159a396..5c99264 100644
--- a/include/bootguard.h
+++ b/include/bootguard.h
@@ -14,16 +14,6 @@
 
 #pragma once
 
-#if defined(__GNUC__)
-#define __noreturn __attribute__((noreturn))
-#define unreachable() __builtin_unreachable()
-#else
-#define __noreturn /**/
-#define unreachable()                                                          
\
-       do {                                                                   \
-       } while (1)
-#endif
-
 #include <efi.h>
 #include <efilib.h>
 #include <efiprot.h>
diff --git a/include/ebgpart.h b/include/ebgpart.h
index d02cfbe..85b3ad7 100644
--- a/include/ebgpart.h
+++ b/include/ebgpart.h
@@ -33,10 +33,6 @@
        if (verbosity) fprintf(o, __VA_ARGS__)
 #endif
 
-#ifndef __unused
-#define __unused __attribute__((unused))
-#endif
-
 #include <unistd.h>
 #include <errno.h>
 #include <stdio.h>
diff --git a/include/utils.h b/include/utils.h
index 2f4fa87..a6fbab7 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -29,7 +29,7 @@ typedef struct _VOLUME_DESC {
 typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;
 
 uint32_t calc_crc32(void *data, int32_t size);
-void __noreturn error_exit(CHAR16 *message, EFI_STATUS status);
+void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status);
 VOID *mmalloc(UINTN bytes);
 EFI_STATUS mfree(VOID *p);
 CHAR16 *get_volume_label(EFI_FILE_HANDLE fh);
diff --git a/tools/ebgpart.c b/tools/ebgpart.c
index fc3bf3b..7880101 100644
--- a/tools/ebgpart.c
+++ b/tools/ebgpart.c
@@ -553,7 +553,7 @@ PedDisk *ped_disk_new(const PedDevice *dev)
        return &g_ped_dummy_disk;
 }
 
-PedPartition *ped_disk_next_partition(const PedDisk *__unused pd,
+PedPartition *ped_disk_next_partition(const PedDisk *__attribute__((unused)) 
pd,
                                      const PedPartition *part)
 {
        return part->next;
diff --git a/utils.c b/utils.c
index cb9569d..422356f 100644
--- a/utils.c
+++ b/utils.c
@@ -55,12 +55,12 @@ uint32_t calc_crc32(void *data, int32_t size)
        return crc;
 }
 
-void __noreturn error_exit(CHAR16 *message, EFI_STATUS status)
+void __attribute__((noreturn)) error_exit(CHAR16 *message, EFI_STATUS status)
 {
        ERROR(L"%s ( %r )\n", message, status);
        uefi_call_wrapper(BS->Stall, 1, 3 * 1000 * 1000);
        uefi_call_wrapper(BS->Exit, 4, this_image, status, 0, NULL);
-       unreachable();
+       __builtin_unreachable();
 }
 
 VOID *mmalloc(UINTN bytes)
-- 
2.30.0

-- 
You received this message because you are subscribed to the Google Groups "EFI 
Boot Guard" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/efibootguard-dev/20210110092241.17418-1-christian.storm%40siemens.com.

Reply via email to