46968b6
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
46968b6
From: =?UTF-8?q?Renaud=20M=C3=A9trich?= <rmetrich@redhat.com>
46968b6
Date: Mon, 25 Nov 2019 09:29:53 +0100
46968b6
Subject: [PATCH] Introduce function grub_debug_is_enabled(void) returning 1 if
46968b6
 'debug' is in the environment and not empty
46968b6
MIME-Version: 1.0
46968b6
Content-Type: text/plain; charset=UTF-8
46968b6
Content-Transfer-Encoding: 8bit
46968b6
46968b6
Signed-off-by: Renaud M├ętrich <rmetrich@redhat.com>
46968b6
---
46968b6
 grub-core/kern/misc.c | 13 +++++++++++++
46968b6
 include/grub/misc.h   |  1 +
46968b6
 2 files changed, 14 insertions(+)
46968b6
46968b6
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
e622855
index 9f54b6b7d2..a186ad3dd4 100644
46968b6
--- a/grub-core/kern/misc.c
46968b6
+++ b/grub-core/kern/misc.c
46968b6
@@ -163,6 +163,19 @@ int grub_err_printf (const char *fmt, ...)
46968b6
 __attribute__ ((alias("grub_printf")));
46968b6
 #endif
46968b6
 
46968b6
+/* Return 1 if 'debug' is set and not empty */
46968b6
+int
46968b6
+grub_debug_is_enabled (void)
46968b6
+{
46968b6
+  const char *debug;
46968b6
+
46968b6
+  debug = grub_env_get ("debug");
46968b6
+  if (!debug || debug[0] == '\0')
46968b6
+    return 0;
46968b6
+
46968b6
+  return 1;
46968b6
+}
46968b6
+
46968b6
 int
46968b6
 grub_debug_enabled (const char * condition)
46968b6
 {
46968b6
diff --git a/include/grub/misc.h b/include/grub/misc.h
e622855
index 3adc4036e3..6c4aa85ac5 100644
46968b6
--- a/include/grub/misc.h
46968b6
+++ b/include/grub/misc.h
46968b6
@@ -340,6 +340,7 @@ grub_puts (const char *s)
46968b6
 }
46968b6
 
46968b6
 int EXPORT_FUNC(grub_puts_) (const char *s);
46968b6
+int EXPORT_FUNC(grub_debug_is_enabled) (void);
46968b6
 int EXPORT_FUNC(grub_debug_enabled) (const char *condition);
46968b6
 void EXPORT_FUNC(grub_real_dprintf) (const char *file,
46968b6
                                      const int line,