summaryrefslogtreecommitdiff
path: root/src/core
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2019-07-03 23:56:17 +0900
committerYu Watanabe <watanabe.yu+github@gmail.com>2019-07-05 02:43:56 +0900
commit4bbccb02eaee35e20d3031e7ba4b3d08631ce934 (patch)
tree27fed6568b9faa5a2586c5929159b79a4002c294 /src/core
parent7fa6223f67662e8d5ee26092240b4e1d091a69f5 (diff)
downloadsystemd-4bbccb02eaee35e20d3031e7ba4b3d08631ce934.tar.gz
systemd-4bbccb02eaee35e20d3031e7ba4b3d08631ce934.tar.bz2
systemd-4bbccb02eaee35e20d3031e7ba4b3d08631ce934.zip
tree-wide: introduce strerror_safe()
Diffstat (limited to 'src/core')
-rw-r--r--src/core/execute.c2
-rw-r--r--src/core/path.c2
-rw-r--r--src/core/selinux-access.c3
-rw-r--r--src/core/socket.c2
-rw-r--r--src/core/unit.c2
5 files changed, 6 insertions, 5 deletions
diff --git a/src/core/execute.c b/src/core/execute.c
index abf241aa81..1cbb2a83de 100644
--- a/src/core/execute.c
+++ b/src/core/execute.c
@@ -4891,7 +4891,7 @@ static void exec_command_dump(ExecCommand *c, FILE *f, const char *prefix) {
cmd = exec_command_line(c->argv);
fprintf(f,
"%sCommand Line: %s\n",
- prefix, cmd ? cmd : strerror(ENOMEM));
+ prefix, cmd ? cmd : strerror_safe(ENOMEM));
exec_status_dump(&c->exec_status, f, prefix2);
}
diff --git a/src/core/path.c b/src/core/path.c
index 5a00150e9b..562cd352a3 100644
--- a/src/core/path.c
+++ b/src/core/path.c
@@ -89,7 +89,7 @@ int path_spec_watch(PathSpec *s, sd_event_io_handler_t handler) {
break;
}
- r = log_warning_errno(errno, "Failed to add watch on %s: %s", s->path, errno == ENOSPC ? "too many watches" : strerror(-r));
+ r = log_warning_errno(errno, "Failed to add watch on %s: %s", s->path, errno == ENOSPC ? "too many watches" : strerror_safe(r));
if (cut)
*cut = tmp;
goto fail;
diff --git a/src/core/selinux-access.c b/src/core/selinux-access.c
index c8b1a8588b..960ba6cc6d 100644
--- a/src/core/selinux-access.c
+++ b/src/core/selinux-access.c
@@ -17,6 +17,7 @@
#include "alloc-util.h"
#include "audit-fd.h"
#include "bus-util.h"
+#include "errno-util.h"
#include "format-util.h"
#include "log.h"
#include "path-util.h"
@@ -158,7 +159,7 @@ static int access_init(sd_bus_error *error) {
/* Return an access denied error, if we couldn't load
* the AVC but enforcing mode was on, or we couldn't
* determine whether it is one. */
- return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to open the SELinux AVC: %s", strerror(saved_errno));
+ return sd_bus_error_setf(error, SD_BUS_ERROR_ACCESS_DENIED, "Failed to open the SELinux AVC: %s", strerror_safe(saved_errno));
}
selinux_set_callback(SELINUX_CB_AUDIT, (union selinux_callback) audit_callback);
diff --git a/src/core/socket.c b/src/core/socket.c
index b6a4290c3f..cc3dc5973d 100644
--- a/src/core/socket.c
+++ b/src/core/socket.c
@@ -782,7 +782,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
r = socket_address_print(&p->address, &k);
if (r < 0)
- t = strerror(-r);
+ t = strerror_safe(r);
else
t = k;
diff --git a/src/core/unit.c b/src/core/unit.c
index 463db73ff1..210a4a1a6e 100644
--- a/src/core/unit.c
+++ b/src/core/unit.c
@@ -1326,7 +1326,7 @@ void unit_dump(Unit *u, FILE *f, const char *prefix) {
"%s\tMerged into: %s\n",
prefix, u->merged_into->id);
else if (u->load_state == UNIT_ERROR)
- fprintf(f, "%s\tLoad Error Code: %s\n", prefix, strerror(-u->load_error));
+ fprintf(f, "%s\tLoad Error Code: %s\n", prefix, strerror_safe(u->load_error));
for (n = sd_bus_track_first(u->bus_track); n; n = sd_bus_track_next(u->bus_track))
fprintf(f, "%s\tBus Ref: %s\n", prefix, n);