nalika / rpms / grub2

Forked from rpms/grub2 2 years ago
Clone

Blame SOURCES/0110-Make-grub_error-more-verbose.patch

8e15ce
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
8e15ce
From: Peter Jones <pjones@redhat.com>
8e15ce
Date: Mon, 27 Aug 2018 13:14:06 -0400
8e15ce
Subject: [PATCH] Make grub_error() more verbose
8e15ce
8e15ce
Signed-off-by: Peter Jones <pjones@redhat.com>
8e15ce
---
8e15ce
 grub-core/kern/err.c | 13 +++++++++++--
8e15ce
 include/grub/err.h   |  8 ++++++--
8e15ce
 2 files changed, 17 insertions(+), 4 deletions(-)
8e15ce
8e15ce
diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
8e15ce
index 53c734de70e..aebfe0cf839 100644
8e15ce
--- a/grub-core/kern/err.c
8e15ce
+++ b/grub-core/kern/err.c
8e15ce
@@ -33,15 +33,24 @@ static struct grub_error_saved grub_error_stack_items[GRUB_ERROR_STACK_SIZE];
8e15ce
 static int grub_error_stack_pos;
8e15ce
 static int grub_error_stack_assert;
8e15ce
 
8e15ce
+#ifdef grub_error
8e15ce
+#undef grub_error
8e15ce
+#endif
8e15ce
+
8e15ce
 grub_err_t
8e15ce
-grub_error (grub_err_t n, const char *fmt, ...)
8e15ce
+grub_error (grub_err_t n, const char *file, const int line, const char *fmt, ...)
8e15ce
 {
8e15ce
   va_list ap;
8e15ce
+  int m;
8e15ce
 
8e15ce
   grub_errno = n;
8e15ce
 
8e15ce
+  m = grub_snprintf (grub_errmsg, sizeof (grub_errmsg), "%s:%d:", file, line);
8e15ce
+  if (m < 0)
8e15ce
+    m = 0;
8e15ce
+
8e15ce
   va_start (ap, fmt);
8e15ce
-  grub_vsnprintf (grub_errmsg, sizeof (grub_errmsg), _(fmt), ap);
8e15ce
+  grub_vsnprintf (grub_errmsg + m, sizeof (grub_errmsg) - m, _(fmt), ap);
8e15ce
   va_end (ap);
8e15ce
 
8e15ce
   return n;
8e15ce
diff --git a/include/grub/err.h b/include/grub/err.h
8e15ce
index b08d5d0de4c..c0f90ef07c8 100644
8e15ce
--- a/include/grub/err.h
8e15ce
+++ b/include/grub/err.h
8e15ce
@@ -85,8 +85,12 @@ struct grub_error_saved
8e15ce
 extern grub_err_t EXPORT_VAR(grub_errno);
8e15ce
 extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG];
8e15ce
 
8e15ce
-grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...)
8e15ce
-    __attribute__ ((format (GNU_PRINTF, 2, 3)));
8e15ce
+grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int line, const char *fmt, ...)
8e15ce
+	__attribute__ ((format (GNU_PRINTF, 4, 5)));
8e15ce
+
8e15ce
+#define grub_error(n, fmt, ...) grub_error (n, __FILE__, __LINE__, fmt, ##__VA_ARGS__)
8e15ce
+
8e15ce
+
8e15ce
 void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
8e15ce
 void EXPORT_FUNC(grub_error_push) (void);
8e15ce
 int EXPORT_FUNC(grub_error_pop) (void);