Message ID | ZCVCzOdvlQG2Lke7@tucnak |
---|---|
State | Unresolved |
Headers |
Return-Path: <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp955626vqo; Thu, 30 Mar 2023 01:06:22 -0700 (PDT) X-Google-Smtp-Source: AKy350a+07azoBJH7EsymHrU/2lT0ffKy3aI9r/A4pZKO4dtHenMrp17E6p1NKAENMadAr2tfDOT X-Received: by 2002:a17:906:fb93:b0:92b:8fe7:344 with SMTP id lr19-20020a170906fb9300b0092b8fe70344mr21656889ejb.16.1680163582039; Thu, 30 Mar 2023 01:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680163582; cv=none; d=google.com; s=arc-20160816; b=cZIo4SDpxrsN1Vjn1cdPYKMFkltMbAomgCO7MRl1DeB4nJloovH+RpM/AivuKHNzb0 SsYjICuus60UDODWNR4ju4FeoTzKDGugt7Xjp7gMUvJY5FeShSam0+EKvB8LGDl8xbiS h2xvnS4MN28uVGWvVn5NgZd/k+CPsBiiEVlR+1qwQV7tGgR3UyVte+eDGCzBQDjlDLiY AXkoJqt6PzQ3cVed/pTwQBqsC4TTMy5wx9R/+ihgfsdJrNYw7sOnS9sPicK8CPDsYVVa fjGe5C4105+Vm3WvgX+KkxY/nutASSd23eQcsaM1UseIs5XRD4iVN8iv0fpTsK+hxSGF lCMg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence :content-disposition:mime-version:message-id:subject:cc:to:date :dmarc-filter:delivered-to:dkim-signature:dkim-filter; bh=+4TwIdDzzHVssEwuyn0E6uR2oXHeziLPUUDF/F5JqFk=; b=ueI92RcBYp01jhR9CEgJy0z39qbGnUltCLDHGJs+cOWIjI+10SjRLduHTj+3vzchLP xV3ixORA6Gl7d6RElX2aeHYqEzPJCn5DRWGtH88c8TXrF2LIzqV+MYUM3ot5Dx/SY3/z Tq3VXVJf/gC0DQnAeXcKtbZUfbduMYDg47phCtX6iRyqrhI6pF/zpPuCZptoR78DV6MQ kijghTc+TK2gBLPPqjLU3OAw1Rv8fploItx994bCAeeuKzLca+o63WnyXP80kLjpf/U1 FOvzFUeFnI4tqO2B7x+sjQQkME5LOiHNozASPjelcFz7nLOdejEWesoSr9Uyz+5s+jtJ y5NA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SwYbUPkg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id fj7-20020a1709069c8700b00946c1d28b59si6367550ejc.355.2023.03.30.01.06.21 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Mar 2023 01:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=SwYbUPkg; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E9F293858C50 for <ouuuleilei@gmail.com>; Thu, 30 Mar 2023 08:06:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E9F293858C50 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680163581; bh=+4TwIdDzzHVssEwuyn0E6uR2oXHeziLPUUDF/F5JqFk=; h=Date:To:Cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=SwYbUPkgE0Nn99Y5oLR7nA5BfgQL55xoAisr3p6Wwy7x6aZx0/ZUMsfU57ZISRrQW Qji8tmOSNAtURozL1aj8vlDzpFN5ShZWUN1jocV/5uUN+eUGM1bO6Wh2Kd9ZNOpnHU iggchylav8wDw148a1PK1r8YDxus01y58nmFdnbk= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 9F5363858CDA for <gcc-patches@gcc.gnu.org>; Thu, 30 Mar 2023 08:05:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 9F5363858CDA Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-196-IzJn_lqWOuaY404YMiMllQ-1; Thu, 30 Mar 2023 04:05:36 -0400 X-MC-Unique: IzJn_lqWOuaY404YMiMllQ-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 94D48811E7C for <gcc-patches@gcc.gnu.org>; Thu, 30 Mar 2023 08:05:36 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.16]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 50FFE492C3E; Thu, 30 Mar 2023 08:05:36 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 32U85XAW1701723 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Thu, 30 Mar 2023 10:05:34 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 32U85XGj1701722; Thu, 30 Mar 2023 10:05:33 +0200 Date: Thu, 30 Mar 2023 10:05:32 +0200 To: David Malcolm <dmalcolm@redhat.com> Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] testsuite, analyzer: Fix up pipe-glibc.c testcase [PR107396] Message-ID: <ZCVCzOdvlQG2Lke7@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-3.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list <gcc-patches.gcc.gnu.org> List-Unsubscribe: <https://gcc.gnu.org/mailman/options/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe> List-Archive: <https://gcc.gnu.org/pipermail/gcc-patches/> List-Post: <mailto:gcc-patches@gcc.gnu.org> List-Help: <mailto:gcc-patches-request@gcc.gnu.org?subject=help> List-Subscribe: <https://gcc.gnu.org/mailman/listinfo/gcc-patches>, <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe> From: Jakub Jelinek via Gcc-patches <gcc-patches@gcc.gnu.org> Reply-To: Jakub Jelinek <jakub@redhat.com> Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" <gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1761779208563853567?= X-GMAIL-MSGID: =?utf-8?q?1761779208563853567?= |
Series |
testsuite, analyzer: Fix up pipe-glibc.c testcase [PR107396]
|
|
Checks
Context | Check | Description |
---|---|---|
snail/gcc-patch-check | warning | Git am fail log |
Commit Message
Jakub Jelinek
March 30, 2023, 8:05 a.m. UTC
Hi! The gcc.dg/analyzer/pipe-glibc.c test FAILs when using recent glibc headers and succeeds with older headers. The important change is that https://sourceware.org/git/?p=glibc.git;a=commit;h=c1760eaf3b575ad174fd88b252fd16bd525fa818 in 2021 added __attribute__ ((__malloc__ (fclose, 1))) attribute to fdopen, so in write_to_pipe there is an excess warning: .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c: In function 'write_to_pipe': .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: warning: use of possibly-NULL 'stream' where non-null expected [CWE-690] [-Wanalyzer-possible-null-argument] .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:27:12: note: (1) this call could return NULL .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: note: (2) argument 4 ('stream') from (1) could be NULL where non-null expected <built-in>: note: argument 4 of '__builtin_fwrite' must be non-null Strangely, nothing is reported on the read_from_pipe function, seems fwrite/fprintf/fputc etc. are builtins in GCC and we mark the FILE * arguments as nonnull there on the builtin declarations, while fgetc/fread etc. aren't builtins and glibc doesn't mark any of those using nonnull. Shall we change that on the glibc side? Anyway, because this differs based on glibc version and I think the above warning is not the primary intention of the test, I think it is best to tweak it so that this warning isn't reported. Another option would be avoid using glibc headers and use our own declarations, or make sure we add the malloc with fclose attribute ourselves (but fdopen in the libc headers could be a macro, so not sure __typeof (fdopen) fdopen __attribute__ ((__malloc__, __malloc__ (fclose, 1))); would work). Or use -Wno-analyzer-possible-null-arguments in dg-additional-options? Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-03-30 Jakub Jelinek <jakub@redhat.com> PR analyzer/107396 * gcc.dg/analyzer/pipe-glibc.c (read_from_pie, write_to_pipe): Exit if fdopen returns NULL. Jakub
Comments
On Thu, 2023-03-30 at 10:05 +0200, Jakub Jelinek wrote: > Hi! > > The gcc.dg/analyzer/pipe-glibc.c test FAILs when using recent glibc > headers > and succeeds with older headers. > The important change is that > https://sourceware.org/git/?p=glibc.git;a=commit;h=c1760eaf3b575ad174fd88b252fd16bd525fa818 > in 2021 added __attribute__ ((__malloc__ (fclose, 1))) attribute to > fdopen, > so in write_to_pipe there is an excess warning: > .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c: In function > 'write_to_pipe': > .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: warning: use of > possibly-NULL 'stream' where non-null expected [CWE-690] [-Wanalyzer- > possible-null-argument] > .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:27:12: note: (1) this > call could return NULL > .../gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c:28:3: note: (2) > argument 4 ('stream') from (1) could be NULL where non-null expected > <built-in>: note: argument 4 of '__builtin_fwrite' must be non-null > Strangely, nothing is reported on the read_from_pipe function, seems > fwrite/fprintf/fputc etc. are builtins in GCC and we mark the FILE * > arguments as nonnull there on the builtin declarations, while > fgetc/fread > etc. aren't builtins and glibc doesn't mark any of those using > nonnull. > Shall we change that on the glibc side? > > Anyway, because this differs based on glibc version and I think the > above warning is not the primary intention of the test, I think it is > best to tweak it so that this warning isn't reported. [...snip...] Thanks: the patch LGTM. Dave
--- gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c.jj 2022-10-25 10:37:28.106531709 +0200 +++ gcc/testsuite/gcc.dg/analyzer/pipe-glibc.c 2023-03-29 19:14:48.789766475 +0200 @@ -13,6 +13,8 @@ read_from_pipe (int file) FILE *stream; int c; stream = fdopen (file, "r"); + if (stream == NULL) + exit (EXIT_FAILURE); while ((c = fgetc (stream)) != EOF) putchar (c); fclose (stream); @@ -25,6 +27,8 @@ write_to_pipe (int file) { FILE *stream; stream = fdopen (file, "w"); + if (stream == NULL) + exit (EXIT_FAILURE); fprintf (stream, "hello, world!\n"); fprintf (stream, "goodbye, world!\n"); fclose (stream);