summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hindoe Paaboel Andersen <phomes@gmail.com>2015-05-22 23:40:19 +0200
committerThomas Hindoe Paaboel Andersen <phomes@gmail.com>2015-05-22 23:46:36 +0200
commit717442507b4b11aa1d76810d7b12b15948c7a250 (patch)
treec2da70a626b6a8037cf2f5233f21e88c70ba4e22
parent0454229c100a2113ba82df55703436d6cb2c492b (diff)
downloadsystemd-717442507b4b11aa1d76810d7b12b15948c7a250.tar.gz
bootctl: ferror must be called before FILE is closed
Otherwise it will not show any error stored
-rw-r--r--src/boot/bootctl.c16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/boot/bootctl.c b/src/boot/bootctl.c
index 3a007578dc..ba534b172e 100644
--- a/src/boot/bootctl.c
+++ b/src/boot/bootctl.c
@@ -884,7 +884,7 @@ static int install_loader_config(const char *esp_path) {
char *p;
char line[64];
char *machine = NULL;
- FILE *f;
+ _cleanup_fclose_ FILE *f = NULL, *g = NULL;
f = fopen("/etc/machine-id", "re");
if (!f)
@@ -899,18 +899,16 @@ static int install_loader_config(const char *esp_path) {
if (strlen(line) == 32)
machine = line;
}
- fclose(f);
if (!machine)
return -ESRCH;
p = strjoina(esp_path, "/loader/loader.conf");
- f = fopen(p, "wxe");
- if (f) {
- fprintf(f, "#timeout 3\n");
- fprintf(f, "default %s-*\n", machine);
- fclose(f);
- if (ferror(f))
+ g = fopen(p, "wxe");
+ if (g) {
+ fprintf(g, "#timeout 3\n");
+ fprintf(g, "default %s-*\n", machine);
+ if (ferror(g))
return log_error_errno(EIO, "Failed to write \"%s\": %m", p);
}
@@ -926,7 +924,7 @@ static int help(void) {
" --path=PATH Path to the EFI System Partition (ESP)\n"
" --no-variables Don't touch EFI variables\n"
"\n"
- "Comands:\n"
+ "Commands:\n"
" status Show status of installed systemd-boot and EFI variables\n"
" install Install systemd-boot to the ESP and EFI variables\n"
" update Update systemd-boot in the ESP and EFI variables\n"