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:
parent
42f4054faf
commit
8d88ae92b5
2 changed files with 17 additions and 5 deletions
|
@ -158,17 +158,28 @@ int grub_err_printf (const char *fmt, ...)
|
||||||
__attribute__ ((alias("grub_printf")));
|
__attribute__ ((alias("grub_printf")));
|
||||||
#endif
|
#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
|
void
|
||||||
grub_real_dprintf (const char *file, const int line, const char *condition,
|
grub_real_dprintf (const char *file, const int line, const char *condition,
|
||||||
const char *fmt, ...)
|
const char *fmt, ...)
|
||||||
{
|
{
|
||||||
va_list args;
|
va_list args;
|
||||||
const char *debug = grub_env_get ("debug");
|
|
||||||
|
|
||||||
if (! debug)
|
if (grub_debug_enabled (condition))
|
||||||
return;
|
|
||||||
|
|
||||||
if (grub_strword (debug, "all") || grub_strword (debug, condition))
|
|
||||||
{
|
{
|
||||||
grub_printf ("%s:%d: ", file, line);
|
grub_printf ("%s:%d: ", file, line);
|
||||||
va_start (args, fmt);
|
va_start (args, fmt);
|
||||||
|
|
|
@ -340,6 +340,7 @@ grub_puts (const char *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
int EXPORT_FUNC(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,
|
void EXPORT_FUNC(grub_real_dprintf) (const char *file,
|
||||||
const int line,
|
const int line,
|
||||||
const char *condition,
|
const char *condition,
|
||||||
|
|
Loading…
Reference in a new issue