kern: Add grub_debug_enabled()

Add a grub_debug_enabled() helper function instead of open coding it.

Signed-off-by: Peter Jones <pjones@redhat.com>
Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
Peter Jones 2020-03-04 12:58:43 +01:00 committed by Daniel Kiper
parent 42f4054faf
commit 8d88ae92b5
2 changed files with 17 additions and 5 deletions

View file

@ -158,17 +158,28 @@ int grub_err_printf (const char *fmt, ...)
__attribute__ ((alias("grub_printf")));
#endif
int
grub_debug_enabled (const char * condition)
{
const char *debug;
debug = grub_env_get ("debug");
if (!debug)
return 0;
if (grub_strword (debug, "all") || grub_strword (debug, condition))
return 1;
return 0;
}
void
grub_real_dprintf (const char *file, const int line, const char *condition,
const char *fmt, ...)
{
va_list args;
const char *debug = grub_env_get ("debug");
if (! debug)
return;
if (grub_strword (debug, "all") || grub_strword (debug, condition))
if (grub_debug_enabled (condition))
{
grub_printf ("%s:%d: ", file, line);
va_start (args, fmt);

View file

@ -340,6 +340,7 @@ grub_puts (const char *s)
}
int EXPORT_FUNC(grub_puts_) (const char *s);
int EXPORT_FUNC(grub_debug_enabled) (const char *condition);
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
const int line,
const char *condition,