summaryrefslogtreecommitdiff
path: root/src/libsystemd
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 18:23:20 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 18:24:30 +0100
commit23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41 (patch)
tree28e66fb86dd0cffc3a3cca3cf234cb52c3b64ad3 /src/libsystemd
parent5e03c6e3b517286bbd65b48d88f60e5b83721894 (diff)
treewide: more log_*_errno + return simplifications
Diffstat (limited to 'src/libsystemd')
-rw-r--r--src/libsystemd/sd-bus/bus-dump.c30
-rw-r--r--src/libsystemd/sd-bus/bus-util.c6
-rw-r--r--src/libsystemd/sd-bus/busctl.c60
3 files changed, 32 insertions, 64 deletions
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c
index b57ac41e05..722a65448d 100644
--- a/src/libsystemd/sd-bus/bus-dump.c
+++ b/src/libsystemd/sd-bus/bus-dump.c
@@ -125,10 +125,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
}
r = sd_bus_message_rewind(m, !(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY));
- if (r < 0) {
- log_error_errno(r, "Failed to rewind: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to rewind: %m");
if (!(flags & BUS_MESSAGE_DUMP_SUBTREE_ONLY))
fprintf(f, "%sMESSAGE \"%s\" {\n", indent(0, flags), strempty(m->root_container.signature));
@@ -151,20 +149,16 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
} basic;
r = sd_bus_message_peek_type(m, &type, &contents);
- if (r < 0) {
- log_error_errno(r, "Failed to peek type: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to peek type: %m");
if (r == 0) {
if (level <= 1)
break;
r = sd_bus_message_exit_container(m);
- if (r < 0) {
- log_error_errno(r, "Failed to exit container: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to exit container: %m");
level--;
@@ -182,10 +176,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
if (bus_type_is_container(type) > 0) {
r = sd_bus_message_enter_container(m, type, contents);
- if (r < 0) {
- log_error_errno(r, "Failed to enter container: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to enter container: %m");
if (type == SD_BUS_TYPE_ARRAY)
fprintf(f, "%sARRAY \"%s\" {\n", prefix, contents);
@@ -202,10 +194,8 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) {
}
r = sd_bus_message_read_basic(m, type, &basic);
- if (r < 0) {
- log_error_errno(r, "Failed to get basic: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get basic: %m");
assert(r > 0);
diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c
index 9fcbfccc02..bdaa4494a1 100644
--- a/src/libsystemd/sd-bus/bus-util.c
+++ b/src/libsystemd/sd-bus/bus-util.c
@@ -1263,13 +1263,11 @@ int bus_property_get_ulong(
#endif
int bus_log_parse_error(int r) {
- log_error_errno(r, "Failed to parse bus message: %m");
- return r;
+ return log_error_errno(r, "Failed to parse bus message: %m");
}
int bus_log_create_error(int r) {
- log_error_errno(r, "Failed to create bus message: %m");
- return r;
+ return log_error_errno(r, "Failed to create bus message: %m");
}
int bus_parse_unit_info(sd_bus_message *message, UnitInfo *u) {
diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c
index febfc98a59..229a1cf9a2 100644
--- a/src/libsystemd/sd-bus/busctl.c
+++ b/src/libsystemd/sd-bus/busctl.c
@@ -89,10 +89,8 @@ static int list_bus_names(sd_bus *bus, char **argv) {
arg_unique = arg_acquired = arg_activatable = true;
r = sd_bus_list_names(bus, (arg_acquired || arg_unique) ? &acquired : NULL, arg_activatable ? &activatable : NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to list names: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to list names: %m");
pager_open_if_enabled();
@@ -104,20 +102,16 @@ static int list_bus_names(sd_bus *bus, char **argv) {
max_i = MAX(max_i, strlen(*i));
r = hashmap_put(names, *i, NAME_IS_ACQUIRED);
- if (r < 0) {
- log_error_errno(r, "Failed to add to hashmap: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add to hashmap: %m");
}
STRV_FOREACH(i, activatable) {
max_i = MAX(max_i, strlen(*i));
r = hashmap_put(names, *i, NAME_IS_ACTIVATABLE);
- if (r < 0 && r != -EEXIST) {
- log_error_errno(r, "Failed to add to hashmap: %m");
- return r;
- }
+ if (r < 0 && r != -EEXIST)
+ return log_error_errno(r, "Failed to add to hashmap: %m");
}
merged = new(char*, hashmap_size(names) + 1);
@@ -438,10 +432,8 @@ static int tree(sd_bus *bus, char **argv) {
bool not_first = false;
r = sd_bus_list_names(bus, &names, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to get name list: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get name list: %m");
pager_open_if_enabled();
@@ -1095,40 +1087,32 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
return log_oom();
r = sd_bus_add_match(bus, NULL, m, NULL, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to add match: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match: %m");
added_something = true;
}
STRV_FOREACH(i, arg_matches) {
r = sd_bus_add_match(bus, NULL, *i, NULL, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to add match: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match: %m");
added_something = true;
}
if (!added_something) {
r = sd_bus_add_match(bus, NULL, "", NULL, NULL);
- if (r < 0) {
- log_error_errno(r, "Failed to add match: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to add match: %m");
}
for (;;) {
_cleanup_bus_message_unref_ sd_bus_message *m = NULL;
r = sd_bus_process(bus, &m);
- if (r < 0) {
- log_error_errno(r, "Failed to process bus: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to process bus: %m");
if (m) {
dump(m, stdout);
@@ -1139,10 +1123,8 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL
continue;
r = sd_bus_wait(bus, (uint64_t) -1);
- if (r < 0) {
- log_error_errno(r, "Failed to wait for bus: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to wait for bus: %m");
}
}
@@ -1206,10 +1188,8 @@ static int status(sd_bus *bus, char *argv[]) {
&creds);
}
- if (r < 0) {
- log_error_errno(r, "Failed to get credentials: %m");
- return r;
- }
+ if (r < 0)
+ return log_error_errno(r, "Failed to get credentials: %m");
bus_creds_dump(creds, NULL, false);
return 0;