summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorMichal Schmidt <mschmidt@redhat.com>2014-11-28 11:58:34 +0100
committerMichal Schmidt <mschmidt@redhat.com>2014-11-28 12:04:41 +0100
commit0a1beeb64207eaa88ab9236787b1cbc2f704ae14 (patch)
tree50117277be2e2078d0373b944a30b4f09bb94443 /src/shared
parentb4d23205f238e06aaa31264628e20669e714acad (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/shared')
-rw-r--r--src/shared/capability.c2
-rw-r--r--src/shared/generator.c4
-rw-r--r--src/shared/install.c2
-rw-r--r--src/shared/logs-show.c28
-rw-r--r--src/shared/pager.c2
-rw-r--r--src/shared/sleep-config.c2
-rw-r--r--src/shared/socket-label.c4
-rw-r--r--src/shared/socket-util.c2
-rw-r--r--src/shared/spawn-ask-password-agent.c2
-rw-r--r--src/shared/spawn-polkit-agent.c2
-rw-r--r--src/shared/util.c8
11 files changed, 29 insertions, 29 deletions
diff --git a/src/shared/capability.c b/src/shared/capability.c
index 0226542c6c..f7513379a2 100644
--- a/src/shared/capability.c
+++ b/src/shared/capability.c
@@ -255,7 +255,7 @@ int drop_privileges(uid_t uid, gid_t gid, uint64_t keep_capabilities) {
r = capability_bounding_set_drop(~keep_capabilities, true);
if (r < 0) {
- log_error("Failed to drop capabilities: %s", strerror(-r));
+ log_error_errno(-r, "Failed to drop capabilities: %m");
return r;
}
diff --git a/src/shared/generator.c b/src/shared/generator.c
index 414470be1c..892fa39ec1 100644
--- a/src/shared/generator.c
+++ b/src/shared/generator.c
@@ -52,10 +52,10 @@ int generator_write_fsck_deps(
r = fsck_exists(fstype);
if (r == -ENOENT) {
/* treat missing check as essentially OK */
- log_debug("Checking was requested for %s, but fsck.%s does not exist: %s", what, fstype, strerror(-r));
+ log_debug_errno(-r, "Checking was requested for %s, but fsck.%s does not exist: %m", what, fstype);
return 0;
} else if (r < 0) {
- log_warning("Checking was requested for %s, but fsck.%s cannot be used: %s", what, fstype, strerror(-r));
+ log_warning_errno(-r, "Checking was requested for %s, but fsck.%s cannot be used: %m", what, fstype);
return r;
}
}
diff --git a/src/shared/install.c b/src/shared/install.c
index 8a7f7e2094..1e90bdf725 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -1554,7 +1554,7 @@ int unit_file_add_dependency(
state = unit_file_get_state(scope, root_dir, *i);
if (state < 0) {
- log_error("Failed to get unit file state for %s: %s", *i, strerror(-state));
+ log_error_errno(-state, "Failed to get unit file state for %s: %m", *i);
return state;
}
diff --git a/src/shared/logs-show.c b/src/shared/logs-show.c
index e33824be4a..32eba6ccfe 100644
--- a/src/shared/logs-show.c
+++ b/src/shared/logs-show.c
@@ -296,7 +296,7 @@ static int output_short(
r = sd_journal_get_monotonic_usec(j, &t, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
@@ -323,7 +323,7 @@ static int output_short(
r = sd_journal_get_realtime_usec(j, &x);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
@@ -422,7 +422,7 @@ static int output_verbose(
r = parse_field(data, length, "_SOURCE_REALTIME_TIMESTAMP=", &value, &size);
if (r < 0)
- log_debug("_SOURCE_REALTIME_TIMESTAMP invalid: %s", strerror(-r));
+ log_debug_errno(-r, "_SOURCE_REALTIME_TIMESTAMP invalid: %m");
else {
r = safe_atou64(value, &realtime);
if (r < 0)
@@ -442,7 +442,7 @@ static int output_verbose(
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -517,19 +517,19 @@ static int output_export(
r = sd_journal_get_realtime_usec(j, &realtime);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
r = sd_journal_get_monotonic_usec(j, &monotonic, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -657,19 +657,19 @@ static int output_json(
r = sd_journal_get_realtime_usec(j, &realtime);
if (r < 0) {
- log_error("Failed to get realtime timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get realtime timestamp: %m");
return r;
}
r = sd_journal_get_monotonic_usec(j, &monotonic, &boot_id);
if (r < 0) {
- log_error("Failed to get monotonic timestamp: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get monotonic timestamp: %m");
return r;
}
r = sd_journal_get_cursor(j, &cursor);
if (r < 0) {
- log_error("Failed to get cursor: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get cursor: %m");
return r;
}
@@ -877,7 +877,7 @@ static int output_cat(
if (r == -ENOENT)
return 0;
- log_error("Failed to get data: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get data: %m");
return r;
}
@@ -1226,13 +1226,13 @@ int add_match_this_boot(sd_journal *j, const char *machine) {
if (machine) {
r = get_boot_id_for_machine(machine, &boot_id);
if (r < 0) {
- log_error("Failed to get boot id of container %s: %s", machine, strerror(-r));
+ log_error_errno(-r, "Failed to get boot id of container %s: %m", machine);
return r;
}
} else {
r = sd_id128_get_boot(&boot_id);
if (r < 0) {
- log_error("Failed to get boot id: %s", strerror(-r));
+ log_error_errno(-r, "Failed to get boot id: %m");
return r;
}
}
@@ -1240,7 +1240,7 @@ int add_match_this_boot(sd_journal *j, const char *machine) {
sd_id128_to_string(boot_id, match + 9);
r = sd_journal_add_match(j, match, strlen(match));
if (r < 0) {
- log_error("Failed to add match: %s", strerror(-r));
+ log_error_errno(-r, "Failed to add match: %m");
return r;
}
diff --git a/src/shared/pager.c b/src/shared/pager.c
index 001927ce93..572c26b149 100644
--- a/src/shared/pager.c
+++ b/src/shared/pager.c
@@ -186,7 +186,7 @@ int show_man_page(const char *desc, bool null_stdio) {
if (null_stdio) {
r = make_null_stdio();
if (r < 0) {
- log_error("Failed to kill stdio: %s", strerror(-r));
+ log_error_errno(-r, "Failed to kill stdio: %m");
_exit(EXIT_FAILURE);
}
}
diff --git a/src/shared/sleep-config.c b/src/shared/sleep-config.c
index d8de644a92..7a4e5cda2b 100644
--- a/src/shared/sleep-config.c
+++ b/src/shared/sleep-config.c
@@ -227,7 +227,7 @@ static bool enough_memory_for_hibernation(void) {
r = get_status_field("/proc/meminfo", "\nActive(anon):", &active);
if (r < 0) {
- log_error("Failed to retrieve Active(anon) from /proc/meminfo: %s", strerror(-r));
+ log_error_errno(-r, "Failed to retrieve Active(anon) from /proc/meminfo: %m");
return false;
}
diff --git a/src/shared/socket-label.c b/src/shared/socket-label.c
index 47d9488d56..b0fca9b45c 100644
--- a/src/shared/socket-label.c
+++ b/src/shared/socket-label.c
@@ -162,12 +162,12 @@ int make_socket_fd(int log_level, const char* address, int flags) {
r = socket_address_print(&a, &p);
if (r < 0) {
- log_error("socket_address_print(): %s", strerror(-r));
+ log_error_errno(-r, "socket_address_print(): %m");
return r;
}
if (fd < 0)
- log_error("Failed to listen on %s: %s", p, strerror(-fd));
+ log_error_errno(-fd, "Failed to listen on %s: %m", p);
else
log_full(log_level, "Listening on %s", p);
}
diff --git a/src/shared/socket-util.c b/src/shared/socket-util.c
index 911dbfe55a..4457e9d1a2 100644
--- a/src/shared/socket-util.c
+++ b/src/shared/socket-util.c
@@ -637,7 +637,7 @@ int socknameinfo_pretty(union sockaddr_union *sa, socklen_t salen, char **_ret)
r = sockaddr_pretty(&sa->sa, salen, true, &ret);
if (r < 0) {
- log_error("sockadd_pretty() failed: %s", strerror(-r));
+ log_error_errno(-r, "sockadd_pretty() failed: %m");
return r;
}
diff --git a/src/shared/spawn-ask-password-agent.c b/src/shared/spawn-ask-password-agent.c
index ff121f86a2..6e31d8d138 100644
--- a/src/shared/spawn-ask-password-agent.c
+++ b/src/shared/spawn-ask-password-agent.c
@@ -49,7 +49,7 @@ int ask_password_agent_open(void) {
SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH,
SYSTEMD_TTY_ASK_PASSWORD_AGENT_BINARY_PATH, "--watch", NULL);
if (r < 0)
- log_error("Failed to fork TTY ask password agent: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fork TTY ask password agent: %m");
return r;
}
diff --git a/src/shared/spawn-polkit-agent.c b/src/shared/spawn-polkit-agent.c
index 7a90ef8013..93652f052d 100644
--- a/src/shared/spawn-polkit-agent.c
+++ b/src/shared/spawn-polkit-agent.c
@@ -64,7 +64,7 @@ int polkit_agent_open(void) {
safe_close(pipe_fd[1]);
if (r < 0)
- log_error("Failed to fork TTY ask password agent: %s", strerror(-r));
+ log_error_errno(-r, "Failed to fork TTY ask password agent: %m");
else
/* Wait until the agent closes the fd */
fd_wait_for_event(pipe_fd[0], POLLHUP, USEC_INFINITY);
diff --git a/src/shared/util.c b/src/shared/util.c
index d3eec5f878..11be757c2f 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -2214,7 +2214,7 @@ int acquire_terminal(
r = reset_terminal_fd(fd, true);
if (r < 0)
- log_warning("Failed to reset terminal: %s", strerror(-r));
+ log_warning_errno(-r, "Failed to reset terminal: %m");
return fd;
@@ -3796,7 +3796,7 @@ int wait_for_terminate_and_warn(const char *name, pid_t pid) {
r = wait_for_terminate(pid, &status);
if (r < 0) {
- log_warning("Failed to wait for %s: %s", name, strerror(-r));
+ log_warning_errno(-r, "Failed to wait for %s: %m", name);
return r;
}
@@ -5507,13 +5507,13 @@ int make_console_stdio(void) {
fd = acquire_terminal("/dev/console", false, true, true, USEC_INFINITY);
if (fd < 0) {
- log_error("Failed to acquire terminal: %s", strerror(-fd));
+ log_error_errno(-fd, "Failed to acquire terminal: %m");
return fd;
}
r = make_stdio(fd);
if (r < 0) {
- log_error("Failed to duplicate terminal fd: %s", strerror(-r));
+ log_error_errno(-r, "Failed to duplicate terminal fd: %m");
return r;
}