summaryrefslogtreecommitdiff
path: root/src/firstboot/firstboot.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/firstboot/firstboot.c')
-rw-r--r--src/firstboot/firstboot.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/src/firstboot/firstboot.c b/src/firstboot/firstboot.c
index 01a3d38746..e2a1c00a75 100644
--- a/src/firstboot/firstboot.c
+++ b/src/firstboot/firstboot.c
@@ -716,10 +716,8 @@ static int parse_argv(int argc, char *argv[]) {
path_kill_slashes(arg_root);
- if (path_equal(arg_root, "/")) {
- free(arg_root);
- arg_root = NULL;
- }
+ if (path_equal(arg_root, "/"))
+ arg_root = mfree(arg_root);
break;
@@ -729,9 +727,8 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
- free(arg_locale);
- arg_locale = strdup(optarg);
- if (!arg_locale)
+ r = free_and_strdup(&arg_locale, optarg);
+ if (r < 0)
return log_oom();
break;
@@ -742,9 +739,8 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
- free(arg_locale_messages);
- arg_locale_messages = strdup(optarg);
- if (!arg_locale_messages)
+ r = free_and_strdup(&arg_locale_messages, optarg);
+ if (r < 0)
return log_oom();
break;
@@ -755,24 +751,20 @@ static int parse_argv(int argc, char *argv[]) {
return -EINVAL;
}
- free(arg_timezone);
- arg_timezone = strdup(optarg);
- if (!arg_timezone)
+ r = free_and_strdup(&arg_timezone, optarg);
+ if (r < 0)
return log_oom();
break;
case ARG_ROOT_PASSWORD:
- free(arg_root_password);
- arg_root_password = strdup(optarg);
- if (!arg_root_password)
+ r = free_and_strdup(&arg_root_password, optarg);
+ if (r < 0)
return log_oom();
-
break;
case ARG_ROOT_PASSWORD_FILE:
- free(arg_root_password);
- arg_root_password = NULL;
+ arg_root_password = mfree(arg_root_password);
r = read_one_line_file(optarg, &arg_root_password);
if (r < 0)
@@ -787,7 +779,8 @@ static int parse_argv(int argc, char *argv[]) {
}
hostname_cleanup(optarg);
- if (free_and_strdup(&arg_hostname, optarg) < 0)
+ r = free_and_strdup(&arg_hostname, optarg);
+ if (r < 0)
return log_oom();
break;