From 17679f331403b2d9af84bb4d107bc0ae1f3373f3 Mon Sep 17 00:00:00 2001 From: Jakob Kaivo Date: Fri, 25 Sep 2020 14:24:55 -0400 Subject: move type test objects to file scope, remove need for (void)foo to avoid warnings on unused variables --- signal.c | 6 ++---- stddef.c | 12 ++++-------- stdio.c | 11 ++++------- stdlib.c | 14 +++++--------- string.c | 5 +++-- wchar.c | 17 ++++++----------- wctype.c | 11 ++++------- 7 files changed, 28 insertions(+), 48 deletions(-) diff --git a/signal.c b/signal.c index 4e0d9be..d2c96e2 100644 --- a/signal.c +++ b/signal.c @@ -1,10 +1,10 @@ #include #include "test.h" +sig_atomic_t test_sig_atomic = 0; + void test_signal_h(void) { - sig_atomic_t sig_atomic = 0; - int signals[] = { SIGABRT, SIGFPE, @@ -14,8 +14,6 @@ void test_signal_h(void) SIGTERM, }; - (void)sig_atomic; - testing_header("signal.h"); test_distinct(signals); diff --git a/stddef.c b/stddef.c index 575881d..43ab2d8 100644 --- a/stddef.c +++ b/stddef.c @@ -6,18 +6,14 @@ struct s { char b; }; +ptrdiff_t test_ptrdiff; +size_t test_size; +wchar_t test_wchar; + void test_stddef_h(void) { - ptrdiff_t ptrdiff; - size_t size; - wchar_t wchar; - static struct s the_s; - (void)ptrdiff; - (void)size; - (void)wchar; - testing_header("stddef.h"); test_true(NULL == 0); diff --git a/stdio.c b/stdio.c index cf5d6ac..49a0a3b 100644 --- a/stdio.c +++ b/stdio.c @@ -2,15 +2,12 @@ #include "_stdio.h" #include "test.h" +FILE *test_file; +fpos_t test_fpos; +size_t test_size; + void test_stdio_h(void) { - FILE *file; - fpos_t fpos; - size_t size; - (void)file; - (void)fpos; - (void)size; - int buftypes[] = { _IOFBF, _IOLBF, diff --git a/stdlib.c b/stdlib.c index 9e09111..954031e 100644 --- a/stdlib.c +++ b/stdlib.c @@ -2,17 +2,13 @@ #include #include "test.h" +div_t test_div; +ldiv_t test_ldiv; +size_t test_size; +wchar_t test_wchar; + void test_stdlib_h(void) { - div_t div; - ldiv_t ldiv; - size_t size; - wchar_t wchar; - (void)div; - (void)ldiv; - (void)size; - (void)wchar; - int exit_statuses[] = { EXIT_FAILURE, EXIT_SUCCESS, diff --git a/string.c b/string.c index 5b476d7..f1174ec 100644 --- a/string.c +++ b/string.c @@ -1,14 +1,14 @@ #include #include "test.h" +size_t test_size; + void test_string_h(void) { - size_t size; char dst[64] = { 0 }; char less[] = "a"; char more[] = "b"; char haystack[] = "the five boxing wizards jump quickly"; - (void)size; testing_header("string.h"); @@ -60,6 +60,7 @@ void test_string_h(void) test_true(strspn(haystack, "12345") == 0); test_true(strspn(haystack, "eht") == 3); + test_true(strstr(haystack, "") == haystack); test_true(strstr(haystack, "wizard") == haystack + 16); test_true(strstr(haystack, "rogue") == NULL); diff --git a/wchar.c b/wchar.c index 525d562..137e218 100644 --- a/wchar.c +++ b/wchar.c @@ -3,19 +3,14 @@ #include "_wchar.h" #include "test.h" +wchar_t test_wchar; +size_t test_size; +mbstate_t test_mbstate; +wint_t test_wint; +struct tm *test_tm; + void test_wchar_h(void) { - wchar_t wchar; - size_t size; - mbstate_t mbstate; - wint_t wint; - struct tm *tm; - (void)wchar; - (void)size; - (void)mbstate; - (void)wint; - (void)tm; - testing_header("wchar.h"); test_true(NULL == 0); diff --git a/wctype.c b/wctype.c index 9bb4f02..0238140 100644 --- a/wctype.c +++ b/wctype.c @@ -5,6 +5,10 @@ #include "_wctype.h" #include "test.h" +wint_t test_wint; +wctrans_t test_wctrans; +wctype_t test_wctype; + #define UPPER L"ABCDEFGHIJKLMNOPQRSTUVWXYZ" #define LOWER L"abcdefghijklmnopqrstuvwxyz" #define DIGIT L"0123456789" @@ -68,13 +72,6 @@ static void test_ctype_conversion_imp(const char *fnname, int (*fn)(int), const void test_wctype_h(void) { - wint_t wint; - wctrans_t wctrans; - wctype_t wctype; - (void)wint; - (void)wctrans; - (void)wctype; - testing_header("wctype.h"); test_ctype_function(iswalnum, UPPER LOWER DIGIT); -- cgit v1.2.1