From 0a1beeb64207eaa88ab9236787b1cbc2f704ae14 Mon Sep 17 00:00:00 2001 From: Michal Schmidt Date: Fri, 28 Nov 2014 11:58:34 +0100 Subject: 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(). --- src/resolve/resolved.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) (limited to 'src/resolve/resolved.c') diff --git a/src/resolve/resolved.c b/src/resolve/resolved.c index 6dd4cade05..9150a5e33b 100644 --- a/src/resolve/resolved.c +++ b/src/resolve/resolved.c @@ -49,20 +49,20 @@ int main(int argc, char *argv[]) { r = mac_selinux_init(NULL); if (r < 0) { - log_error("SELinux setup failed: %s", strerror(-r)); + log_error_errno(-r, "SELinux setup failed: %m"); goto finish; } r = get_user_creds(&user, &uid, &gid, NULL, NULL); if (r < 0) { - log_error("Cannot resolve user name %s: %s", user, strerror(-r)); + log_error_errno(-r, "Cannot resolve user name %s: %m", user); goto finish; } /* Always create the directory where resolv.conf will live */ r = mkdir_safe_label("/run/systemd/resolve", 0755, uid, gid); if (r < 0) { - log_error("Could not create runtime directory: %s", strerror(-r)); + log_error_errno(-r, "Could not create runtime directory: %m"); goto finish; } @@ -74,17 +74,17 @@ int main(int argc, char *argv[]) { r = manager_new(&m); if (r < 0) { - log_error("Could not create manager: %s", strerror(-r)); + log_error_errno(-r, "Could not create manager: %m"); goto finish; } r = manager_parse_config_file(m); if (r < 0) - log_warning("Failed to parse configuration file: %s", strerror(-r)); + log_warning_errno(-r, "Failed to parse configuration file: %m"); r = manager_start(m); if (r < 0) { - log_error("Failed to start manager: %s", strerror(-r)); + log_error_errno(-r, "Failed to start manager: %m"); goto finish; } @@ -92,7 +92,7 @@ int main(int argc, char *argv[]) { * symlink */ r = manager_write_resolv_conf(m); if (r < 0) - log_warning("Could not create resolv.conf: %s", strerror(-r)); + log_warning_errno(-r, "Could not create resolv.conf: %m"); sd_notify(false, "READY=1\n" @@ -100,7 +100,7 @@ int main(int argc, char *argv[]) { r = sd_event_loop(m->event); if (r < 0) { - log_error("Event loop failed: %s", strerror(-r)); + log_error_errno(-r, "Event loop failed: %m"); goto finish; } -- cgit v1.2.3-54-g00ecf