dcavalca / rpms / grub2

Forked from rpms/grub2 3 years ago
Clone

Blame SOURCES/0119-Add-grub_debug_enabled.patch

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