From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa1.mentor.iphmx.com (esa1.mentor.iphmx.com [68.232.129.153]) by sourceware.org (Postfix) with ESMTPS id 374F8385802A for ; Wed, 10 Nov 2021 00:02:16 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 374F8385802A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com IronPort-SDR: PoEKf8dHpUjKNjbRlOW6zQz3zUvwf2mqlr7niw4r8IhWqOQ/WoJu4OcNlbaHh0/YB3ni0dOAfw 6Kx5hWpA2jh7G7CQ6yG6mX5xzHzbgC8fXOg0CGZ/YUJInm8NCgNznA0gT9e1z+q9aMniIJ0rl6 9jG/BubIefWqar/oAwOwJPxyDMIuiJaz+0io91oaHzJgXlWMeaLUhgd0nmWDeL32+Dg1ETwA2U 4ojPOsfXpL0q4vLjSCgmw8NrBKsdqAN3UAy4r7ijrYKPJkxAxGRW7+eWB2ZxoNLiR8URCZ57um ZUXP9LvSEp5cOaFbw7B4k3rS X-IronPort-AV: E=Sophos;i="5.87,221,1631606400"; d="scan'208";a="70749469" Received: from orw-gwy-02-in.mentorg.com ([192.94.38.167]) by esa1.mentor.iphmx.com with ESMTP; 09 Nov 2021 16:02:16 -0800 IronPort-SDR: h7isaOtCPhTkv+vsOA9RIHgCrqxSj6D/+Wlva7IHHXMifHg7WXMvO9o5sok583BJlMVfJfPkBm Kt1JqC0UoDILSk1U79H1rJqh1VfUK/pU3DhHZ+EsyKzvla4s6dTJij+tk/X+ZC/1SgEbr626eM 8mYaOF8HvPllZ1C6qZ+Qy02mIYmjL7SDHVQ3wfL0Oh9f4wt92NgyR/MW2FG4+g03YiOOSxXeCK VB8OQHNqetz+TiPtjkfvDwsJpeXgJwuNMHegDVt014J2AkAS1TsmALa76t5iiBCFxP3re168H8 xW4= Date: Wed, 10 Nov 2021 00:02:10 +0000 From: Joseph Myers X-X-Sender: jsm28@digraph.polyomino.org.uk To: Xi Ruoyao CC: , Bruce Korb Subject: Re: [PATCH] fixincludes: don't assume getcwd() can handle NULL argument In-Reply-To: <109aefbeac593ab5660a71df38f1727002c19e39.camel@mengyan1223.wang> Message-ID: References: <109aefbeac593ab5660a71df38f1727002c19e39.camel@mengyan1223.wang> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-05.mgc.mentorg.com (139.181.222.5) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) X-Spam-Status: No, score=-3116.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS, KAM_DMARC_STATUS, SPF_HELO_PASS, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT X-Content-Filtered-By: Mailman/MimeDel 2.1.29 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 10 Nov 2021 00:02:17 -0000 On Tue, 9 Nov 2021, Xi Ruoyao via Gcc-patches wrote: > POSIX says: > > On some implementations, if buf is a null pointer, getcwd() may obtain > size bytes of memory using malloc(). In this case, the pointer returned > by getcwd() may be used as the argument in a subsequent call to free(). > Invoking getcwd() with buf as a null pointer is not recommended in > conforming applications. > > This produces an error building GCC with --enable-werror-always: > > ../../../fixincludes/fixincl.c: In function ‘process’: > ../../../fixincludes/fixincl.c:1356:7: error: argument 1 is null but > the corresponding size argument 2 value is 4096 [-Werror=nonnull] Isn't this warning actually a glibc bug ? -- Joseph S. Myers joseph@codesourcery.com