summaryrefslogtreecommitdiffstats
path: root/src/firstboot/firstboot.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-16 17:16:42 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2019-07-17 12:07:19 +0200
commitbfbf5f7408b3ded4f50012184d408f4395a577ca (patch)
tree5d77e0683c47062218e17acaf45323fd2518589c /src/firstboot/firstboot.c
parentwait-online: change log level (diff)
downloadsystemd-bfbf5f7408b3ded4f50012184d408f4395a577ca.tar.xz
systemd-bfbf5f7408b3ded4f50012184d408f4395a577ca.zip
firstboot: use free_and_strdup, free_and_replace
Diffstat (limited to '')
-rw-r--r--src/firstboot/firstboot.c13
1 files changed, 2 insertions, 11 deletions
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 74b83f348b..dca3a25e34 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -186,21 +186,15 @@ static int prompt_loop(const char *text, char **l, bool (*is_valid)(const char *
r = safe_atou(p, &u);
if (r >= 0) {
- char *c;
-
if (u <= 0 || u > strv_length(l)) {
log_error("Specified entry number out of range.");
continue;
}
log_info("Selected '%s'.", l[u-1]);
-
- c = strdup(l[u-1]);
- if (!c)
+ if (free_and_strdup(ret, l[u-1]) < 0)
return log_oom();
- free(*ret);
- *ret = c;
return 0;
}
@@ -209,10 +203,7 @@ static int prompt_loop(const char *text, char **l, bool (*is_valid)(const char *
continue;
}
- free(*ret);
- *ret = p;
- p = 0;
- return 0;
+ return free_and_replace(*ret, p);
}
}