From patchwork Thu May 7 17:58:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Sebor X-Patchwork-Id: 38932 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id CB899396DC1D; Thu, 7 May 2020 17:58:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org CB899396DC1D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1588874300; bh=g46pwyh14Y15D3E/P8IvoewdPeSoGDWvy4bmxc6+OMM=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=aAVjB+5F7lpvGYH/T9k2L4N7PQSyMgVLhtAVT64D4wHs6dqwt0QloidfqDtuo0ibY sxQBbGgzL6ULAsyl/1CVEDxwU7C/VbmwlPTdilH/bipQCBgh3occEgFU9jBNsyrC0T rSjVnC2rseKeBIjh8rezkTHZ15P6Fx/ELPbPIxxA= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-qk1-x742.google.com (mail-qk1-x742.google.com [IPv6:2607:f8b0:4864:20::742]) by sourceware.org (Postfix) with ESMTPS id 00B6338708C8 for ; Thu, 7 May 2020 17:58:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 00B6338708C8 Received: by mail-qk1-x742.google.com with SMTP id b188so7066747qkd.9 for ; Thu, 07 May 2020 10:58:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:to:from:subject:message-id:date:user-agent :mime-version:content-language; bh=g46pwyh14Y15D3E/P8IvoewdPeSoGDWvy4bmxc6+OMM=; b=BnrbmbDu2JSMY1Xnq/VNbK3aWlYaDOUAZ5iDnV81wbrM29JdfMgFYvsK90CGB1iDkl dSrTuKtCC0eZggXpGOEGuENV6k/j9nI+smrzbJML33e8BcvVLUam9+ZhxPjJdAkSZn2P DWt+Nh3thSbVWyCli5wv7Xl4lLdFjPPjSOXABuSAjbVO/csdHyOZAsO4RHh2aHPi8752 7n1LSqICIMhjxBZ5QeSCPGL1MtggREGMhjSr8WkyZeO3+x1xEMmwlclo3cqqg/oMvndc 3WUdb1NNKmfC3pQlwqcncSB6PnsSEdASttm7MfD/46h4NUSFmMXj9YfUDiJqaW8GFefM 0Nug== X-Gm-Message-State: AGi0PubppbX5R2Y6e/h562NFwH5kUne7GWlKiPihq4JnrgNRwzsQi3ZD eR+GePwEuYH8k8VVdGNoZIo= X-Google-Smtp-Source: APiQypLk2J2noK5hxbm3/LS2+FiV0dTZEHAiyt8dc2oluDGTmh6ShK5T46lb0WxBvG8Cm2Td/rHUWw== X-Received: by 2002:a05:620a:1456:: with SMTP id i22mr2879559qkl.309.1588874288587; Thu, 07 May 2020 10:58:08 -0700 (PDT) Received: from [192.168.0.41] (174-16-121-251.hlrn.qwest.net. [174.16.121.251]) by smtp.gmail.com with ESMTPSA id q59sm2633076qtd.73.2020.05.07.10.58.07 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 07 May 2020 10:58:07 -0700 (PDT) To: GNU C Library , "Joseph S. Myers" , DJ Delorie Subject: [PATCH] avoid GCC 10 test suite warnings (BZ #25219) Message-ID: Date: Thu, 7 May 2020 11:58:06 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 Content-Language: en-US X-Spam-Status: No, score=-11.8 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Martin Sebor via Libc-alpha From: Martin Sebor Reply-To: Martin Sebor Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" The attached patch suppresses a few GCC 10 true positive warnings in tests that exercise failure modes by making calls with invalid arguments. With the patch, GCC 10 compiles all tests without an error. Martin PS I'm not sure the readlink test is quite correct. If its purpose is to verify that readlink fails for "/" because it's not a symbolic link then it shouldn't also pass an excessive size as the last argument, because it makes the call undefined. If, on the other hand, its purpose is to verify the function fails with EINVAL when "bufsiz is not positive" (as documented on the Linux man page(*) but not in the Glibc manual) then that failure mode should be tested separately from the first. That said, I'm not sure POSIX allows the function to fail with EINVAL in this case because that would make the two failures indistinguishable. http://man7.org/linux/man-pages/man2/readlink.2.html 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..e62efe2638 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,16 @@ 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); + +#if __GNUC_PREREQ (7, 0) + DIAG_PUSH_NEEDS_COMMENT; + /* Avoid warnings about the second (size) argument being excessive. */ + DIAG_IGNORE_NEEDS_COMMENT (10.1, "-Wstringop-overflow"); +#endif fails |= test_wrp (EINVAL, readlink, "/", buf, -1); +#if __GNUC_PREREQ (7, 0) + DIAG_POP_NEEDS_COMMENT; +#endif 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);