From: Lennart Poettering Date: Fri, 9 Feb 2018 15:59:27 +0000 (+0100) Subject: cgtop: command line parsing improvements X-Git-Tag: v238~33^2~9 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=ad078b4181d4b62de4b841fcb39b5707542bd38e;p=thirdparty%2Fsystemd.git 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. --- diff --git a/src/cgtop/cgtop.c b/src/cgtop/cgtop.c index 229aadd2698..4e406e4ad25 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;