tree-wide: introduce strerror_safe()
This commit is contained in:
@@ -577,7 +577,7 @@ const char *bus_error_message(const sd_bus_error *e, int error) {
|
||||
if (error < 0)
|
||||
error = -error;
|
||||
|
||||
return strerror(error);
|
||||
return strerror_safe(error);
|
||||
}
|
||||
|
||||
static bool map_ok(const sd_bus_error_map *map) {
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
#include "bus-internal.h"
|
||||
#include "bus-match.h"
|
||||
#include "bus-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "log.h"
|
||||
@@ -308,7 +309,7 @@ static void* client1(void *p) {
|
||||
|
||||
errno = 0;
|
||||
if (read(pp[0], &x, 1) <= 0) {
|
||||
log_error("Failed to read from pipe: %s", errno ? strerror(errno) : "early read");
|
||||
log_error("Failed to read from pipe: %s", errno != 0 ? strerror_safe(errno) : "early read");
|
||||
goto finish;
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include "bus-error.h"
|
||||
#include "bus-util.h"
|
||||
#include "errno-list.h"
|
||||
#include "errno-util.h"
|
||||
|
||||
static void test_error(void) {
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL, second = SD_BUS_ERROR_NULL;
|
||||
@@ -88,7 +89,7 @@ static void test_error(void) {
|
||||
assert_se(!sd_bus_error_is_set(&error));
|
||||
assert_se(sd_bus_error_set_errno(&error, EBUSY) == -EBUSY);
|
||||
assert_se(streq(error.name, "System.Error.EBUSY"));
|
||||
assert_se(streq(error.message, strerror(EBUSY)));
|
||||
assert_se(streq(error.message, strerror_safe(EBUSY)));
|
||||
assert_se(sd_bus_error_has_name(&error, "System.Error.EBUSY"));
|
||||
assert_se(sd_bus_error_get_errno(&error) == EBUSY);
|
||||
assert_se(sd_bus_error_is_set(&error));
|
||||
|
||||
Reference in New Issue
Block a user