From c65caf8dac4bbd6495e963f1667ef336e5326537 Mon Sep 17 00:00:00 2001 From: Cole Miller Date: Sun, 4 Aug 2024 23:18:50 -0400 Subject: [PATCH] Ignore format-nonliteral warning This fires on all our invocations of vsnprintf, but only with clang (gcc makes an exception for variadic functions presumably for just this reason). I think the value of this lint for us is not worth its price in \#pragma verbosity. Signed-off-by: Cole Miller --- configure.ac | 1 + src/logger.c | 3 --- test/lib/logger.c | 3 --- 3 files changed, 1 insertion(+), 6 deletions(-) diff --git a/configure.ac b/configure.ac index 6bc4afebc..c8cae742f 100644 --- a/configure.ac +++ b/configure.ac @@ -118,6 +118,7 @@ CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \ -Wdate-time \ -Wnested-externs \ -Wconversion \ + -Wno-format-nonliteral \ -Werror \ ]) # To enable: diff --git a/src/logger.c b/src/logger.c index 92bdf919e..78614249d 100644 --- a/src/logger.c +++ b/src/logger.c @@ -36,10 +36,7 @@ void loggerDefaultEmit(void *data, int level, const char *fmt, va_list args) /* Then render the message, possibly truncating it. */ n = EMIT_BUF_LEN - strlen(buf) - 1; -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" vsnprintf(cursor, n, fmt, args); -#pragma GCC diagnostic pop fprintf(stderr, "%s\n", buf); } diff --git a/test/lib/logger.c b/test/lib/logger.c index 2970254fa..20d2588c4 100644 --- a/test/lib/logger.c +++ b/test/lib/logger.c @@ -34,10 +34,7 @@ void test_logger_emit(void *data, int level, const char *format, va_list args) sprintf(buf + strlen(buf), "%2d -> [%s] ", t->id, level_name); -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wformat-nonliteral" vsnprintf(buf + strlen(buf), 1024 - strlen(buf), format, args); -#pragma GCC diagnostic pop munit_log(MUNIT_LOG_INFO, buf); return;