summaryrefslogtreecommitdiffstats
path: root/src/cgtop/cgtop.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2018-02-09 16:59:27 +0100
committerLennart Poettering <lennart@poettering.net>2018-02-09 16:59:27 +0100
commitad078b4181d4b62de4b841fcb39b5707542bd38e (patch)
treed895d9a0ffc2b163b6bdce658be903f46e8bd0dc /src/cgtop/cgtop.c
parentcgtop: add helper for checking if we are operating on the root cgroup (diff)
downloadsystemd-ad078b4181d4b62de4b841fcb39b5707542bd38e.tar.xz
systemd-ad078b4181d4b62de4b841fcb39b5707542bd38e.zip
cgtop: command line parsing improvements
Always output the string we were unable to parse and use log_error_errno()'s return logic to shorten our code a bit.
Diffstat (limited to 'src/cgtop/cgtop.c')
-rw-r--r--src/cgtop/cgtop.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c
index 229aadd269..4e406e4ad2 100644
--- a/src/cgtop/cgtop.c
+++ b/src/cgtop/cgtop.c
@@ -782,17 +782,15 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_DEPTH:
r = safe_atou(optarg, &arg_depth);
- if (r < 0) {
- log_error("Failed to parse depth parameter.");
- return -EINVAL;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse depth parameter: %s", optarg);
break;
case 'd':
r = parse_sec(optarg, &arg_delay);
if (r < 0 || arg_delay <= 0) {
- log_error("Failed to parse delay parameter.");
+ log_error("Failed to parse delay parameter: %s", optarg);
return -EINVAL;
}
@@ -800,10 +798,8 @@ static int parse_argv(int argc, char *argv[]) {
case 'n':
r = safe_atou(optarg, &arg_iterations);
- if (r < 0) {
- log_error("Failed to parse iterations parameter.");
- return -EINVAL;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse iterations parameter: %s", optarg);
break;
@@ -866,10 +862,8 @@ static int parse_argv(int argc, char *argv[]) {
case ARG_RECURSIVE:
r = parse_boolean(optarg);
- if (r < 0) {
- log_error("Failed to parse --recursive= argument: %s", optarg);
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to parse --recursive= argument: %s", optarg);
arg_recursive = r;
arg_recursive_unset = r == 0;