From: Gerhard Sittig Date: Sun, 19 Mar 2023 14:57:24 +0000 (+0100) Subject: log: accept when applications void the log callback X-Git-Url: http://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=d4915da66285a2ad324432b7fc28add3bbc70191 log: accept when applications void the log callback Common support code in the libsigrok library passes all output through an application specified log callback, while a default callback exists which writes to stdout and stderr. Accept when no callback at all is registered. Don't output text in that case, succeed silently. --- diff --git a/src/log.c b/src/log.c index 669d442b..1b01afee 100644 --- a/src/log.c +++ b/src/log.c @@ -260,6 +260,10 @@ SR_PRIV int sr_log(int loglevel, const char *format, ...) if (loglevel > cur_loglevel) return SR_OK; + /* Silently succeed when no logging callback is registered. */ + if (!sr_log_cb) + return SR_OK; + va_start(args, format); ret = sr_log_cb(sr_log_cb_data, loglevel, format, args); va_end(args);