diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2020-07-01 16:45:41 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2020-07-01 16:48:11 -0700 |
commit | 59eb037fc92e23bd6c6034b2a3343ac81f1bd318 (patch) | |
tree | b690191e3ee62c30a9c6fa1e927e45af89fb9997 /tests/unistr | |
parent | a0b286c0a5d50f2b52692f61f09e4500bcd98ebe (diff) | |
download | gnulib-59eb037fc92e23bd6c6034b2a3343ac81f1bd318.tar.gz |
tests: pacify gcc -fanalyzer on zerosize_ptr
* tests/test-memcasecmp.c (main):
* tests/test-memchr.c (main):
* tests/test-memchr2.c (main):
* tests/test-memcmp.c (main):
* tests/test-memmem.c (main):
* tests/test-memrchr.c (main):
* tests/unistr/test-chr.h (main):
* tests/unistr/test-cmp.h (test_cmp):
Check whether zerosize_ptr returns NULL before using it.
This pacifies GCC 10.1’s new fanalyzer option, and matches
other uses of zerosize_ptr.
Diffstat (limited to 'tests/unistr')
-rw-r--r-- | tests/unistr/test-chr.h | 4 | ||||
-rw-r--r-- | tests/unistr/test-cmp.h | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/tests/unistr/test-chr.h b/tests/unistr/test-chr.h index b67be48861..f60610f22b 100644 --- a/tests/unistr/test-chr.h +++ b/tests/unistr/test-chr.h @@ -48,7 +48,9 @@ main (void) ASSERT (U_CHR (input, length, 'a') == input); ASSERT (U_CHR (input, 0, 'a') == NULL); - ASSERT (U_CHR (zerosize_ptr (), 0, 'a') == NULL); + void *page_boundary = zerosize_ptr (); + if (page_boundary) + ASSERT (U_CHR (page_boundary, 0, 'a') == NULL); ASSERT (U_CHR (input, length, 'b') == input + 1); ASSERT (U_CHR (input, length, 'c') == input + 2); diff --git a/tests/unistr/test-cmp.h b/tests/unistr/test-cmp.h index 38a5223f7a..207c59a775 100644 --- a/tests/unistr/test-cmp.h +++ b/tests/unistr/test-cmp.h @@ -20,7 +20,10 @@ static void test_cmp (void) { /* Test equal / not equal distinction. */ - ASSERT (U_CMP (zerosize_ptr (), zerosize_ptr (), 0) == 0); + void *page_boundary1 = zerosize_ptr (); + void *page_boundary2 = zerosize_ptr (); + if (page_boundary1 && page_boundary2) + ASSERT (U_CMP (page_boundary1, page_boundary2, 0) == 0); { static const UNIT input1[] = { 'f', 'o', 'o', 0 }; static const UNIT input2[] = { 'f', 'o', 'o', 'b', 'a', 'r', 0 }; |