Skip to content

Commit

Permalink
Ignore format-nonliteral warning
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
cole-miller committed Sep 2, 2024
1 parent 8e2d685 commit c65caf8
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 6 deletions.
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ CC_CHECK_FLAGS_APPEND([AM_CFLAGS],[CFLAGS],[ \
-Wdate-time \
-Wnested-externs \
-Wconversion \
-Wno-format-nonliteral \
-Werror \
])
# To enable:
Expand Down
3 changes: 0 additions & 3 deletions src/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
3 changes: 0 additions & 3 deletions test/lib/logger.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit c65caf8

Please sign in to comment.