[PATCH] bg_setenv: Fix error reporting for dumpenv_to_file

4 views
Skip to first unread message

Jan Kiszka

unread,
Oct 8, 2021, 4:08:27 AM10/8/21
to efibootguard-dev
From: Jan Kiszka <jan.k...@siemens.com>

Do not report success when there was none and consistently return 1 on
errors, not sometimes errno and sometimes 1.

Signed-off-by: Jan Kiszka <jan.k...@siemens.com>
---
tools/bg_setenv.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c
index 9056102..6a68ba4 100644
--- a/tools/bg_setenv.c
+++ b/tools/bg_setenv.c
@@ -629,13 +629,14 @@ static int dumpenv_to_file(char *envfilepath) {
fprintf(stderr,
"Error writing to output file: %s\n",
strerror(errno));
- result = errno;
+ result = 1;
+ } else {
+ fprintf(stdout, "Output written to %s.\n", envfilepath);
}
if (fclose(of)) {
fprintf(stderr, "Error closing output file.\n");
- result = errno;
+ result = 1;
};
- fprintf(stdout, "Output written to %s.\n", envfilepath);
} else {
fprintf(stderr, "Error opening output file %s (%s).\n",
envfilepath, strerror(errno));
--
2.31.1
Reply all
Reply to author
Forward
0 new messages