[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 08/12] kern: Make grub_error() more verbose
From: |
Javier Martinez Canillas |
Subject: |
[PATCH v2 08/12] kern: Make grub_error() more verbose |
Date: |
Wed, 4 Mar 2020 12:58:47 +0100 |
From: Peter Jones <address@hidden>
Add file and line to grub_error() output to make troubleshooting easier.
Signed-off-by: Peter Jones <address@hidden>
Signed-off-by: Javier Martinez Canillas <address@hidden>
---
grub-core/kern/err.c | 13 +++++++++++--
include/grub/err.h | 5 ++++-
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/grub-core/kern/err.c b/grub-core/kern/err.c
index 53c734de70e..aebfe0cf839 100644
--- 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
index 24ba9f5f592..b68bbec3c72 100644
--- a/include/grub/err.h
+++ b/include/grub/err.h
@@ -85,7 +85,10 @@ struct grub_error_saved
extern grub_err_t EXPORT_VAR(grub_errno);
extern char EXPORT_VAR(grub_errmsg)[GRUB_MAX_ERRMSG];
-grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *fmt, ...);
+grub_err_t EXPORT_FUNC(grub_error) (grub_err_t n, const char *file, const int
line, const char *fmt, ...);
+
+#define grub_error(n, fmt, ...) grub_error (n, __FILE__, __LINE__, fmt,
##__VA_ARGS__)
+
void EXPORT_FUNC(grub_fatal) (const char *fmt, ...) __attribute__ ((noreturn));
void EXPORT_FUNC(grub_error_push) (void);
int EXPORT_FUNC(grub_error_pop) (void);
--
2.24.1
- [PATCH v2 02/12] efi: Print more debug info in our module loader, (continued)
- [PATCH v2 02/12] efi: Print more debug info in our module loader, Javier Martinez Canillas, 2020/03/04
- [PATCH v2 03/12] Makefile: Make libgrub.pp depend on config-util.h, Javier Martinez Canillas, 2020/03/04
- [PATCH v2 05/12] normal/completion: Fix possible NULL pointer dereference, Javier Martinez Canillas, 2020/03/04
- [PATCH v2 04/12] kern: Add grub_debug_enabled(), Javier Martinez Canillas, 2020/03/04
- [PATCH v2 06/12] efi/gop: Add support for BLT_ONLY adapters, Javier Martinez Canillas, 2020/03/04
- [PATCH v2 07/12] efi/uga: Use 64 bit for fb_base, Javier Martinez Canillas, 2020/03/04
- [PATCH v2 09/12] efi: Print error messages to grub_efi_allocate_pages_real(), Javier Martinez Canillas, 2020/03/04
- [PATCH v2 11/12] efi/gop: Add debug output on GOP probing, Javier Martinez Canillas, 2020/03/04
- [PATCH v2 08/12] kern: Make grub_error() more verbose,
Javier Martinez Canillas <=
- Re: [PATCH v2 08/12] kern: Make grub_error() more verbose, Daniel Kiper, 2020/03/06
- Message not available
- Re: [PATCH v2 08/12] kern: Make grub_error() more verbose, Daniel Kiper, 2020/03/06
- Re: [PATCH v2 08/12] kern: Make grub_error() more verbose, Vladimir 'phcoder' Serbinenko, 2020/03/06
- Re: [PATCH v2 08/12] kern: Make grub_error() more verbose, Daniel Kiper, 2020/03/09
- Re: [PATCH v2 08/12] kern: Make grub_error() more verbose, Didier Spaier, 2020/03/06