Blame SOURCES/0119-Add-grub_debug_enabled.patch

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