These gcc warnings: ../../gllib/stdopen.c:40:30: warning: leak of file descriptor 'full_fd' [CWE-775] ../../gllib/stdopen.c:40:30: warning: leak of file descriptor 'new_fd' [CWE-775] ../../gllib/stdopen.c:59:15: warning: leak of file descriptor 'new_fd' [CWE-775]
are not false positives. But they point to intentional effects. 2025-04-26 Bruno Haible <br...@clisp.org> stdopen: Silence -Wanalyzer-fd-leak warnings. * lib/stdopen.c: Add a '#pragma GCC diagnostic ignored'. diff --git a/lib/stdopen.c b/lib/stdopen.c index b684281525..9b5227e84d 100644 --- a/lib/stdopen.c +++ b/lib/stdopen.c @@ -26,6 +26,12 @@ #include <unistd.h> #include <errno.h> +/* It is normal that stdopen() opens file descriptors without closing them. + Tell GCC not to warn about it. */ +#if _GL_GNUC_PREREQ (13, 1) +# pragma GCC diagnostic ignored "-Wanalyzer-fd-leak" +#endif + /* Try to ensure that all of the standard file numbers (0, 1, 2) are in use. Without this, each application would have to guard every call to open, dup, fopen, etc. with tests to ensure they