diff options
author | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 11:58:34 +0100 |
---|---|---|
committer | Michal Schmidt <mschmidt@redhat.com> | 2014-11-28 12:04:41 +0100 |
commit | 0a1beeb64207eaa88ab9236787b1cbc2f704ae14 (patch) | |
tree | 50117277be2e2078d0373b944a30b4f09bb94443 /src/libsystemd | |
parent | b4d23205f238e06aaa31264628e20669e714acad (diff) |
treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'
Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
Diffstat (limited to 'src/libsystemd')
-rw-r--r-- | src/libsystemd/sd-bus/bus-dump.c | 10 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-kernel.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-track.c | 2 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/bus-util.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/busctl.c | 36 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-chat.c | 66 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-objects.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-bus/test-bus-server.c | 12 | ||||
-rw-r--r-- | src/libsystemd/sd-event/sd-event.c | 8 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/rtnl-util.c | 4 | ||||
-rw-r--r-- | src/libsystemd/sd-rtnl/test-rtnl.c | 8 |
11 files changed, 79 insertions, 79 deletions
diff --git a/src/libsystemd/sd-bus/bus-dump.c b/src/libsystemd/sd-bus/bus-dump.c index 2ddf016a95..54716bd904 100644 --- a/src/libsystemd/sd-bus/bus-dump.c +++ b/src/libsystemd/sd-bus/bus-dump.c @@ -126,7 +126,7 @@ 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("Failed to rewind: %s", strerror(-r)); + log_error_errno(-r, "Failed to rewind: %m"); return r; } @@ -152,7 +152,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { r = sd_bus_message_peek_type(m, &type, &contents); if (r < 0) { - log_error("Failed to peek type: %s", strerror(-r)); + log_error_errno(-r, "Failed to peek type: %m"); return r; } @@ -162,7 +162,7 @@ int bus_message_dump(sd_bus_message *m, FILE *f, unsigned flags) { r = sd_bus_message_exit_container(m); if (r < 0) { - log_error("Failed to exit container: %s", strerror(-r)); + log_error_errno(-r, "Failed to exit container: %m"); return r; } @@ -183,7 +183,7 @@ 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("Failed to enter container: %s", strerror(-r)); + log_error_errno(-r, "Failed to enter container: %m"); return r; } @@ -203,7 +203,7 @@ 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("Failed to get basic: %s", strerror(-r)); + log_error_errno(-r, "Failed to get basic: %m"); return r; } diff --git a/src/libsystemd/sd-bus/bus-kernel.c b/src/libsystemd/sd-bus/bus-kernel.c index 84fb4bdf2b..fe150ccdae 100644 --- a/src/libsystemd/sd-bus/bus-kernel.c +++ b/src/libsystemd/sd-bus/bus-kernel.c @@ -1059,7 +1059,7 @@ int bus_kernel_write_message(sd_bus *bus, sd_bus_message *m, bool hint_sync_call /* Anybody can send us invalid messages, let's just drop them. */ if (r == -EBADMSG || r == -EPROTOTYPE) - log_debug("Ignoring invalid message: %s", strerror(-r)); + log_debug_errno(-r, "Ignoring invalid message: %m"); else return r; } @@ -1243,7 +1243,7 @@ int bus_kernel_read_message(sd_bus *bus, bool hint_priority, int64_t priority) { /* Anybody can send us invalid messages, let's just drop them. */ if (r == -EBADMSG || r == -EPROTOTYPE) { - log_debug("Ignoring invalid message: %s", strerror(-r)); + log_debug_errno(-r, "Ignoring invalid message: %m"); r = 0; } diff --git a/src/libsystemd/sd-bus/bus-track.c b/src/libsystemd/sd-bus/bus-track.c index f3b593d2b8..0b2f2a9059 100644 --- a/src/libsystemd/sd-bus/bus-track.c +++ b/src/libsystemd/sd-bus/bus-track.c @@ -309,7 +309,7 @@ void bus_track_dispatch(sd_bus_track *track) { r = track->handler(track, track->userdata); if (r < 0) - log_debug("Failed to process track handler: %s", strerror(-r)); + log_debug_errno(-r, "Failed to process track handler: %m"); else if (r == 0) bus_track_add_to_queue(track); diff --git a/src/libsystemd/sd-bus/bus-util.c b/src/libsystemd/sd-bus/bus-util.c index 5345526309..4b5c1a6d36 100644 --- a/src/libsystemd/sd-bus/bus-util.c +++ b/src/libsystemd/sd-bus/bus-util.c @@ -1263,12 +1263,12 @@ int bus_property_get_ulong( #endif int bus_log_parse_error(int r) { - log_error("Failed to parse bus message: %s", strerror(-r)); + log_error_errno(-r, "Failed to parse bus message: %m"); return r; } int bus_log_create_error(int r) { - log_error("Failed to create bus message: %s", strerror(-r)); + log_error_errno(-r, "Failed to create bus message: %m"); return r; } diff --git a/src/libsystemd/sd-bus/busctl.c b/src/libsystemd/sd-bus/busctl.c index e432db406b..8cc309c01b 100644 --- a/src/libsystemd/sd-bus/busctl.c +++ b/src/libsystemd/sd-bus/busctl.c @@ -90,7 +90,7 @@ static int list_bus_names(sd_bus *bus, char **argv) { r = sd_bus_list_names(bus, (arg_acquired || arg_unique) ? &acquired : NULL, arg_activatable ? &activatable : NULL); if (r < 0) { - log_error("Failed to list names: %s", strerror(-r)); + log_error_errno(-r, "Failed to list names: %m"); return r; } @@ -105,7 +105,7 @@ static int list_bus_names(sd_bus *bus, char **argv) { r = hashmap_put(names, *i, NAME_IS_ACQUIRED); if (r < 0) { - log_error("Failed to add to hashmap: %s", strerror(-r)); + log_error_errno(-r, "Failed to add to hashmap: %m"); return r; } } @@ -115,7 +115,7 @@ static int list_bus_names(sd_bus *bus, char **argv) { r = hashmap_put(names, *i, NAME_IS_ACTIVATABLE); if (r < 0 && r != -EEXIST) { - log_error("Failed to add to hashmap: %s", strerror(-r)); + log_error_errno(-r, "Failed to add to hashmap: %m"); return r; } } @@ -439,7 +439,7 @@ static int tree(sd_bus *bus, char **argv) { r = sd_bus_list_names(bus, &names, NULL); if (r < 0) { - log_error("Failed to get name list: %s", strerror(-r)); + log_error_errno(-r, "Failed to get name list: %m"); return r; } @@ -1096,7 +1096,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL r = sd_bus_add_match(bus, NULL, m, NULL, NULL); if (r < 0) { - log_error("Failed to add match: %s", strerror(-r)); + log_error_errno(-r, "Failed to add match: %m"); return r; } @@ -1106,7 +1106,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL STRV_FOREACH(i, arg_matches) { r = sd_bus_add_match(bus, NULL, *i, NULL, NULL); if (r < 0) { - log_error("Failed to add match: %s", strerror(-r)); + log_error_errno(-r, "Failed to add match: %m"); return r; } @@ -1116,7 +1116,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL if (!added_something) { r = sd_bus_add_match(bus, NULL, "", NULL, NULL); if (r < 0) { - log_error("Failed to add match: %s", strerror(-r)); + log_error_errno(-r, "Failed to add match: %m"); return r; } } @@ -1126,7 +1126,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL r = sd_bus_process(bus, &m); if (r < 0) { - log_error("Failed to process bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to process bus: %m"); return r; } @@ -1140,7 +1140,7 @@ static int monitor(sd_bus *bus, char *argv[], int (*dump)(sd_bus_message *m, FIL r = sd_bus_wait(bus, (uint64_t) -1); if (r < 0) { - log_error("Failed to wait for bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to wait for bus: %m"); return r; } } @@ -1200,7 +1200,7 @@ static int status(sd_bus *bus, char *argv[]) { &creds); if (r < 0) { - log_error("Failed to get credentials: %s", strerror(-r)); + log_error_errno(-r, "Failed to get credentials: %m"); return r; } @@ -1962,7 +1962,7 @@ int main(int argc, char *argv[]) { r = sd_bus_new(&bus); if (r < 0) { - log_error("Failed to allocate bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate bus: %m"); goto finish; } @@ -1971,25 +1971,25 @@ int main(int argc, char *argv[]) { r = sd_bus_set_monitor(bus, true); if (r < 0) { - log_error("Failed to set monitor mode: %s", strerror(-r)); + log_error_errno(-r, "Failed to set monitor mode: %m"); goto finish; } r = sd_bus_negotiate_creds(bus, true, _SD_BUS_CREDS_ALL); if (r < 0) { - log_error("Failed to enable credentials: %s", strerror(-r)); + log_error_errno(-r, "Failed to enable credentials: %m"); goto finish; } r = sd_bus_negotiate_timestamp(bus, true); if (r < 0) { - log_error("Failed to enable timestamps: %s", strerror(-r)); + log_error_errno(-r, "Failed to enable timestamps: %m"); goto finish; } r = sd_bus_negotiate_fds(bus, true); if (r < 0) { - log_error("Failed to enable fds: %s", strerror(-r)); + log_error_errno(-r, "Failed to enable fds: %m"); goto finish; } } @@ -1999,7 +1999,7 @@ int main(int argc, char *argv[]) { else { r = sd_bus_set_bus_client(bus, true); if (r < 0) { - log_error("Failed to set bus client: %s", strerror(-r)); + log_error_errno(-r, "Failed to set bus client: %m"); goto finish; } @@ -2025,13 +2025,13 @@ int main(int argc, char *argv[]) { } } if (r < 0) { - log_error("Failed to set address: %s", strerror(-r)); + log_error_errno(-r, "Failed to set address: %m"); goto finish; } r = sd_bus_start(bus); if (r < 0) { - log_error("Failed to connect to bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to connect to bus: %m"); goto finish; } diff --git a/src/libsystemd/sd-bus/test-bus-chat.c b/src/libsystemd/sd-bus/test-bus-chat.c index 8ee66cfcda..7703878982 100644 --- a/src/libsystemd/sd-bus/test-bus-chat.c +++ b/src/libsystemd/sd-bus/test-bus-chat.c @@ -54,7 +54,7 @@ static int object_callback(sd_bus *bus, sd_bus_message *m, void *userdata, sd_bu r = sd_bus_reply_method_return(m, NULL); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); return r; } @@ -74,19 +74,19 @@ static int server_init(sd_bus **_bus) { r = sd_bus_open_user(&bus); if (r < 0) { - log_error("Failed to connect to user bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to connect to user bus: %m"); goto fail; } r = sd_bus_get_owner_id(bus, &id); if (r < 0) { - log_error("Failed to get server ID: %s", strerror(-r)); + log_error_errno(-r, "Failed to get server ID: %m"); goto fail; } r = sd_bus_get_unique_name(bus, &unique); if (r < 0) { - log_error("Failed to get unique name: %s", strerror(-r)); + log_error_errno(-r, "Failed to get unique name: %m"); goto fail; } @@ -96,25 +96,25 @@ static int server_init(sd_bus **_bus) { r = sd_bus_request_name(bus, "org.freedesktop.systemd.test", 0); if (r < 0) { - log_error("Failed to acquire name: %s", strerror(-r)); + log_error_errno(-r, "Failed to acquire name: %m"); goto fail; } r = sd_bus_add_fallback(bus, NULL, "/foo/bar", object_callback, NULL); if (r < 0) { - log_error("Failed to add object: %s", strerror(-r)); + log_error_errno(-r, "Failed to add object: %m"); goto fail; } r = sd_bus_add_match(bus, NULL, "type='signal',interface='foo.bar',member='Notify'", match_callback, NULL); if (r < 0) { - log_error("Failed to add match: %s", strerror(-r)); + log_error_errno(-r, "Failed to add match: %m"); goto fail; } r = sd_bus_add_match(bus, NULL, "type='signal',interface='org.freedesktop.DBus',member='NameOwnerChanged'", match_callback, NULL); if (r < 0) { - log_error("Failed to add match: %s", strerror(-r)); + log_error_errno(-r, "Failed to add match: %m"); goto fail; } @@ -141,14 +141,14 @@ static int server(sd_bus *bus) { r = sd_bus_process(bus, &m); if (r < 0) { - log_error("Failed to process requests: %s", strerror(-r)); + log_error_errno(-r, "Failed to process requests: %m"); goto fail; } if (r == 0) { r = sd_bus_wait(bus, (uint64_t) -1); if (r < 0) { - log_error("Failed to wait: %s", strerror(-r)); + log_error_errno(-r, "Failed to wait: %m"); goto fail; } @@ -173,7 +173,7 @@ static int server(sd_bus *bus) { r = sd_bus_message_read(m, "s", &hello); if (r < 0) { - log_error("Failed to get parameter: %s", strerror(-r)); + log_error_errno(-r, "Failed to get parameter: %m"); goto fail; } @@ -187,14 +187,14 @@ static int server(sd_bus *bus) { r = sd_bus_reply_method_return(m, "s", lowercase); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } } else if (sd_bus_message_is_method_call(m, "org.freedesktop.systemd.test", "ExitClient1")) { r = sd_bus_reply_method_return(m, NULL); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } @@ -203,7 +203,7 @@ static int server(sd_bus *bus) { r = sd_bus_reply_method_return(m, NULL); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } @@ -214,7 +214,7 @@ static int server(sd_bus *bus) { r = sd_bus_reply_method_return(m, NULL); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } @@ -224,7 +224,7 @@ static int server(sd_bus *bus) { r = sd_bus_message_read(m, "h", &fd); if (r < 0) { - log_error("Failed to get parameter: %s", strerror(-r)); + log_error_errno(-r, "Failed to get parameter: %m"); goto fail; } @@ -238,7 +238,7 @@ static int server(sd_bus *bus) { r = sd_bus_reply_method_return(m, NULL); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } @@ -248,7 +248,7 @@ static int server(sd_bus *bus) { m, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method.")); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } } @@ -276,7 +276,7 @@ static void* client1(void*p) { r = sd_bus_open_user(&bus); if (r < 0) { - log_error("Failed to connect to user bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to connect to user bus: %m"); goto finish; } @@ -291,13 +291,13 @@ static void* client1(void*p) { "s", "HELLO"); if (r < 0) { - log_error("Failed to issue method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to issue method call: %m"); goto finish; } r = sd_bus_message_read(reply, "s", &hello); if (r < 0) { - log_error("Failed to get string: %s", strerror(-r)); + log_error_errno(-r, "Failed to get string: %m"); goto finish; } @@ -322,7 +322,7 @@ static void* client1(void*p) { "h", pp[1]); if (r < 0) { - log_error("Failed to issue method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to issue method call: %m"); goto finish; } @@ -346,7 +346,7 @@ finish: "org.freedesktop.systemd.test", "ExitClient1"); if (r < 0) - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); else sd_bus_send(bus, q, NULL); @@ -380,7 +380,7 @@ static void* client2(void*p) { r = sd_bus_open_user(&bus); if (r < 0) { - log_error("Failed to connect to user bus: %s", strerror(-r)); + log_error_errno(-r, "Failed to connect to user bus: %m"); goto finish; } @@ -392,7 +392,7 @@ static void* client2(void*p) { "org.object.test", "Foobar"); if (r < 0) { - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); goto finish; } @@ -412,7 +412,7 @@ static void* client2(void*p) { "foo.bar", "Notify"); if (r < 0) { - log_error("Failed to allocate signal: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate signal: %m"); goto finish; } @@ -433,7 +433,7 @@ static void* client2(void*p) { "org.freedesktop.DBus.Peer", "GetMachineId"); if (r < 0) { - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); goto finish; } @@ -445,7 +445,7 @@ static void* client2(void*p) { r = sd_bus_message_read(reply, "s", &mid); if (r < 0) { - log_error("Failed to parse machine ID: %s", strerror(-r)); + log_error_errno(-r, "Failed to parse machine ID: %m"); goto finish; } @@ -462,7 +462,7 @@ static void* client2(void*p) { "org.freedesktop.systemd.test", "Slow"); if (r < 0) { - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); goto finish; } @@ -486,7 +486,7 @@ static void* client2(void*p) { "org.freedesktop.systemd.test", "Slow"); if (r < 0) { - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); goto finish; } @@ -499,13 +499,13 @@ static void* client2(void*p) { while (!quit) { r = sd_bus_process(bus, NULL); if (r < 0) { - log_error("Failed to process requests: %s", strerror(-r)); + log_error_errno(-r, "Failed to process requests: %m"); goto finish; } if (r == 0) { r = sd_bus_wait(bus, (uint64_t) -1); if (r < 0) { - log_error("Failed to wait: %s", strerror(-r)); + log_error_errno(-r, "Failed to wait: %m"); goto finish; } } @@ -525,7 +525,7 @@ finish: "org.freedesktop.systemd.test", "ExitClient2"); if (r < 0) { - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); goto finish; } diff --git a/src/libsystemd/sd-bus/test-bus-objects.c b/src/libsystemd/sd-bus/test-bus-objects.c index 1324e912fc..2ed34e5120 100644 --- a/src/libsystemd/sd-bus/test-bus-objects.c +++ b/src/libsystemd/sd-bus/test-bus-objects.c @@ -237,14 +237,14 @@ static void *server(void *p) { r = sd_bus_process(bus, NULL); if (r < 0) { - log_error("Failed to process requests: %s", strerror(-r)); + log_error_errno(-r, "Failed to process requests: %m"); goto fail; } if (r == 0) { r = sd_bus_wait(bus, (uint64_t) -1); if (r < 0) { - log_error("Failed to wait: %s", strerror(-r)); + log_error_errno(-r, "Failed to wait: %m"); goto fail; } diff --git a/src/libsystemd/sd-bus/test-bus-server.c b/src/libsystemd/sd-bus/test-bus-server.c index 96d6298336..30e2d8cf44 100644 --- a/src/libsystemd/sd-bus/test-bus-server.c +++ b/src/libsystemd/sd-bus/test-bus-server.c @@ -65,14 +65,14 @@ static void *server(void *p) { r = sd_bus_process(bus, &m); if (r < 0) { - log_error("Failed to process requests: %s", strerror(-r)); + log_error_errno(-r, "Failed to process requests: %m"); goto fail; } if (r == 0) { r = sd_bus_wait(bus, (uint64_t) -1); if (r < 0) { - log_error("Failed to wait: %s", strerror(-r)); + log_error_errno(-r, "Failed to wait: %m"); goto fail; } @@ -90,7 +90,7 @@ static void *server(void *p) { r = sd_bus_message_new_method_return(m, &reply); if (r < 0) { - log_error("Failed to allocate return: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate return: %m"); goto fail; } @@ -102,7 +102,7 @@ static void *server(void *p) { &reply, &SD_BUS_ERROR_MAKE_CONST(SD_BUS_ERROR_UNKNOWN_METHOD, "Unknown method.")); if (r < 0) { - log_error("Failed to allocate return: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate return: %m"); goto fail; } } @@ -110,7 +110,7 @@ static void *server(void *p) { if (reply) { r = sd_bus_send(bus, reply, NULL); if (r < 0) { - log_error("Failed to send reply: %s", strerror(-r)); + log_error_errno(-r, "Failed to send reply: %m"); goto fail; } } @@ -147,7 +147,7 @@ static int client(struct context *c) { "org.freedesktop.systemd.test", "Exit"); if (r < 0) { - log_error("Failed to allocate method call: %s", strerror(-r)); + log_error_errno(-r, "Failed to allocate method call: %m"); return r; } diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index fb436adc13..993ef202de 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -2158,9 +2158,9 @@ static int source_dispatch(sd_event_source *s) { if (r < 0) { if (s->description) - log_debug("Event source '%s' returned error, disabling: %s", s->description, strerror(-r)); + log_debug_errno(-r, "Event source '%s' returned error, disabling: %m", s->description); else - log_debug("Event source %p returned error, disabling: %s", s, strerror(-r)); + log_debug_errno(-r, "Event source %p returned error, disabling: %m", s); } if (s->n_ref == 0) @@ -2196,9 +2196,9 @@ static int event_prepare(sd_event *e) { if (r < 0) { if (s->description) - log_debug("Prepare callback of event source '%s' returned error, disabling: %s", s->description, strerror(-r)); + log_debug_errno(-r, "Prepare callback of event source '%s' returned error, disabling: %m", s->description); else - log_debug("Prepare callback of event source %p returned error, disabling: %s", s, strerror(-r)); + log_debug_errno(-r, "Prepare callback of event source %p returned error, disabling: %m", s); } if (s->n_ref == 0) diff --git a/src/libsystemd/sd-rtnl/rtnl-util.c b/src/libsystemd/sd-rtnl/rtnl-util.c index 1ec1fa8d27..1adfbb8643 100644 --- a/src/libsystemd/sd-rtnl/rtnl-util.c +++ b/src/libsystemd/sd-rtnl/rtnl-util.c @@ -157,11 +157,11 @@ bool rtnl_message_type_is_addr(uint16_t type) { } int rtnl_log_parse_error(int r) { - log_error("Failed to parse netlink message: %s", strerror(-r)); + log_error_errno(-r, "Failed to parse netlink message: %m"); return r; } int rtnl_log_create_error(int r) { - log_error("Failed to create netlink message: %s", strerror(-r)); + log_error_errno(-r, "Failed to create netlink message: %m"); return r; } diff --git a/src/libsystemd/sd-rtnl/test-rtnl.c b/src/libsystemd/sd-rtnl/test-rtnl.c index 46b5bb20c3..d77bce45cc 100644 --- a/src/libsystemd/sd-rtnl/test-rtnl.c +++ b/src/libsystemd/sd-rtnl/test-rtnl.c @@ -135,7 +135,7 @@ static void test_route(void) { r = sd_rtnl_message_new_route(NULL, &req, RTM_NEWROUTE, AF_INET, RTPROT_STATIC); if (r < 0) { - log_error("Could not create RTM_NEWROUTE message: %s", strerror(-r)); + log_error_errno(-r, "Could not create RTM_NEWROUTE message: %m"); return; } @@ -143,13 +143,13 @@ static void test_route(void) { r = sd_rtnl_message_append_in_addr(req, RTA_GATEWAY, &addr); if (r < 0) { - log_error("Could not append RTA_GATEWAY attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_GATEWAY attribute: %m"); return; } r = sd_rtnl_message_append_u32(req, RTA_OIF, index); if (r < 0) { - log_error("Could not append RTA_OIF attribute: %s", strerror(-r)); + log_error_errno(-r, "Could not append RTA_OIF attribute: %m"); return; } @@ -223,7 +223,7 @@ static int pipe_handler(sd_rtnl *rtnl, sd_rtnl_message *m, void *userdata) { r = sd_rtnl_message_get_errno(m); - log_info("%d left in pipe. got reply: %s", *counter, strerror(-r)); + log_info_errno(-r, "%d left in pipe. got reply: %m", *counter); assert_se(r >= 0); |