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