diff options
| author | Antonio Borneo <borneo.antonio@gmail.com> | 2019-04-26 22:40:18 +0200 |
|---|---|---|
| committer | Antonio Borneo <borneo.antonio@gmail.com> | 2019-05-02 22:14:53 +0200 |
| commit | 294ed97e646a41b7749cd67e240138fcab5bdc5a (patch) | |
| tree | bb0807cabca089fb2ba0db554fa293a1d67494dd /src/wayland-server.c | |
| parent | tests: Verify that wayland_scanner can catch bad identifiers (diff) | |
| download | wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.tar wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.tar.gz wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.tar.bz2 wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.tar.lz wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.tar.xz wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.tar.zst wayland-294ed97e646a41b7749cd67e240138fcab5bdc5a.zip | |
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 <borneo.antonio@gmail.com>
Diffstat (limited to 'src/wayland-server.c')
| -rw-r--r-- | src/wayland-server.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/wayland-server.c b/src/wayland-server.c index 19f6a76..884a5a3 100644 --- a/src/wayland-server.c +++ b/src/wayland-server.c @@ -1362,7 +1362,7 @@ socket_data(int fd, uint32_t mask, void *data) client_fd = wl_os_accept_cloexec(fd, (struct sockaddr *) &name, &length); if (client_fd < 0) - wl_log("failed to accept: %m\n"); + wl_log("failed to accept: %s\n", strerror(errno)); else if (!wl_client_create(display, client_fd)) close(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; } |
