efivar/0015-Add-efi_error_pop-and-pop-some-errors-sometimes.patch
Petr Šabata 974b936917 RHEL 9.0.0 Alpha bootstrap
The content of this branch was automatically imported from Fedora ELN
with the following as its source:
https://src.fedoraproject.org/rpms/efivar#9f54d8029387895b7b1389d9a9f9e0bf476a027f
2020-10-14 23:58:29 +02:00

148 lines
3.7 KiB
Diff

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