|
|
a43681 |
From c4e3c85e470705f2e8a3bdebf54ebcea90152963 Mon Sep 17 00:00:00 2001
|
|
|
a43681 |
From: Peter Jones <pjones@redhat.com>
|
|
|
a43681 |
Date: Tue, 28 May 2019 14:02:12 -0400
|
|
|
a43681 |
Subject: [PATCH 15/63] Add efi_error_pop() and pop some errors sometimes.
|
|
|
a43681 |
|
|
|
a43681 |
Signed-off-by: Peter Jones <pjones@redhat.com>
|
|
|
a43681 |
---
|
|
|
a43681 |
src/error.c | 37 +++++++++++++++++++++++++++++--------
|
|
|
a43681 |
src/include/efivar/efivar.h | 9 +++++++++
|
|
|
a43681 |
src/libefivar.map.in | 7 +++++++
|
|
|
a43681 |
src/linux.c | 4 ++++
|
|
|
a43681 |
4 files changed, 49 insertions(+), 8 deletions(-)
|
|
|
a43681 |
|
|
|
a43681 |
diff --git a/src/error.c b/src/error.c
|
|
|
a43681 |
index d1008a3d676..df03d7f45e0 100644
|
|
|
a43681 |
--- a/src/error.c
|
|
|
a43681 |
+++ b/src/error.c
|
|
|
a43681 |
@@ -78,6 +78,22 @@ efi_error_get(unsigned int n,
|
|
|
a43681 |
return 1;
|
|
|
a43681 |
}
|
|
|
a43681 |
|
|
|
a43681 |
+static inline UNUSED void
|
|
|
a43681 |
+clear_error_entry(error_table_entry *et)
|
|
|
a43681 |
+{
|
|
|
a43681 |
+ if (!et)
|
|
|
a43681 |
+ return;
|
|
|
a43681 |
+
|
|
|
a43681 |
+ if (et->filename)
|
|
|
a43681 |
+ free(et->filename);
|
|
|
a43681 |
+ if (et->function)
|
|
|
a43681 |
+ free(et->function);
|
|
|
a43681 |
+ if (et->message)
|
|
|
a43681 |
+ free(et->message);
|
|
|
a43681 |
+
|
|
|
a43681 |
+ memset(et, '\0', sizeof(*et));
|
|
|
a43681 |
+}
|
|
|
a43681 |
+
|
|
|
a43681 |
int PUBLIC NONNULL(1, 2, 5) PRINTF(5, 6)
|
|
|
a43681 |
efi_error_set(const char *filename,
|
|
|
a43681 |
const char *function,
|
|
|
a43681 |
@@ -136,6 +152,16 @@ err:
|
|
|
a43681 |
return -1;
|
|
|
a43681 |
}
|
|
|
a43681 |
|
|
|
a43681 |
+void PUBLIC
|
|
|
a43681 |
+efi_error_pop(void)
|
|
|
a43681 |
+{
|
|
|
a43681 |
+ if (current <= 0)
|
|
|
a43681 |
+ return;
|
|
|
a43681 |
+
|
|
|
a43681 |
+ current -= 1;
|
|
|
a43681 |
+ clear_error_entry(&error_table[current]);
|
|
|
a43681 |
+}
|
|
|
a43681 |
+
|
|
|
a43681 |
void PUBLIC DESTRUCTOR
|
|
|
a43681 |
efi_error_clear(void)
|
|
|
a43681 |
{
|
|
|
a43681 |
@@ -143,14 +169,7 @@ efi_error_clear(void)
|
|
|
a43681 |
for (unsigned int i = 0; i < current; i++) {
|
|
|
a43681 |
error_table_entry *et = &error_table[i];
|
|
|
a43681 |
|
|
|
a43681 |
- if (et->filename)
|
|
|
a43681 |
- free(et->filename);
|
|
|
a43681 |
- if (et->function)
|
|
|
a43681 |
- free(et->function);
|
|
|
a43681 |
- if (et->message)
|
|
|
a43681 |
- free(et->message);
|
|
|
a43681 |
-
|
|
|
a43681 |
- memset(et, '\0', sizeof(*et));
|
|
|
a43681 |
+ clear_error_entry(et);
|
|
|
a43681 |
}
|
|
|
a43681 |
free(error_table);
|
|
|
a43681 |
}
|
|
|
a43681 |
@@ -182,3 +201,5 @@ efi_get_verbose(void)
|
|
|
a43681 |
{
|
|
|
a43681 |
return efi_verbose;
|
|
|
a43681 |
}
|
|
|
a43681 |
+
|
|
|
a43681 |
+// vim:fenc=utf-8:tw=75:noet
|
|
|
a43681 |
diff --git a/src/include/efivar/efivar.h b/src/include/efivar/efivar.h
|
|
|
a43681 |
index ad6449d9d93..dabf41789e5 100644
|
|
|
a43681 |
--- a/src/include/efivar/efivar.h
|
|
|
a43681 |
+++ b/src/include/efivar/efivar.h
|
|
|
a43681 |
@@ -187,6 +187,7 @@ extern int efi_error_set(const char *filename,
|
|
|
a43681 |
__attribute__((__nonnull__ (1, 2, 5)))
|
|
|
a43681 |
__attribute__((__format__ (printf, 5, 6)));
|
|
|
a43681 |
extern void efi_error_clear(void);
|
|
|
a43681 |
+extern void efi_error_pop(void);
|
|
|
a43681 |
#else
|
|
|
a43681 |
static inline int
|
|
|
a43681 |
__attribute__((__nonnull__ (2, 3, 4, 5, 6)))
|
|
|
a43681 |
@@ -218,6 +219,12 @@ efi_error_clear(void)
|
|
|
a43681 |
{
|
|
|
a43681 |
return;
|
|
|
a43681 |
}
|
|
|
a43681 |
+
|
|
|
a43681 |
+static inline void
|
|
|
a43681 |
+efi_error_pop(void)
|
|
|
a43681 |
+{
|
|
|
a43681 |
+ return;
|
|
|
a43681 |
+}
|
|
|
a43681 |
#endif
|
|
|
a43681 |
|
|
|
a43681 |
#define efi_error_real__(errval, file, function, line, fmt, args...) \
|
|
|
a43681 |
@@ -238,3 +245,5 @@ extern FILE * efi_get_logfile(void)
|
|
|
a43681 |
#include <efivar/efivar-dp.h>
|
|
|
a43681 |
|
|
|
a43681 |
#endif /* EFIVAR_H */
|
|
|
a43681 |
+
|
|
|
a43681 |
+// vim:fenc=utf-8:tw=75:noet
|
|
|
a43681 |
diff --git a/src/libefivar.map.in b/src/libefivar.map.in
|
|
|
a43681 |
index b5ee1ce334a..8e50d574f10 100644
|
|
|
a43681 |
--- a/src/libefivar.map.in
|
|
|
a43681 |
+++ b/src/libefivar.map.in
|
|
|
a43681 |
@@ -127,3 +127,10 @@ LIBEFIVAR_1.36 {
|
|
|
a43681 |
efi_get_verbose;
|
|
|
a43681 |
efi_get_logfile;
|
|
|
a43681 |
} LIBEFIVAR_1.35;
|
|
|
a43681 |
+
|
|
|
a43681 |
+LIBEFIVAR_1.37 {
|
|
|
a43681 |
+} LIBEFIVAR_1.36;
|
|
|
a43681 |
+
|
|
|
a43681 |
+LIBEFIVAR_1.38 {
|
|
|
a43681 |
+ global: efi_error_pop;
|
|
|
a43681 |
+} LIBEFIVAR_1.37;
|
|
|
a43681 |
diff --git a/src/linux.c b/src/linux.c
|
|
|
a43681 |
index 4bb453be834..4e102da5e24 100644
|
|
|
a43681 |
--- a/src/linux.c
|
|
|
a43681 |
+++ b/src/linux.c
|
|
|
a43681 |
@@ -405,6 +405,8 @@ struct device HIDDEN
|
|
|
a43681 |
rc = sysfs_readlink(&tmpbuf,
|
|
|
a43681 |
"block/%s/device/device/driver",
|
|
|
a43681 |
dev->disk_name);
|
|
|
a43681 |
+ if (rc >= 0 && tmpbuf)
|
|
|
a43681 |
+ efi_error_pop();
|
|
|
a43681 |
}
|
|
|
a43681 |
if (rc < 0 || !tmpbuf) {
|
|
|
a43681 |
efi_error("readlink of /sys/block/%s/device/driver failed",
|
|
|
a43681 |
@@ -626,3 +628,5 @@ get_sector_size(int filedes)
|
|
|
a43681 |
sector_size = 512;
|
|
|
a43681 |
return sector_size;
|
|
|
a43681 |
}
|
|
|
a43681 |
+
|
|
|
a43681 |
+// vim:fenc=utf-8:tw=75:et
|
|
|
a43681 |
--
|
|
|
a43681 |
2.26.2
|
|
|
a43681 |
|