From 9e6a37ccc2964c63ebc8491ad0da4d6ac668f2b4 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 24 Apr 2023 12:06:54 -0700 Subject: tests: suppress some unwanted -fanalyzer checking * tests/test-dup2.c, tests/test-fcntl.c, tests/test-fopen.h: * tests/test-getdtablesize.c, tests/test-listen.c: * tests/test-localename.c, tests/test-open.h, tests/test-perror2.c: * tests/test-select.h: Add pragmas to disable unwanted -fanalyzer checking. --- tests/test-dup2.c | 6 ++++++ tests/test-fcntl.c | 8 ++++++++ tests/test-fopen.h | 5 +++++ tests/test-getdtablesize.c | 5 +++++ tests/test-listen.c | 5 +++++ tests/test-localename.c | 4 ++++ tests/test-open.h | 5 +++++ tests/test-perror2.c | 5 +++++ tests/test-select.h | 4 ++++ 9 files changed, 47 insertions(+) (limited to 'tests') diff --git a/tests/test-dup2.c b/tests/test-dup2.c index 85133ea1e4..e7957271ad 100644 --- a/tests/test-dup2.c +++ b/tests/test-dup2.c @@ -50,6 +50,12 @@ SIGNATURE_CHECK (dup2, int, (int, int)); #include "macros.h" +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +# pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#endif + /* Return non-zero if FD is open. */ static int is_open (int fd) diff --git a/tests/test-fcntl.c b/tests/test-fcntl.c index 4206de991a..c2b7377b59 100644 --- a/tests/test-fcntl.c +++ b/tests/test-fcntl.c @@ -44,6 +44,14 @@ SIGNATURE_CHECK (fcntl, int, (int, int, ...)); #include "binary-io.h" #include "macros.h" +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif +#if __GNUC__ >= 13 +# pragma GCC diagnostic ignored "-Wanalyzer-va-arg-type-mismatch" +#endif + #if !O_BINARY # define set_binary_mode(f,m) zero () static int zero (void) { return 0; } diff --git a/tests/test-fopen.h b/tests/test-fopen.h index a03c931816..751afd8c61 100644 --- a/tests/test-fopen.h +++ b/tests/test-fopen.h @@ -23,6 +23,11 @@ #include "macros.h" +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-file-leak" +#endif + /* Test fopen. Assumes BASE is defined. */ static int diff --git a/tests/test-getdtablesize.c b/tests/test-getdtablesize.c index 46a546fead..4eb28d9b1e 100644 --- a/tests/test-getdtablesize.c +++ b/tests/test-getdtablesize.c @@ -25,6 +25,11 @@ SIGNATURE_CHECK (getdtablesize, int, (void)); #include "macros.h" +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + int main (int argc, char *argv[]) { diff --git a/tests/test-listen.c b/tests/test-listen.c index 43b86a8bb0..b245e48f3a 100644 --- a/tests/test-listen.c +++ b/tests/test-listen.c @@ -27,6 +27,11 @@ SIGNATURE_CHECK (listen, int, (int, int)); #include "sockets.h" #include "macros.h" +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#endif + int main (void) { diff --git a/tests/test-localename.c b/tests/test-localename.c index d56d14ed0a..090afeb538 100644 --- a/tests/test-localename.c +++ b/tests/test-localename.c @@ -35,6 +35,10 @@ # define freelocale(loc) ((void) (loc)) #endif +/* Suppress GCC false positive. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-use-of-uninitialized-value" +#endif #if HAVE_GOOD_USELOCALE diff --git a/tests/test-open.h b/tests/test-open.h index 18549c4c4f..f01523dc16 100644 --- a/tests/test-open.h +++ b/tests/test-open.h @@ -16,6 +16,11 @@ /* Written by Bruno Haible , 2007. */ +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + /* Make test_open always inline if we're using Fortify, which defines __always_inline to do that. Do nothing otherwise. This works around a glibc bug whereby 'open' cannot be used as a function diff --git a/tests/test-perror2.c b/tests/test-perror2.c index de12480322..0c96832d37 100644 --- a/tests/test-perror2.c +++ b/tests/test-perror2.c @@ -22,6 +22,11 @@ #include #include +/* Tell GCC not to warn about myerr being leaked. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + /* This test intentionally parses stderr. So, we arrange to have fd 10 (outside the range of interesting fd's during the test) set up to duplicate the original stderr. */ diff --git a/tests/test-select.h b/tests/test-select.h index ceeb485471..af840d2bc8 100644 --- a/tests/test-select.h +++ b/tests/test-select.h @@ -37,6 +37,10 @@ # include #endif +/* Tell GCC not to warn about the specific edge cases tested here. */ +#if __GNUC__ >= 10 +# pragma GCC diagnostic ignored "-Wanalyzer-fd-use-without-check" +#endif typedef int (*select_fn) (int, fd_set *, fd_set *, fd_set *, struct timeval *); -- cgit v1.2.1