summary refs log tree commit diff stats
path: root/util/systemd.c
diff options
context:
space:
mode:
authorThomas Huth <thuth@redhat.com>2019-10-18 15:07:16 +0200
committerPaolo Bonzini <pbonzini@redhat.com>2019-10-22 09:38:42 +0200
commit372a87a1d9f611cedeff2f679fe8da219f0b938f (patch)
tree705d9190f1cf286f6cd39c5fcaf894174d0cd3dc /util/systemd.c
parent30d6ff662d0411fcb98a577e58582690fc2c513c (diff)
downloadfocaccia-qemu-372a87a1d9f611cedeff2f679fe8da219f0b938f.tar.gz
focaccia-qemu-372a87a1d9f611cedeff2f679fe8da219f0b938f.zip
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>
Diffstat (limited to 'util/systemd.c')
-rw-r--r--util/systemd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/util/systemd.c b/util/systemd.c
index d22e86c707..1dd0367d9a 100644
--- a/util/systemd.c
+++ b/util/systemd.c
@@ -60,8 +60,8 @@ unsigned int check_socket_activation(void)
              * and we should exit.
              */
             error_report("Socket activation failed: "
-                         "invalid file descriptor fd = %d: %m",
-                         fd);
+                         "invalid file descriptor fd = %d: %s",
+                         fd, g_strerror(errno));
             exit(EXIT_FAILURE);
         }
     }