From baaa35ad706419ae5aacc11d2bece5bd8b73ee42 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Tue, 20 Nov 2018 23:40:44 +0100 Subject: 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. --- src/portable/portablectl.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) (limited to 'src/portable') diff --git a/src/portable/portablectl.c b/src/portable/portablectl.c index 9d1f3f7815..9af9744fd0 100644 --- a/src/portable/portablectl.c +++ b/src/portable/portablectl.c @@ -62,10 +62,9 @@ static int determine_image(const char *image, bool permit_non_existing, char **r return 0; } - if (arg_transport != BUS_TRANSPORT_LOCAL) { - log_error("Operations on images by path not supported when connecting to remote systems."); - return -EOPNOTSUPP; - } + if (arg_transport != BUS_TRANSPORT_LOCAL) + return log_error_errno(SYNTHETIC_ERRNO(EOPNOTSUPP), + "Operations on images by path not supported when connecting to remote systems."); r = chase_symlinks(image, NULL, CHASE_TRAIL_SLASH | (permit_non_existing ? CHASE_NONEXISTENT : 0), ret); if (r < 0) @@ -135,10 +134,9 @@ static int determine_matches(const char *image, char **l, bool allow_any, char * } else if (strv_equal(l, STRV_MAKE("-"))) { - if (!allow_any) { - log_error("Refusing all unit file match."); - return -EINVAL; - } + if (!allow_any) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Refusing all unit file match."); if (!arg_quiet) log_info("(Matching all unit files.)"); @@ -896,10 +894,9 @@ static int parse_argv(int argc, char *argv[]) { if (streq(optarg, "help")) return dump_profiles(); - if (!filename_is_valid(optarg)) { - log_error("Unit profile name not valid: %s", optarg); - return -EINVAL; - } + if (!filename_is_valid(optarg)) + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Unit profile name not valid: %s", optarg); arg_profile = optarg; break; @@ -914,10 +911,9 @@ static int parse_argv(int argc, char *argv[]) { "copy\n" "symlink"); return 0; - } else { - log_error("Failed to parse --copy= argument: %s", optarg); - return -EINVAL; - } + } else + return log_error_errno(SYNTHETIC_ERRNO(EINVAL), + "Failed to parse --copy= argument: %s", optarg); break; -- cgit v1.2.3