From: Christian Storm <[email protected]>

The headers bootguard.h and utils.h mutually #include each other
for no apparent reason. Hence, disentangle their #include relation
to allow selective inclusion.

One problem of this is, e.g., utils.h defines _VOLUME_DESC
after #include "bootguard.h". However, bootguard.h uses
this in extern VOLUME_DESC *volumes.

Signed-off-by: Christian Storm <[email protected]>
---
 bootguard.c         |  1 +
 env/fatvars.c       |  1 +
 include/bootguard.h | 16 ----------------
 include/utils.h     | 16 +++++++++++++++-
 4 files changed, 17 insertions(+), 17 deletions(-)

diff --git a/bootguard.c b/bootguard.c
index 22a2a8a..55811dd 100644
--- a/bootguard.c
+++ b/bootguard.c
@@ -13,6 +13,7 @@
  */
 
 #include "bootguard.h"
+#include "utils.h"
 
 EFI_HANDLE this_image;
 
diff --git a/env/fatvars.c b/env/fatvars.c
index e86743e..5c63212 100644
--- a/env/fatvars.c
+++ b/env/fatvars.c
@@ -13,6 +13,7 @@
  */
 
 #include <bootguard.h>
+#include <utils.h>
 #include <syspart.h>
 #include <envdata.h>
 
diff --git a/include/bootguard.h b/include/bootguard.h
index 159a396..99d8fe4 100644
--- a/include/bootguard.h
+++ b/include/bootguard.h
@@ -14,20 +14,7 @@
 
 #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>
-#include <utils.h>
 
 /* The following definitions regarding status and error constants are
  * implemented the same way the corresponding gnu-efi constants are
@@ -48,9 +35,6 @@ typedef int BG_STATUS;
 
 extern EFI_HANDLE this_image;
 
-extern VOLUME_DESC *volumes;
-extern UINTN volume_count;
-
 typedef struct _BG_LOADER_PARAMS {
        CHAR16 *payload_path;
        CHAR16 *payload_options;
diff --git a/include/utils.h b/include/utils.h
index 2f4fa87..ff8f9ef 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -15,10 +15,21 @@
 
 #pragma once
 
-#include "bootguard.h"
+#include <efi.h>
+#include <efilib.h>
 
 #define MAX_INFO_SIZE 1024
 
+#if defined(__GNUC__)
+#define __noreturn __attribute__((noreturn))
+#define unreachable() __builtin_unreachable()
+#else
+#define __noreturn /**/
+#define unreachable()                                                          
\
+       do {                                                                   \
+       } while (1)
+#endif
+
 typedef struct _VOLUME_DESC {
        EFI_DEVICE_PATH *devpath;
        CHAR16 *fslabel;
@@ -26,6 +37,9 @@ typedef struct _VOLUME_DESC {
        EFI_FILE_HANDLE root;
 } VOLUME_DESC;
 
+extern VOLUME_DESC *volumes;
+extern UINTN volume_count;
+
 typedef enum { DOSFSLABEL, CUSTOMLABEL, NOLABEL } LABELMODE;
 
 uint32_t calc_crc32(void *data, int32_t size);
-- 
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/20210108144342.24785-3-christian.storm%40siemens.com.

Reply via email to