From 87283261997fd65aeca5d7968ac8c622ac656967 Mon Sep 17 00:00:00 2001 From: Arnaud Giersch Date: Wed, 4 Oct 2017 23:15:15 +0200 Subject: [PATCH 1/1] Reduce cognitive complexity (sonar). --- src/xbt/log.c | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/src/xbt/log.c b/src/xbt/log.c index a3a3918741..5e8cdd1684 100644 --- a/src/xbt/log.c +++ b/src/xbt/log.c @@ -364,18 +364,16 @@ void _xbt_log_event_log(xbt_log_event_t ev, const char *fmt, ...) /* First, try with a static buffer */ int done = 0; - if (XBT_LOG_STATIC_BUFFER_SIZE) { - char buff[XBT_LOG_STATIC_BUFFER_SIZE]; - ev->buffer = buff; - ev->buffer_size = sizeof buff; - va_start(ev->ap, fmt); - done = cat->layout->do_layout(cat->layout, ev, fmt); - va_end(ev->ap); - if (done) - appender->do_append(appender, buff); - } + char buff[XBT_LOG_STATIC_BUFFER_SIZE]; + ev->buffer = buff; + ev->buffer_size = sizeof buff; + va_start(ev->ap, fmt); + done = cat->layout->do_layout(cat->layout, ev, fmt); + va_end(ev->ap); + if (done) { + appender->do_append(appender, buff); + } else { - if (!done) { /* The static buffer was too small, use a dynamically expanded one */ ev->buffer_size = XBT_LOG_DYNAMIC_BUFFER_SIZE; ev->buffer = xbt_malloc(ev->buffer_size); -- 2.20.1