summaryrefslogtreecommitdiffstats
path: root/src/portable
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-20 23:40:44 +0100
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-11-22 10:54:38 +0100
commitbaaa35ad706419ae5aacc11d2bece5bd8b73ee42 (patch)
treebb4b9c576fc56b3237d59e959ded7c245917fcd7 /src/portable
parentbasic/log: add concept of "synthethic errnos" (diff)
downloadsystemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.tar.xz
systemd-baaa35ad706419ae5aacc11d2bece5bd8b73ee42.zip
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/portable')
-rw-r--r--src/portable/portablectl.c28
1 files changed, 12 insertions, 16 deletions
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;