From 6b7834fe5de3de690e6efb9467c61691c4b2f30f Mon Sep 17 00:00:00 2001 From: =?utf8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Thu, 6 Oct 2022 13:07:49 +0200 Subject: [PATCH] basic/log: include the log syntax callback in the errno protection block In general, log_syntax_internal() must keep errno unchanged. But the call to log_syntax_callback() was added outside of the block protected by PROTECT_ERRNO. --- src/basic/log.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/basic/log.c b/src/basic/log.c index c5e16d669b..2f5353c739 100644 --- a/src/basic/log.c +++ b/src/basic/log.c @@ -1341,18 +1341,19 @@ int log_syntax_internal( const char *func, const char *format, ...) { + PROTECT_ERRNO; + if (log_syntax_callback) log_syntax_callback(unit, level, log_syntax_callback_userdata); - PROTECT_ERRNO; - char buffer[LINE_MAX]; - va_list ap; - const char *unit_fmt = NULL; - if (_likely_(LOG_PRI(level) > log_max_level) || log_target == LOG_TARGET_NULL) return -ERRNO_VALUE(error); + char buffer[LINE_MAX]; + va_list ap; + const char *unit_fmt = NULL; + errno = ERRNO_VALUE(error); va_start(ap, format); -- 2.25.1