summaryrefslogtreecommitdiff
path: root/src/cgtop
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/cgtop
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/cgtop')
-rw-r--r--src/cgtop/cgtop.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index d0fa69ff88..cbae9897a5 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -19,6 +19,7 @@
#include "hashmap.h"
#include "main-func.h"
#include "missing_sched.h"
+#include "parse-argument.h"
#include "parse-util.h"
#include "path-util.h"
#include "pretty-print.h"
@@ -867,12 +868,11 @@ static int parse_argv(int argc, char *argv[]) {
break;
case ARG_RECURSIVE:
- r = parse_boolean(optarg);
+ r = parse_boolean_argument("--recursive=", optarg, &arg_recursive);
if (r < 0)
- return log_error_errno(r, "Failed to parse --recursive= argument '%s': %m", optarg);
+ return r;
- arg_recursive = r;
- arg_recursive_unset = r == 0;
+ arg_recursive_unset = !r;
break;
case 'M':