From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1930) id DFF353851C0C; Mon, 11 May 2020 17:38:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DFF353851C0C Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Martin Sebor To: glibc-cvs@sourceware.org Subject: [glibc] Suppress GCC 10 true positive warnings [BZ #25967] X-Act-Checkin: glibc X-Git-Author: Martin Sebor X-Git-Refname: refs/heads/master X-Git-Oldrev: e627106266ad8785457fadbf5bf67ed604d2a353 X-Git-Newrev: 978e8ac39f8ba2d694031e521511da1ae803ccfc Message-Id: <20200511173821.DFF353851C0C@sourceware.org> Date: Mon, 11 May 2020 17:38:21 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 May 2020 17:38:22 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=978e8ac39f8ba2d694031e521511da1ae803ccfc commit 978e8ac39f8ba2d694031e521511da1ae803ccfc Author: Martin Sebor Date: Mon May 11 11:29:39 2020 -0600 Suppress GCC 10 true positive warnings [BZ #25967] Suppress or avoid warnings in tests that exercise failure modes by making calls with invalid arguments. Reviewed-by: DJ Delorie Reviewed-by: Florian Weimer Reviewed-by: Joseph Myers Diff: --- io/tst-getcwd.c | 21 +++++++++++++++++++-- posix/test-errno.c | 12 +++++++++++- 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/io/tst-getcwd.c b/io/tst-getcwd.c index 75ecd2c7b9..c9c4713fc3 100644 --- a/io/tst-getcwd.c +++ b/io/tst-getcwd.c @@ -23,6 +23,7 @@ #include #include #include +#include #define TEST_FUNCTION do_test () @@ -58,7 +59,13 @@ do_test (void) bufs[i] = (char *) malloc (sbs); } + /* Avoid warnings about the first argument being null when the second + is nonzero. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wnonnull"); bufs[i] = getcwd (NULL, sbs); + DIAG_POP_NEEDS_COMMENT; + lens[i] = sbs; if (bufs[i] == NULL) { @@ -96,12 +103,17 @@ getcwd (NULL, sbs) = \"%s\", getcwd (thepath, sizeof thepath) = \"%s\"\n", free (bufs[i]); /* Test whether the function signals success despite the buffer - being too small. */ + being too small. + Avoid warnings about the first argument being null when the second + is nonzero. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wnonnull"); if (getcwd (NULL, len) != NULL) { puts ("getcwd (NULL, len) didn't failed"); return 1; } + DIAG_POP_NEEDS_COMMENT; bufs[0] = malloc (len); bufs[1] = malloc (len); @@ -132,13 +144,18 @@ getcwd (NULL, sbs) = \"%s\", getcwd (thepath, sizeof thepath) = \"%s\"\n", return 1; } - /* Now test handling of correctly sized buffers. */ + /* Now test handling of correctly sized buffers. + Again. avoid warnings about the first argument being null when + the second is nonzero. */ + DIAG_PUSH_NEEDS_COMMENT; + DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wnonnull"); bufs[0] = getcwd (NULL, len + 1); if (bufs[0] == NULL) { puts ("getcwd (NULL, len + 1) failed"); return 1; } + DIAG_POP_NEEDS_COMMENT; free (bufs[0]); memset (thepath, '\xff', sizeof thepath); diff --git a/posix/test-errno.c b/posix/test-errno.c index 6afadcd102..492fd66bb5 100644 --- a/posix/test-errno.c +++ b/posix/test-errno.c @@ -34,6 +34,7 @@ #include #include #include +#include /* This is not an exhaustive test: only system calls that can be persuaded to fail with a consistent error code and no side effects @@ -119,7 +120,16 @@ do_test (void) fails |= test_wrp (EBADF, fstatfs, -1, &sfs); fails |= test_wrp (EBADF, fsync, -1); fails |= test_wrp (EBADF, ftruncate, -1, 0); + +#if __GNUC_PREREQ (7, 0) + DIAG_PUSH_NEEDS_COMMENT; + /* Avoid warnings about the second (size) argument being negative. */ + DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wstringop-overflow"); +#endif fails |= test_wrp (EINVAL, getgroups, -1, 0); +#if __GNUC_PREREQ (7, 0) + DIAG_POP_NEEDS_COMMENT; +#endif fails |= test_wrp (EBADF, getpeername, -1, &sa, &sl); fails |= test_wrp (EBADF, getsockname, -1, &sa, &sl); fails |= test_wrp (EBADF, getsockopt, -1, 0, 0, buf, &sl); @@ -134,7 +144,7 @@ do_test (void) fails |= test_wrp (EINVAL, munmap, (void *) -1, 0); fails |= test_wrp (EISDIR, open, "/bin", EISDIR, O_WRONLY); fails |= test_wrp (EBADF, read, -1, buf, 1); - fails |= test_wrp (EINVAL, readlink, "/", buf, -1); + fails |= test_wrp (EINVAL, readlink, "/", buf, sizeof buf); fails |= test_wrp (EBADF, readv, -1, iov, 1); fails |= test_wrp (EBADF, recv, -1, buf, 1, 0); fails |= test_wrp (EBADF, recvfrom, -1, buf, 1, 0, &sa, &sl);