1
0
Fork 0
mirror of https://git.tukaani.org/xz.git synced 2024-04-04 12:36:23 +02:00

Tests: Silence warnings about unused functions from tuktest.h.

Warnings about unused tuktest_run_test conveniently tell which
test programs haven't been converted to tuktest.h yet but I
silenced that warning too for now anyway.

It is fine to use __attribute__((__unused__)) even when the
function is actually used because the attribute only means
that the function might be unused.
This commit is contained in:
Lasse Collin 2022-09-09 14:12:30 +03:00
parent f8ee61e74e
commit f2d084fe3f

View file

@ -153,6 +153,14 @@
#endif #endif
// This is silencing warnings about unused functions. Not all test programs
// need all functions from this header.
#if TUKTEST_GNUC_REQ(3, 0)
# define tuktest_maybe_unused __attribute__((__unused__))
#else
# define tuktest_maybe_unused
#endif
// We need printf("") so silence the warning about empty format string. // We need printf("") so silence the warning about empty format string.
#if TUKTEST_GNUC_REQ(4, 2) #if TUKTEST_GNUC_REQ(4, 2)
# pragma GCC diagnostic ignored "-Wformat-zero-length" # pragma GCC diagnostic ignored "-Wformat-zero-length"
@ -561,6 +569,7 @@ tuktest_end(void)
#define tuktest_run(testfunc) \ #define tuktest_run(testfunc) \
tuktest_run_test(&(testfunc), #testfunc) tuktest_run_test(&(testfunc), #testfunc)
tuktest_maybe_unused
static void static void
tuktest_run_test(void (*testfunc)(void), const char *testfunc_str) tuktest_run_test(void (*testfunc)(void), const char *testfunc_str)
{ {
@ -639,6 +648,7 @@ tuktest_run_test(void (*testfunc)(void), const char *testfunc_str)
tuktest_file_from_x(NULL, filename, sizeptr, __FILE__, __LINE__) tuktest_file_from_x(NULL, filename, sizeptr, __FILE__, __LINE__)
// Internal helper for the macros above. // Internal helper for the macros above.
tuktest_maybe_unused
static void * static void *
tuktest_file_from_x(const char *prefix, const char *filename, size_t *size, tuktest_file_from_x(const char *prefix, const char *filename, size_t *size,
const char *prog_filename, unsigned prog_line) const char *prog_filename, unsigned prog_line)