qemu with hax to log dma reads & writes jcs.org/2018/11/12/vfio

Do not use %m in common code to print error messages

The %m format specifier is an extension from glibc - and when compiling
QEMU for NetBSD, the compiler correctly complains, e.g.:

/home/qemu/qemu-test.ELjfrQ/src/util/main-loop.c: In function 'sigfd_handler':
/home/qemu/qemu-test.ELjfrQ/src/util/main-loop.c:64:13: warning: %m is only
allowed in syslog(3) like functions [-Wformat=]
printf("read from sigfd returned %zd: %m\n", len);
^
Let's use g_strerror() here instead, which is an easy-to-use wrapper
around the thread-safe strerror_r() function.

While we're at it, also convert the "printf()" in main-loop.c into
the preferred "error_report()".

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-Id: <20191018130716.25438-1-thuth@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

authored by

Thomas Huth and committed by
Paolo Bonzini
372a87a1 30d6ff66

+6 -5
+2 -2
hw/misc/tmp421.c
··· 120 120 int tempid; 121 121 122 122 if (sscanf(name, "temperature%d", &tempid) != 1) { 123 - error_setg(errp, "error reading %s: %m", name); 123 + error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); 124 124 return; 125 125 } 126 126 ··· 160 160 } 161 161 162 162 if (sscanf(name, "temperature%d", &tempid) != 1) { 163 - error_setg(errp, "error reading %s: %m", name); 163 + error_setg(errp, "error reading %s: %s", name, g_strerror(errno)); 164 164 return; 165 165 } 166 166
+2 -1
util/main-loop.c
··· 61 61 } 62 62 63 63 if (len != sizeof(info)) { 64 - printf("read from sigfd returned %zd: %m\n", len); 64 + error_report("read from sigfd returned %zd: %s", len, 65 + g_strerror(errno)); 65 66 return; 66 67 } 67 68
+2 -2
util/systemd.c
··· 60 60 * and we should exit. 61 61 */ 62 62 error_report("Socket activation failed: " 63 - "invalid file descriptor fd = %d: %m", 64 - fd); 63 + "invalid file descriptor fd = %d: %s", 64 + fd, g_strerror(errno)); 65 65 exit(EXIT_FAILURE); 66 66 } 67 67 }