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/login/loginctl.c | |
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/login/loginctl.c')
-rw-r--r-- | src/login/loginctl.c | 29 |
1 files changed, 13 insertions, 16 deletions
diff --git a/src/login/loginctl.c b/src/login/loginctl.c index 427bb431cf..fb5240d7d3 100644 --- a/src/login/loginctl.c +++ b/src/login/loginctl.c @@ -763,10 +763,10 @@ static int print_property(const char *name, const char *expected_value, sd_bus_m if (r < 0) return bus_log_parse_error(r); - if (!uid_is_valid(uid)) { - log_error("Invalid user ID: " UID_FMT, uid); - return -EINVAL; - } + if (!uid_is_valid(uid)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Invalid user ID: " UID_FMT, + uid); bus_print_property_value(name, expected_value, value, UID_FMT, uid); return 1; @@ -1419,10 +1419,9 @@ static int parse_argv(int argc, char *argv[]) { break; case 'n': - if (safe_atou(optarg, &arg_lines) < 0) { - log_error("Failed to parse lines '%s'", optarg); - return -EINVAL; - } + if (safe_atou(optarg, &arg_lines) < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse lines '%s'", optarg); break; case 'o': @@ -1432,10 +1431,9 @@ static int parse_argv(int argc, char *argv[]) { } arg_output = output_mode_from_string(optarg); - if (arg_output < 0) { - log_error("Unknown output '%s'.", optarg); - return -EINVAL; - } + if (arg_output < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Unknown output '%s'.", optarg); break; case ARG_NO_PAGER: @@ -1461,10 +1459,9 @@ static int parse_argv(int argc, char *argv[]) { } arg_signal = signal_from_string(optarg); - if (arg_signal < 0) { - log_error("Failed to parse signal string %s.", optarg); - return -EINVAL; - } + if (arg_signal < 0) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse signal string %s.", optarg); break; case 'H': |