From ad66a854a0910ef4366acdcd61a3ba7d402808a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Valverde?= Date: Tue, 27 Sep 2022 22:05:55 +0100 Subject: [PATCH] wslog: Print to stderr with a null error handler For some programs (e.g: unit tests) we want to init the logging subsystem but having to pass an error output handler is overkill and annoying. In that case with a NULL handler printing to stderr by default is almost certainly the best thing to do. --- wsutil/wslog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/wsutil/wslog.c b/wsutil/wslog.c index a6482e6e7c..bbb9a8c189 100644 --- a/wsutil/wslog.c +++ b/wsutil/wslog.c @@ -323,11 +323,11 @@ static void print_err(void (*vcmdarg_err)(const char *, va_list ap), { va_list ap; - if (vcmdarg_err == NULL) - return; - va_start(ap, fmt); - vcmdarg_err(fmt, ap); + if (vcmdarg_err) + vcmdarg_err(fmt, ap); + else + vfprintf(stderr, fmt, ap); va_end(ap); if (exit_failure != LOG_ARGS_NOEXIT) exit(exit_failure);