Commit 9be54af8 authored by Antonio Borneo's avatar Antonio Borneo
Browse files

log: remove "%m" from format strings by using strerror(errno)

The printf() format specifier "%m" is a glibc extension to print
the string returned by strerror(errno). While supported by other
libraries (e.g. uClibc and musl), it is not widely portable.

In Wayland code the format string is often passed to a logging
function that calls other syscalls before the conversion of "%m"
takes place. If one of such syscall modifies the value in errno,
the conversion of "%m" will incorrectly report the error string
corresponding to the new value of errno.

Remove all the occurrences of the specifier "%m" in Wayland code
by using directly the string returned by strerror(errno).
Signed-off-by: Antonio Borneo's avatarAntonio Borneo <>
parent ea11878d
Pipeline #33563 failed with stage
in 1 minute and 11 seconds
......@@ -231,7 +231,7 @@ wl_event_source_timer_dispatch(struct wl_event_source *source,
len = read(source->fd, &expires, sizeof expires);
if (!(len == -1 && errno == EAGAIN) && len != sizeof expires)
/* Is there anything we can do here? Will this ever happen? */
wl_log("timerfd read error: %m\n");
wl_log("timerfd read error: %s\n", strerror(errno));
return timer_source->func(timer_source->;
......@@ -325,7 +325,7 @@ wl_event_source_signal_dispatch(struct wl_event_source *source,
len = read(source->fd, &signal_info, sizeof signal_info);
if (!(len == -1 && errno == EAGAIN) && len != sizeof signal_info)
/* Is there anything we can do here? Will this ever happen? */
wl_log("signalfd read error: %m\n");
wl_log("signalfd read error: %s\n", strerror(errno));
return signal_source->func(signal_source->signal_number,
......@@ -1956,7 +1956,7 @@ int main(int argc, char *argv[])
buf = XML_GetBuffer(ctx.parser, XML_BUFFER_SIZE);
len = fread(buf, 1, XML_BUFFER_SIZE, input);
if (len < 0) {
fprintf(stderr, "fread: %m\n");
fprintf(stderr, "fread: %s\n", strerror(errno));
......@@ -1362,7 +1362,7 @@ socket_data(int fd, uint32_t mask, void *data)
client_fd = wl_os_accept_cloexec(fd, (struct sockaddr *) &name,
if (client_fd < 0)
wl_log("failed to accept: %m\n");
wl_log("failed to accept: %s\n", strerror(errno));
if (!wl_client_create(display, client_fd))
......@@ -1467,12 +1467,12 @@ _wl_display_add_socket(struct wl_display *display, struct wl_socket *s)
size = offsetof (struct sockaddr_un, sun_path) + strlen(s->addr.sun_path);
if (bind(s->fd, (struct sockaddr *) &s->addr, size) < 0) {
wl_log("bind() failed with error: %m\n");
wl_log("bind() failed with error: %s\n", strerror(errno));
return -1;
if (listen(s->fd, 128) < 0) {
wl_log("listen() failed with error: %m\n");
wl_log("listen() failed with error: %s\n", strerror(errno));
return -1;
......@@ -281,7 +281,8 @@ shm_create_pool(struct wl_client *client, struct wl_resource *resource,
if (pool->data == MAP_FAILED) {
"failed mmap fd %d: %m", fd);
"failed mmap fd %d: %s", fd,
goto err_free;
......@@ -338,7 +338,8 @@ int main(int argc, char *argv[])
if (waitid(P_PID, pid, &info, WEXITED)) {
fprintf(stderr, "waitid failed: %m\n");
fprintf(stderr, "waitid failed: %s\n",
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment