summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosé Bollo <jose.bollo@iot.bzh>2017-06-28 18:05:18 +0200
committerJosé Bollo <jose.bollo@iot.bzh>2017-06-28 18:05:18 +0200
commit5cea66506dff09e8bdebbd623115ea103e87aba6 (patch)
treed8bbfdfa993c85f1203936d5edff8589c1989dfb
parentc5f9125c75bd2aa7db9dfad6e2dc178fff2d2f73 (diff)
Fix bad error reporting
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>
-rw-r--r--src/verbose.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/verbose.c b/src/verbose.c
index 6d0db01..3a0559e 100644
--- a/src/verbose.c
+++ b/src/verbose.c
@@ -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);