[Libguestfs] [nbdkit PATCH 1/3] main: Avoid fprintf(%m) for BSD builds

Eric Blake eblake at redhat.com
Thu Nov 29 17:21:28 UTC 2018


printf %m is a glibc extension; using it directly can cause
odd output on BSD. Most of our uses of %m are via nbdkit wrappers,
which will be fixed in a future patch; this was the only %m I
could find in a direct call to the printf family, so it doesn't
hurt to just open-code it.  This particular error is reached
early enough in the process that nbdkit_error() is not a viable
substitute.

Signed-off-by: Eric Blake <eblake at redhat.com>
---
 src/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/main.c b/src/main.c
index e80333a..fd6e30e 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1204,8 +1204,8 @@ get_socket_activation (void)
        * and we should exit.
        */
       fprintf (stderr, "%s: socket activation: "
-               "invalid file descriptor fd = %d: %m\n",
-               program_name, fd);
+               "invalid file descriptor fd = %d: %s\n",
+               program_name, fd, strerror(errno));
       exit (EXIT_FAILURE);
     }
   }
-- 
2.17.2




More information about the Libguestfs mailing list