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>
This commit is contained in:
Antonio Borneo 2019-04-26 22:40:18 +02:00
parent 6db761d162
commit 294ed97e64
5 changed files with 11 additions and 8 deletions

View file

@ -338,7 +338,8 @@ int main(int argc, char *argv[])
if (waitid(P_PID, pid, &info, WEXITED)) {
stderr_set_color(RED);
fprintf(stderr, "waitid failed: %m\n");
fprintf(stderr, "waitid failed: %s\n",
strerror(errno));
stderr_reset_color();
abort();