summaryrefslogtreecommitdiff
path: root/src/resolve/resolvconf-compat.c
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/resolve/resolvconf-compat.c
parent52d86690d68779b120a4380f7cc740825827fb0d (diff)
downloadsystemd-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/resolve/resolvconf-compat.c')
-rw-r--r--src/resolve/resolvconf-compat.c37
1 files changed, 17 insertions, 20 deletions
diff --git a/src/resolve/resolvconf-compat.c b/src/resolve/resolvconf-compat.c
index 340767634f..242c26e5ca 100644
--- a/src/resolve/resolvconf-compat.c
+++ b/src/resolve/resolvconf-compat.c
@@ -183,19 +183,19 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
case 'r':
case 'v':
case 'V':
- log_error("Switch -%c not supported.", c);
- return -EINVAL;
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Switch -%c not supported.", c);
/* The Debian resolvconf commands we don't support. */
case ARG_ENABLE_UPDATES:
- log_error("Switch --enable-updates not supported.");
- return -EINVAL;
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Switch --enable-updates not supported.");
case ARG_DISABLE_UPDATES:
- log_error("Switch --disable-updates not supported.");
- return -EINVAL;
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Switch --disable-updates not supported.");
case ARG_UPDATES_ARE_ENABLED:
- log_error("Switch --updates-are-enabled not supported.");
- return -EINVAL;
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Switch --updates-are-enabled not supported.");
case '?':
return -EINVAL;
@@ -204,15 +204,13 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
assert_not_reached("Unhandled option");
}
- if (arg_mode == _MODE_INVALID) {
- log_error("Expected either -a or -d on the command line.");
- return -EINVAL;
- }
+ if (arg_mode == _MODE_INVALID)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Expected either -a or -d on the command line.");
- if (optind+1 != argc) {
- log_error("Expected interface name as argument.");
- return -EINVAL;
- }
+ if (optind+1 != argc)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "Expected interface name as argument.");
r = ifname_mangle(argv[optind], false);
if (r <= 0)
@@ -268,10 +266,9 @@ int resolvconf_parse_argv(int argc, char *argv[]) {
} else if (type == TYPE_PRIVATE)
log_debug("Private DNS server data not supported, ignoring.");
- if (!arg_set_dns) {
- log_error("No DNS servers specified, refusing operation.");
- return -EINVAL;
- }
+ if (!arg_set_dns)
+ return log_error_errno(SYNTHETIC_ERRNO(EINVAL),
+ "No DNS servers specified, refusing operation.");
}
return 1; /* work to do */