aboutsummaryrefslogtreecommitdiffstats
path: root/src/scanner.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/scanner.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/scanner.c')
-rw-r--r--src/scanner.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/scanner.c b/src/scanner.c
index 86d90c0..8cffea5 100644
--- a/src/scanner.c
+++ b/src/scanner.c
@@ -2015,7 +2015,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));
fclose(input);
exit(EXIT_FAILURE);
}