summaryrefslogtreecommitdiffstats
path: root/src/event-loop.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2019-04-26 22:40:18 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2019-05-02 22:14:53 +0200
commit294ed97e646a41b7749cd67e240138fcab5bdc5a (patch)
treebb0807cabca089fb2ba0db554fa293a1d67494dd /src/event-loop.c
parenttests: Verify that wayland_scanner can catch bad identifiers (diff)
downloadwayland-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/event-loop.c')
-rw-r--r--src/event-loop.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/event-loop.c b/src/event-loop.c
index eb2dce6..54c8474 100644
--- a/src/event-loop.c
+++ b/src/event-loop.c
@@ -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->base.data);
}
@@ -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,
signal_source->base.data);