Skip to content

Commit

Permalink
tests/nutlogtest.c: use support for plain "-Wformat" and for "-Wforma…
Browse files Browse the repository at this point in the history
…t-extra-args" in pragmas to quiesce "bogus-looking" test cases [networkupstools#2450]

Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed Jun 2, 2024
1 parent 8ccaa27 commit 41ce7c7
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions tests/nutlogtest.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,24 @@ int main(void) {
ret++;
}

#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW)
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat"
#endif
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_EXTRA_ARGS)
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wformat-extra-args"
#endif
if (snprintf_dynamic(buf, sizeof(buf), dynfmt, "%d", "Single string via dynamic format", 1) < 0) {
upsdebugx(0, "D: snprintf_dynamic() correctly reports mis-matched formats");
} else {
upsdebugx(0, "E: snprintf_dynamic() wrongly reports well-matched formats");
ret++;
}
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_OVERFLOW)
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT_EXTRA_ARGS)
# pragma GCC diagnostic pop
#endif
#if (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_PUSH_POP) && (defined HAVE_PRAGMA_GCC_DIAGNOSTIC_IGNORED_FORMAT)
# pragma GCC diagnostic pop
#endif

Expand Down

0 comments on commit 41ce7c7

Please sign in to comment.