15a207
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
15a207
From: Peter Jones <pjones@redhat.com>
15a207
Date: Thu, 30 Nov 2017 15:11:39 -0500
15a207
Subject: [PATCH] Add grub_debug_enabled()
15a207
15a207
---
15a207
 grub-core/kern/misc.c | 21 ++++++++++++++++-----
15a207
 include/grub/misc.h   |  1 +
15a207
 2 files changed, 17 insertions(+), 5 deletions(-)
15a207
15a207
diff --git a/grub-core/kern/misc.c b/grub-core/kern/misc.c
15a207
index 636f97e1ba1..e758ab3416d 100644
15a207
--- a/grub-core/kern/misc.c
15a207
+++ b/grub-core/kern/misc.c
15a207
@@ -159,17 +159,28 @@ int grub_err_printf (const char *fmt, ...)
15a207
 __attribute__ ((alias("grub_printf")));
15a207
 #endif
15a207
 
15a207
+int
15a207
+grub_debug_enabled (const char * condition)
15a207
+{
15a207
+  const char *debug;
15a207
+
15a207
+  debug = grub_env_get ("debug");
15a207
+  if (!debug)
15a207
+    return 0;
15a207
+
15a207
+  if (grub_strword (debug, "all") || grub_strword (debug, condition))
15a207
+    return 1;
15a207
+
15a207
+  return 0;
15a207
+}
15a207
+
15a207
 void
15a207
 grub_real_dprintf (const char *file, const int line, const char *condition,
15a207
 		   const char *fmt, ...)
15a207
 {
15a207
   va_list args;
15a207
-  const char *debug = grub_env_get ("debug");
15a207
 
15a207
-  if (! debug)
15a207
-    return;
15a207
-
15a207
-  if (grub_strword (debug, "all") || grub_strword (debug, condition))
15a207
+  if (grub_debug_enabled (condition))
15a207
     {
15a207
       grub_printf ("%s:%d: ", file, line);
15a207
       va_start (args, fmt);
15a207
diff --git a/include/grub/misc.h b/include/grub/misc.h
15a207
index cbfae75a1b4..f7473c154f0 100644
15a207
--- a/include/grub/misc.h
15a207
+++ b/include/grub/misc.h
15a207
@@ -367,6 +367,7 @@ grub_puts (const char *s)
15a207
 }
15a207
 
15a207
 int EXPORT_FUNC(grub_puts_) (const char *s);
15a207
+int EXPORT_FUNC(grub_debug_enabled) (const char *condition);
15a207
 void EXPORT_FUNC(grub_real_dprintf) (const char *file,
15a207
                                      const int line,
15a207
                                      const char *condition,