From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mo4-p01-ob.smtp.rzone.de (mo4-p01-ob.smtp.rzone.de [81.169.146.167]) by sourceware.org (Postfix) with ESMTPS id C13693858C27 for ; Fri, 25 Dec 2020 00:44:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org C13693858C27 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=clisp.org Authentication-Results: sourceware.org; spf=none smtp.mailfrom=bruno@clisp.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; t=1608857088; s=strato-dkim-0002; d=clisp.org; h=References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From:From: Subject:Sender; bh=P0yar2u7Hw+UeZo+L0bsm1hREHjfoZdWai8SP2OkWk4=; b=Qb2RdHznDafxS2lLPT1SmUqwGpGKlmUTSf06ZeSdNuzQLaBT79cDz3HeSDaO50/yzq QeuudNrp57Zd2A96qzt/7M8qMlIfXGshrIDvPh4Ykv9Xc/O0uWiNas0YEoflPrSzaNKU ZY2Uq5UKRinUCwYPu8qho3PkSsiSobCZeCZfa7FoUTzbh8EZBjGxJRhXduCzx1aIZWTt eo7mTDP6xI8YWYT51LvMG1Hevib9Vhof3SUOBwjGRvs0K5wOf1moKnbHZNpX4PTE3w7B d3KulXOlFvav8UZinsiopWMQikbeYPkcSnq8gVqS9Vo69bQ6kuOdV/0doGDKOQAtactH NRrg== X-RZG-AUTH: ":Ln4Re0+Ic/6oZXR1YgKryK8brlshOcZlIWs+iCP5vnk6shH+AHjwLuWOHqfzyPs=" X-RZG-CLASS-ID: mo00 Received: from bruno.haible.de by smtp.strato.de (RZmta 47.10.7 DYNA|AUTH) with ESMTPSA id e012d5wBP0il4iv (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (curve X9_62_prime256v1 with 256 ECDH bits, eq. 3072 bits RSA)) (Client did not present a certificate); Fri, 25 Dec 2020 01:44:47 +0100 (CET) From: Bruno Haible To: bug-gnulib@gnu.org Cc: Paul Eggert , Adhemerval Zanella , libc-alpha@sourceware.org Subject: Re: [PATCH 1/5] warnings in canonicalize.c Date: Fri, 25 Dec 2020 01:44:46 +0100 Message-ID: <4523025.s2klC9eo8s@omega> User-Agent: KMail/5.1.3 (Linux/4.4.0-197-generic; KDE/5.18.0; x86_64; ; ) In-Reply-To: <05d5bdbd-210b-bb14-969c-ba59434a2280@cs.ucla.edu> References: <20201224151701.1751008-1-adhemerval.zanella@linaro.org> <20201224151701.1751008-2-adhemerval.zanella@linaro.org> <05d5bdbd-210b-bb14-969c-ba59434a2280@cs.ucla.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, NICE_REPLY_A, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_PASS, SPF_NONE, 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-List-Received-Date: Fri, 25 Dec 2020 00:44:51 -0000 Paul Eggert wrote: > > @@ -270,7 +270,7 @@ > > buf[n] = '\0'; > > > > char *extra_buf = extra_buffer.data; > > - idx_t end_idx; > > + idx_t end_idx = 0; > > if (end_in_extra_buffer) > > end_idx = end - extra_buf; > > idx_t len = strlen (end); > > This change isn't needed, since end_idx is used only when > end_in_extra_buffer is true. > > Was the latter change put in only to pacify older GCC versions? Yes. > (I don't get a warning with GCC 10.2.) Indeed, I don't see warnings in canonicalize-lgpl.c. But there are warnings in gnulib's canonicalize.c: gcc 9.3.0: $ gcc -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -c ./canonicalize.c ./canonicalize.c: In function 'canonicalize_filename_mode_stk': ./canonicalize.c:337:16: warning: unused variable 'discard' [-Wunused-variable] 337 | char discard; | ^~~~~~~ ./canonicalize.c: In function 'canonicalize_filename_mode': ./canonicalize.c:400:33: warning: 'end_idx' may be used uninitialized in this function [-Wmaybe-uninitialized] 400 | end = extra_buf + end_idx; | ~~~~~~~~~~^~~~~~~~~ ./canonicalize.c:389:21: note: 'end_idx' was declared here 389 | idx_t end_idx; | ^~~~~~~ gcc 10.2.0: $ gcc -DHAVE_CONFIG_H -I. -I.. -Wall -g -O2 -c ./canonicalize.c ./canonicalize.c: In function 'canonicalize_filename_mode_stk': ./canonicalize.c:337:16: warning: unused variable 'discard' [-Wunused-variable] 337 | char discard; | ^~~~~~~ ... ./canonicalize.c:400:33: warning: 'end_idx' may be used uninitialized in this function [-Wmaybe-uninitialized] 400 | end = extra_buf + end_idx; | ~~~~~~~~~~^~~~~~~~~ ./canonicalize.c:389:21: note: 'end_idx' was declared here 389 | idx_t end_idx; | ^~~~~~~ Bruno