From 279d3c9cead3a7ffb657fedbab0e2bc90db45667 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Fri, 28 Nov 2014 14:45:55 +0100 Subject: treewide: more log_*_errno() conversions --- src/core/load-dropin.c | 2 +- src/core/main.c | 2 +- src/journal/journalctl.c | 6 +++--- src/libsystemd/sd-resolve/test-resolve.c | 8 ++++---- src/shared/socket-util.c | 2 +- src/socket-proxy/socket-proxyd.c | 2 +- src/udev/udev-rules.c | 8 ++++---- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/core/load-dropin.c b/src/core/load-dropin.c index 0abac9584d..8da4adc9a2 100644 --- a/src/core/load-dropin.c +++ b/src/core/load-dropin.c @@ -71,7 +71,7 @@ static int iterate_dir( de = readdir(d); if (!de && errno != 0) { k = errno; - log_error("Failed to read directory %s: %s", path, strerror(k)); + log_error_errno(k, "Failed to read directory %s: %m", path); return -k; } diff --git a/src/core/main.c b/src/core/main.c index 30de748452..c204758d43 100644 --- a/src/core/main.c +++ b/src/core/main.c @@ -354,7 +354,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value) { if (env) arg_default_environment = env; else - log_warning("Setting environment variable '%s' failed, ignoring: %s", value, strerror(ENOMEM)); + log_warning_errno(ENOMEM, "Setting environment variable '%s' failed, ignoring: %m", value); } else log_warning("Environment variable name '%s' is not valid. Ignoring.", value); diff --git a/src/journal/journalctl.c b/src/journal/journalctl.c index 6077b6e1a2..1fdd7fc5c8 100644 --- a/src/journal/journalctl.c +++ b/src/journal/journalctl.c @@ -1382,7 +1382,7 @@ static int setup_keys(void) { log_info("Generating seed..."); l = loop_read(fd, seed, seed_size, true); if (l < 0 || (size_t) l != seed_size) { - log_error("Failed to read random seed: %s", strerror(EIO)); + log_error_errno(EIO, "Failed to read random seed: %m"); r = -EIO; goto finish; } @@ -1428,14 +1428,14 @@ static int setup_keys(void) { l = loop_write(fd, &h, sizeof(h), false); if (l < 0 || (size_t) l != sizeof(h)) { - log_error("Failed to write header: %s", strerror(EIO)); + log_error_errno(EIO, "Failed to write header: %m"); r = -EIO; goto finish; } l = loop_write(fd, state, state_size, false); if (l < 0 || (size_t) l != state_size) { - log_error("Failed to write state: %s", strerror(EIO)); + log_error_errno(EIO, "Failed to write state: %m"); r = -EIO; goto finish; } diff --git a/src/libsystemd/sd-resolve/test-resolve.c b/src/libsystemd/sd-resolve/test-resolve.c index b7f8640231..a9dc9313a6 100644 --- a/src/libsystemd/sd-resolve/test-resolve.c +++ b/src/libsystemd/sd-resolve/test-resolve.c @@ -146,18 +146,18 @@ int main(int argc, char *argv[]) { /* Make a name -> address query */ r = sd_resolve_getaddrinfo(resolve, &q1, argc >= 2 ? argv[1] : "www.heise.de", NULL, &hints, getaddrinfo_handler, NULL); if (r < 0) - log_error("sd_resolve_getaddrinfo(): %s", strerror(-r)); + log_error_errno(r, "sd_resolve_getaddrinfo(): %m"); /* Make an address -> name query */ sa.sin_addr.s_addr = inet_addr(argc >= 3 ? argv[2] : "193.99.144.71"); r = sd_resolve_getnameinfo(resolve, &q2, (struct sockaddr*) &sa, sizeof(sa), 0, SD_RESOLVE_GET_BOTH, getnameinfo_handler, NULL); if (r < 0) - log_error("sd_resolve_getnameinfo(): %s", strerror(-r)); + log_error_errno(r, "sd_resolve_getnameinfo(): %m"); /* Make a res_query() call */ r = sd_resolve_res_query(resolve, &q3, "_xmpp-client._tcp.gmail.com", C_IN, T_SRV, res_handler, NULL); if (r < 0) - log_error("sd_resolve_res_query(): %s", strerror(-r)); + log_error_errno(r, "sd_resolve_res_query(): %m"); /* Wait until the three queries are completed */ while (sd_resolve_query_is_done(q1) == 0 || @@ -166,7 +166,7 @@ int main(int argc, char *argv[]) { r = sd_resolve_wait(resolve, (uint64_t) -1); if (r < 0) { - log_error("sd_resolve_wait(): %s", strerror(-r)); + log_error_errno(r, "sd_resolve_wait(): %m"); assert_not_reached("sd_resolve_wait() failed"); } } diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c index 6ef68fce09..0bb34f7826 100644 --- a/src/shared/socket-util.c +++ b/src/shared/socket-util.c @@ -641,7 +641,7 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret) return r; } - log_debug("getnameinfo(%s) failed: %s", ret, strerror(saved_errno)); + log_debug_errno(saved_errno, "getnameinfo(%s) failed: %m", ret); } else { ret = strdup(host); if (!ret) diff --git a/src/socket-proxy/socket-proxyd.c b/src/socket-proxy/socket-proxyd.c index d2d7d35015..eba285bba6 100644 --- a/src/socket-proxy/socket-proxyd.c +++ b/src/socket-proxy/socket-proxyd.c @@ -326,7 +326,7 @@ static int connect_cb(sd_event_source *s, int fd, uint32_t revents, void *userda } if (error != 0) { - log_error("Failed to connect to remote host: %s", strerror(error)); + log_error_errno(error, "Failed to connect to remote host: %m"); goto fail; } diff --git a/src/udev/udev-rules.c b/src/udev/udev-rules.c index 37508fa0a8..55587fd5a8 100644 --- a/src/udev/udev-rules.c +++ b/src/udev/udev-rules.c @@ -476,7 +476,7 @@ static uid_t add_uid(struct udev_rules *rules, const char *owner) { if (r == -ENOENT || r == -ESRCH) log_error("specified user '%s' unknown", owner); else - log_error("error resolving user '%s': %s", owner, strerror(-r)); + log_error_errno(r, "error resolving user '%s': %m", owner); } /* grow buffer if needed */ @@ -523,7 +523,7 @@ static gid_t add_gid(struct udev_rules *rules, const char *group) { if (r == -ENOENT || r == -ESRCH) log_error("specified group '%s' unknown", group); else - log_error("error resolving group '%s': %s", group, strerror(-r)); + log_error_errno(r, "error resolving group '%s': %m", group); } /* grow buffer if needed */ @@ -2279,7 +2279,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, if (r == -ENOENT || r == -ESRCH) log_error("specified user '%s' unknown", owner); else - log_error("error resolving user '%s': %s", owner, strerror(-r)); + log_error_errno(r, "error resolving user '%s': %m", owner); event->uid = 0; } @@ -2305,7 +2305,7 @@ int udev_rules_apply_to_event(struct udev_rules *rules, if (r == -ENOENT || r == -ESRCH) log_error("specified group '%s' unknown", group); else - log_error("error resolving group '%s': %s", group, strerror(-r)); + log_error_errno(r, "error resolving group '%s': %m", group); event->gid = 0; } -- cgit v1.2.3-54-g00ecf