diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-20 23:40:44 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-11-22 10:54:38 +0100 |
commit | baaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch) | |
tree | bb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/analyze | |
parent | 52d86690d68779b120a4380f7cc740825827fb0d (diff) | |
download | systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.tar.gz |
coccinelle: make use of SYNTHETIC_ERRNO
Ideally, coccinelle would strip unnecessary braces too. But I do not see any
option in coccinelle for this, so instead, I edited the patch text using
search&replace to remove the braces. Unfortunately this is not fully automatic,
in particular it didn't deal well with if-else-if-else blocks and ifdefs, so
there is an increased likelikehood be some bugs in such spots.
I also removed part of the patch that coccinelle generated for udev, where we
returns -1 for failure. This should be fixed independently.
Diffstat (limited to 'src/analyze')
-rw-r--r-- | src/analyze/analyze.c | 43 |
1 files changed, 19 insertions, 24 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 5e0e03f53d..757ddea098 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -1360,10 +1360,10 @@ static int cat_config(int argc, char *argv[], void *userdata) { break; } - if (!t) { - log_error("Path %s does not start with any known prefix.", *arg); - return -EINVAL; - } + if (!t) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Path %s does not start with any known prefix.", + *arg); } else t = *arg; @@ -1638,10 +1638,9 @@ static int dump_syscall_filters(int argc, char *argv[], void *userdata) { } #else -static int dump_syscall_filters(int argc, char *argv[], void *userdata) { - log_error("Not compiled with syscall filters, sorry."); - return -EOPNOTSUPP; -} +static int dump_syscall_filters(int argc, char *argv[], void *userdata) + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), + "Not compiled with syscall filters, sorry."); #endif static int dump_timespan(int argc, char *argv[], void *userdata) { @@ -1948,10 +1947,9 @@ static int parse_argv(int argc, char *argv[]) { case ARG_MAN: if (optarg) { r = parse_boolean(optarg); - if (r < 0) { - log_error("Failed to parse --man= argument."); - return -EINVAL; - } + if (r < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse --man= argument."); arg_man = r; } else @@ -1962,10 +1960,9 @@ static int parse_argv(int argc, char *argv[]) { case ARG_GENERATORS: if (optarg) { r = parse_boolean(optarg); - if (r < 0) { - log_error("Failed to parse --generators= argument."); - return -EINVAL; - } + if (r < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse --generators= argument."); arg_generators = r; } else @@ -1981,15 +1978,13 @@ static int parse_argv(int argc, char *argv[]) { } if (arg_scope == UNIT_FILE_GLOBAL && - !STR_IN_SET(argv[optind] ?: "time", "dot", "unit-paths", "verify")) { - log_error("Option --global only makes sense with verbs dot, unit-paths, verify."); - return -EINVAL; - } + !STR_IN_SET(argv[optind] ?: "time", "dot", "unit-paths", "verify")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Option --global only makes sense with verbs dot, unit-paths, verify."); - if (arg_root && !streq_ptr(argv[optind], "cat-config")) { - log_error("Option --root is only supported for cat-config right now."); - return -EINVAL; - } + if (arg_root && !streq_ptr(argv[optind], "cat-config")) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Option --root is only supported for cat-config right now."); return 1; /* work to do */ } |