tree-wide: introduce strerror_safe()

This commit is contained in:
Yu Watanabe
2019-07-05 02:43:56 +09:00
parent 7fa6223f67
commit 4bbccb02ea
20 changed files with 55 additions and 38 deletions
+1 -1
View File
@@ -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);
}
+1 -1
View File
@@ -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;
+2 -1
View File
@@ -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);
+1 -1
View File
@@ -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;
+1 -1
View File
@@ -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);