Fix bad error reporting 3.99.2 dab/3.99.2 dab_3.99.2
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 28 Jun 2017 16:05:18 +0000 (18:05 +0200)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 28 Jun 2017 16:47:55 +0000 (18:47 +0200)
The use of %m was buggy due to the implementation
of 'vverbose': it always returned ENOTTY

   Inappropriate ioctl for device

Change-Id: I0b7dd4c2f4ce5a45611042a8b9ba3e6db0e60803
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/verbose.c

index 6d0db01..3a0559e 100644 (file)
@@ -52,6 +52,7 @@ void verbose_set_name(const char *name, int authority)
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <errno.h>
 
 static char *appname;
 
@@ -70,7 +71,9 @@ static const char *prefixes[] = {
 
 void vverbose(int level, const char *file, int line, const char *fmt, va_list args)
 {
+       int saverr = errno;
        int tty = isatty(fileno(stderr));
+       errno = saverr;
 
        fprintf(stderr, "%s: ", prefixes[LEVEL(level)] + (tty ? 4 : 0));
        vfprintf(stderr, fmt, args);