From 8d3d7072e609ef0e0fb37e1d19a29307d58146c3 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Fri, 28 Nov 2014 19:13:53 +0100 Subject: [PATCH] treewide: a few more log_*_errno + return simplifications The one in tmpfiles.c:create_item() even looks like it fixes a bug. --- src/libsystemd/sd-rtnl/rtnl-util.c | 6 ++---- src/machine/machine.c | 3 +-- src/modules-load/modules-load.c | 3 +-- src/resolve/resolved-manager.c | 6 ++---- src/shared/logs-show.c | 3 +-- src/sysctl/sysctl.c | 3 +-- src/sysusers/sysusers.c | 3 +-- src/tmpfiles/tmpfiles.c | 9 +++------ 8 files changed, 12 insertions(+), 24 deletions(-) diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c index bd97ba9ae7f..4521742b8e9 100644 --- a/src/libsystemd/sd-rtnl/rtnl-util.c +++ b/src/libsystemd/sd-rtnl/rtnl-util.c @@ -157,11 +157,9 @@ bool rtnl_message_type_is_addr(uint16_t type) { } int rtnl_log_parse_error(int r) { - log_error_errno(r, "Failed to parse netlink message: %m"); - return r; + return log_error_errno(r, "Failed to parse netlink message: %m"); } int rtnl_log_create_error(int r) { - log_error_errno(r, "Failed to create netlink message: %m"); - return r; + return log_error_errno(r, "Failed to create netlink message: %m"); } diff --git a/src/machine/machine.c b/src/machine/machine.c index 40189269e01..0d84213eeae 100644 --- a/src/machine/machine.c +++ b/src/machine/machine.c @@ -259,8 +259,7 @@ int machine_load(Machine *m) { if (r == -ENOENT) return 0; - log_error_errno(r, "Failed to read %s: %m", m->state_file); - return r; + return log_error_errno(r, "Failed to read %s: %m", m->state_file); } if (id) diff --git a/src/modules-load/modules-load.c b/src/modules-load/modules-load.c index 1fd01adbe44..4dbacd13dc3 100644 --- a/src/modules-load/modules-load.c +++ b/src/modules-load/modules-load.c @@ -139,8 +139,7 @@ static int apply_file(struct kmod_ctx *ctx, const char *path, bool ignore_enoent if (ignore_enoent && r == -ENOENT) return 0; - log_error_errno(r, "Failed to open %s, ignoring: %m", path); - return r; + return log_error_errno(r, "Failed to open %s, ignoring: %m", path); } log_debug("apply: %s", path); diff --git a/src/resolve/resolved-manager.c b/src/resolve/resolved-manager.c index 9f61c9d9a29..661f8fc738d 100644 --- a/src/resolve/resolved-manager.c +++ b/src/resolve/resolved-manager.c @@ -379,10 +379,8 @@ static int manager_watch_hostname(Manager *m) { if (r == -EPERM) /* kernels prior to 3.2 don't support polling this file. Ignore the failure. */ m->hostname_fd = safe_close(m->hostname_fd); - else { - log_error_errno(r, "Failed to add hostname event source: %m"); - return r; - } + else + return log_error_errno(r, "Failed to add hostname event source: %m"); } r = determine_hostname(&m->hostname); diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c index 2da4ef3e120..98972eda3b0 100644 --- a/src/shared/logs-show.c +++ b/src/shared/logs-show.c @@ -858,8 +858,7 @@ static int output_cat( if (r == -ENOENT) return 0; - log_error_errno(r, "Failed to get data: %m"); - return r; + return log_error_errno(r, "Failed to get data: %m"); } assert(l >= 8); diff --git a/src/sysctl/sysctl.c b/src/sysctl/sysctl.c index 346ff3b2378..2d1ae6e8b17 100644 --- a/src/sysctl/sysctl.c +++ b/src/sysctl/sysctl.c @@ -134,8 +134,7 @@ static int parse_file(Hashmap *sysctl_options, const char *path, bool ignore_eno if (ignore_enoent && r == -ENOENT) return 0; - log_error_errno(r, "Failed to open file '%s', ignoring: %m", path); - return r; + return log_error_errno(r, "Failed to open file '%s', ignoring: %m", path); } log_debug("parse: %s", path); diff --git a/src/sysusers/sysusers.c b/src/sysusers/sysusers.c index 3a56b6b482a..845a307ae71 100644 --- a/src/sysusers/sysusers.c +++ b/src/sysusers/sysusers.c @@ -1709,8 +1709,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) { if (ignore_enoent && r == -ENOENT) return 0; - log_error_errno(r, "Failed to open '%s', ignoring: %m", fn); - return r; + return log_error_errno(r, "Failed to open '%s', ignoring: %m", fn); } f = rf; diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 1a4f02db33d..45d31fb5d80 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -667,10 +667,8 @@ static int create_item(Item *i) { if (r < 0) { struct stat a, b; - if (r != -EEXIST) { - log_error_errno(r, "Failed to copy files to %s: %m", i->path); - return -r; - } + if (r != -EEXIST) + return log_error_errno(r, "Failed to copy files to %s: %m", i->path); if (stat(i->argument, &a) < 0) { log_error("stat(%s) failed: %m", i->argument); @@ -1519,8 +1517,7 @@ static int read_config_file(const char *fn, bool ignore_enoent) { if (ignore_enoent && r == -ENOENT) return 0; - log_error_errno(r, "Failed to open '%s', ignoring: %m", fn); - return r; + return log_error_errno(r, "Failed to open '%s', ignoring: %m", fn); } FOREACH_LINE(line, f, break) {