summaryrefslogtreecommitdiff
path: root/log.c
diff options
context:
space:
mode:
authorDaniel Elstner <daniel.kitta@gmail.com>2015-09-13 23:05:42 +0200
committerDaniel Elstner <daniel.kitta@gmail.com>2015-09-13 23:09:45 +0200
commitef3a66299ade1bc41090d0b6d24c21b6bcfad571 (patch)
tree686e0c1b51103df5cdba5c7d5733e636172e8478 /log.c
parentfdfc532ecd49fc3353627ef4a093366e73d6b91a (diff)
downloadlibsigrokdecode-ef3a66299ade1bc41090d0b6d24c21b6bcfad571.tar.gz
libsigrokdecode-ef3a66299ade1bc41090d0b6d24c21b6bcfad571.zip
log: Use GLib printf for consistency
Just as in libsigrok, use g_vfprintf() in the log callback to make sure we are linking to a standard-conforming printf implementation.
Diffstat (limited to 'log.c')
-rw-r--r--log.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/log.c b/log.c
index 73c1fdd..0d8bbfa 100644
--- a/log.c
+++ b/log.c
@@ -23,6 +23,7 @@
#include "libsigrokdecode.h"
#include <stdarg.h>
#include <stdio.h>
+#include <glib/gprintf.h>
/**
* @file
@@ -153,8 +154,6 @@ SRD_API int srd_log_callback_set_default(void)
static int srd_logv(void *cb_data, int loglevel, const char *format,
va_list args)
{
- int ret;
-
/* This specific log callback doesn't need the void pointer data. */
(void)cb_data;
@@ -162,11 +161,12 @@ static int srd_logv(void *cb_data, int loglevel, const char *format,
if (loglevel > cur_loglevel)
return SRD_OK;
- fputs("srd: ", stderr);
- ret = vfprintf(stderr, format, args);
- fprintf(stderr, "\n");
+ if (fputs("srd: ", stderr) < 0
+ || g_vfprintf(stderr, format, args) < 0
+ || putc('\n', stderr) < 0)
+ return SRD_ERR;
- return ret;
+ return SRD_OK;
}
/** @private */