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

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