From: Christian Storm <[email protected]>

The current mechanism to parse gnu-efi's version is restricted to
gnu-efi 3.x series. Improve the calculation to also account for
gnu-efi 4.x series (and beyond).

Reported-by: Andreas Tobler <[email protected]>
Signed-off-by: Christian Storm <[email protected]>
---
 configure.ac                     | 6 +++---
 drivers/watchdog/wdfuncs_end.c   | 2 +-
 drivers/watchdog/wdfuncs_start.c | 2 +-
 main.c                           | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/configure.ac b/configure.ac
index d1c932b..7f22339 100644
--- a/configure.ac
+++ b/configure.ac
@@ -40,7 +40,7 @@ AC_PROG_CC
 AC_CHECK_TOOL(LD, ld)
 AC_CHECK_TOOL(OBJCOPY, objcopy)
 AC_CHECK_TOOL(GREP, grep)
-AC_CHECK_TOOL(TR, tr)
+AC_CHECK_TOOL(AWK, awk)
 
 dnl Dont try to use things like -std=c99 for efi compilation
 GNUEFI_CC=$CC
@@ -232,9 +232,9 @@ if test "x$PKG_CONFIG" = "xno"; then
 fi
 
 # Note: gnu-efi introduced pkg-config with version 3.0.16
-# GNU_EFI_VERSION resolves to gnu-efi's version without dots, e.g., 
GNU_EFI_VERSION=3016
+# GNU_EFI_VERSION resolves to gnu-efi's version without dots, e.g., 
GNU_EFI_VERSION=3000016
 # gnu-efi versions < 3.0.16 resolve to GNU_EFI_VERSION=0
-AC_SUBST([GNU_EFI_VERSION], [$( ($PKG_CONFIG --modversion "gnu-efi" 
2>/dev/null || echo 0) | $TR -d '.' )])
+AC_SUBST([GNU_EFI_VERSION], [$( ($PKG_CONFIG --modversion "gnu-efi" 
2>/dev/null || echo 0) | $AWK -F. '{print $1*1000000 + $2*1000 + $3}' )])
 AC_DEFINE_UNQUOTED([GNU_EFI_VERSION], [${GNU_EFI_VERSION}], [gnu-efi version])
 
 AC_SUBST([OBJCOPY_HAS_EFI_APP_TARGET], [$($OBJCOPY --info | $GREP -q pei- 
2>/dev/null && echo "true")])
diff --git a/drivers/watchdog/wdfuncs_end.c b/drivers/watchdog/wdfuncs_end.c
index d19a0ab..f90ffc7 100644
--- a/drivers/watchdog/wdfuncs_end.c
+++ b/drivers/watchdog/wdfuncs_end.c
@@ -12,7 +12,7 @@
  * SPDX-License-Identifier:    GPL-2.0-only
  */
 
-#if GNU_EFI_VERSION < 3016
+#if GNU_EFI_VERSION < 3000016
 
 #include <efi.h>
 #include "utils.h"
diff --git a/drivers/watchdog/wdfuncs_start.c b/drivers/watchdog/wdfuncs_start.c
index bdf47f5..c627050 100644
--- a/drivers/watchdog/wdfuncs_start.c
+++ b/drivers/watchdog/wdfuncs_start.c
@@ -12,7 +12,7 @@
  * SPDX-License-Identifier:    GPL-2.0-only
  */
 
-#if GNU_EFI_VERSION < 3016
+#if GNU_EFI_VERSION < 3000016
 
 #include <efi.h>
 #include "utils.h"
diff --git a/main.c b/main.c
index 5d61385..b1bbc56 100644
--- a/main.c
+++ b/main.c
@@ -45,7 +45,7 @@ VOID register_watchdog(WATCHDOG_DRIVER *driver)
 
 static EFI_STATUS probe_watchdogs(UINTN timeout)
 {
-#if GNU_EFI_VERSION < 3016
+#if GNU_EFI_VERSION < 3000016
        const unsigned long *entry = wdfuncs_start;
        for (entry++; entry < wdfuncs_end; entry++) {
                ((void (*)(void))*entry)();
-- 
2.52.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 visit 
https://groups.google.com/d/msgid/efibootguard-dev/2B603319-916F-4EE8-8C4C-44A9444AC9C6%40siemens.com.

Reply via email to