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/login/logind-user.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/login/logind-user.c') diff --git a/src/login/logind-user.c b/src/login/logind-user.c index 1205b48ab..7a39140d8 100644 --- a/src/login/logind-user.c +++ b/src/login/logind-user.c @@ -252,7 +252,7 @@ int user_save(User *u) { finish: if (r < 0) - log_error("Failed to save user data %s: %s", u->state_file, strerror(-r)); + log_error_errno(-r, "Failed to save user data %s: %m", u->state_file); return r; } @@ -278,7 +278,7 @@ int user_load(User *u) { if (r == -ENOENT) return 0; - log_error("Failed to read %s: %s", u->state_file, strerror(-r)); + log_error_errno(-r, "Failed to read %s: %m", u->state_file); return r; } @@ -311,7 +311,7 @@ static int user_mkdir_runtime_path(User *u) { r = mkdir_safe_label("/run/user", 0755, 0, 0); if (r < 0) { - log_error("Failed to create /run/user: %s", strerror(-r)); + log_error_errno(-r, "Failed to create /run/user: %m"); return r; } @@ -338,7 +338,7 @@ static int user_mkdir_runtime_path(User *u) { r = mount("tmpfs", p, "tmpfs", MS_NODEV|MS_NOSUID, t); if (r < 0) { - log_error("Failed to mount per-user tmpfs directory %s: %s", p, strerror(-r)); + log_error_errno(-r, "Failed to mount per-user tmpfs directory %s: %m", p); goto fail; } } @@ -510,14 +510,14 @@ static int user_remove_runtime_path(User *u) { r = rm_rf(u->runtime_path, false, false, false); if (r < 0) - log_error("Failed to remove runtime directory %s: %s", u->runtime_path, strerror(-r)); + log_error_errno(-r, "Failed to remove runtime directory %s: %m", u->runtime_path); if (umount2(u->runtime_path, MNT_DETACH) < 0) log_error("Failed to unmount user runtime directory %s: %m", u->runtime_path); r = rm_rf(u->runtime_path, false, true, false); if (r < 0) - log_error("Failed to remove runtime directory %s: %s", u->runtime_path, strerror(-r)); + log_error_errno(-r, "Failed to remove runtime directory %s: %m", u->runtime_path); free(u->runtime_path); u->runtime_path = NULL; -- cgit v1.2.3