summaryrefslogtreecommitdiff
path: root/src/partition
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-15 19:32:42 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2021-02-17 21:06:31 +0100
commit599c7c545f689f7d19a73238eecc69bf94fa6a74 (patch)
tree3d7cc8218ea1771ada8c36d094cda46a51c81291 /src/partition
parent79dbbb261d245b619a4d82c1cdf96f6a4310ee0d (diff)
downloadsystemd-599c7c545f689f7d19a73238eecc69bf94fa6a74.tar.gz
tree-wide: add a helper to parse boolean optarg
This nicely covers the case when optarg is optional. The same parser can be used when the option string passed to getopt_long() requires a parameter and when it doesn't. The error messages are made consistent. Also fixes a log error c&p in --crash-reboot message.
Diffstat (limited to 'src/partition')
-rw-r--r--src/partition/repart.c14
1 files changed, 5 insertions, 9 deletions
diff --git a/src/partition/repart.c b/src/partition/repart.c
index 78c31187ea..ac905cab53 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -44,8 +44,8 @@
#include "mkdir.h"
#include "mkfs-util.h"
#include "mount-util.h"
-#include "parse-util.h"
#include "parse-argument.h"
+#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
#include "proc-cmdline.h"
@@ -3575,11 +3575,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_DRY_RUN:
- r = parse_boolean(optarg);
+ r = parse_boolean_argument("--dry-run=", optarg, &arg_dry_run);
if (r < 0)
- return log_error_errno(r, "Failed to parse --dry-run= parameter: %s", optarg);
-
- dry_run = r;
+ return r;
break;
case ARG_EMPTY:
@@ -3604,11 +3602,9 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_DISCARD:
- r = parse_boolean(optarg);
+ r = parse_boolean_argument("--discard=", optarg, &arg_discard);
if (r < 0)
- return log_error_errno(r, "Failed to parse --discard= parameter: %s", optarg);
-
- arg_discard = r;
+ return r;
break;
case ARG_FACTORY_RESET: