Discussion:
vasnprintf tests: avoid warnings
(too old to reply)
Bruno Haible
2017-04-22 13:01:17 UTC
Permalink
Raw Message
On Mac OS X, I'm seeing these warnings:


test-vasnprintf-posix3.c:64:1: warning: unused function 'test_vasnprintf' [-Wunused-function]
test_vasnprintf ()
^
test-vasnprintf-posix3.c:70:1: warning: unused function 'test_asnprintf' [-Wunused-function]
test_asnprintf ()
^


This fixes it:

2017-04-22 Bruno Haible <***@clisp.org>

vasnprintf tests: Avoid warnings.
* tests/test-vasnprintf-posix3.c (test_function, my_asnprintf,
test_vasnprintf, test_asnprintf): Don't define if there's nothing to
test.

diff --git a/tests/test-vasnprintf-posix3.c b/tests/test-vasnprintf-posix3.c
index 0e8f934..c198526 100644
--- a/tests/test-vasnprintf-posix3.c
+++ b/tests/test-vasnprintf-posix3.c
@@ -26,13 +26,14 @@

#include "macros.h"

+/* glibc >= 2.2 supports the 'I' flag, and in glibc >= 2.2.3 the fa_IR
+ locale defines the 'outdigits' to be U+06F0..U+06F9.
+ So we test for glibc >= 2.3. */
+#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__
+
static void
test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
{
- /* glibc >= 2.2 supports the 'I' flag, and in glibc >= 2.2.3 the fa_IR
- locale defines the 'outdigits' to be U+06F0..U+06F9.
- So we test for glibc >= 2.3. */
-#if (__GLIBC__ > 2 || (__GLIBC__ == 2 && __GLIBC_MINOR__ >= 3)) && !defined __UCLIBC__
/* Test that the 'I' flag is supported. */
{
size_t length;
@@ -45,7 +46,6 @@ test_function (char * (*my_asnprintf) (char *, size_t *, const char *, ...))
ASSERT (length == strlen (result));
free (result);
}
-#endif
}

static char *
@@ -72,6 +72,8 @@ test_asnprintf ()
test_function (asnprintf);
}

+#endif
+
int
main (int argc, char *argv[])
{

Loading...