diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 18:50:43 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 18:56:16 +0100 |
commit | f647962d64e844689f3e2acfce6102fc47e76df2 (patch) | |
tree | dcaf5e38de1d4e31f73f540bc85532ceb72cfa6b /src/tmpfiles/tmpfiles.c | |
parent | e80733be33e52d8ab2f1ae845326d39c600f5612 (diff) |
treewide: yet more log_*_errno + return simplifications
Using:
find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
'local $/;
local $_=<>;
s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg;
print;'
$f
done
And a couple of manual whitespace fixups.
Diffstat (limited to 'src/tmpfiles/tmpfiles.c')
-rw-r--r-- | src/tmpfiles/tmpfiles.c | 36 |
1 files changed, 12 insertions, 24 deletions
diff --git a/src/tmpfiles/tmpfiles.c b/src/tmpfiles/tmpfiles.c index 34a644b26b..1a4f02db33 100644 --- a/src/tmpfiles/tmpfiles.c +++ b/src/tmpfiles/tmpfiles.c @@ -710,10 +710,8 @@ static int create_item(Item *i) { } if (r < 0) { - if (r != -EEXIST) { - log_error_errno(r, "Failed to create directory %s: %m", i->path); - return r; - } + if (r != -EEXIST) + return log_error_errno(r, "Failed to create directory %s: %m", i->path); if (stat(i->path, &st) < 0) { log_error("stat(%s) failed: %m", i->path); @@ -761,10 +759,8 @@ static int create_item(Item *i) { mac_selinux_create_file_clear(); } - if (r < 0) { - log_error_errno(r, "Failed to create fifo %s: %m", i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create fifo %s: %m", i->path); } else { log_debug("%s is not a fifo.", i->path); return 0; @@ -800,10 +796,8 @@ static int create_item(Item *i) { r = symlink_atomic(i->argument, i->path); mac_selinux_create_file_clear(); - if (r < 0) { - log_error_errno(r, "symlink(%s, %s) failed: %m", i->argument, i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "symlink(%s, %s) failed: %m", i->argument, i->path); } else { log_debug("%s is not a symlink or does not point to the correct path.", i->path); return 0; @@ -862,10 +856,8 @@ static int create_item(Item *i) { mac_selinux_create_file_clear(); } - if (r < 0) { - log_error_errno(r, "Failed to create device node %s: %m", i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to create device node %s: %m", i->path); } else { log_debug("%s is not a device node.", i->path); return 0; @@ -938,10 +930,8 @@ static int remove_item_instance(Item *i, const char *instance) { /* FIXME: we probably should use dir_cleanup() here * instead of rm_rf() so that 'x' is honoured. */ r = rm_rf_dangerous(instance, false, i->type == RECURSIVE_REMOVE_PATH, false); - if (r < 0 && r != -ENOENT) { - log_error_errno(r, "rm_rf(%s): %m", instance); - return r; - } + if (r < 0 && r != -ENOENT) + return log_error_errno(r, "rm_rf(%s): %m", instance); break; } @@ -1397,10 +1387,8 @@ static int parse_line(const char *fname, unsigned line, const char *buffer) { } r = hashmap_put(h, i->path, i); - if (r < 0) { - log_error_errno(r, "Failed to insert item %s: %m", i->path); - return r; - } + if (r < 0) + return log_error_errno(r, "Failed to insert item %s: %m", i->path); i = NULL; /* avoid cleanup */ |