From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.4 Received: from second.openwall.net (second.openwall.net [193.110.157.125]) by inbox.vuxu.org (Postfix) with SMTP id 8C83E21671 for ; Thu, 21 Mar 2024 23:27:30 +0100 (CET) Received: (qmail 7586 invoked by uid 550); 21 Mar 2024 22:22:52 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 7548 invoked from network); 21 Mar 2024 22:22:51 -0000 Date: Thu, 21 Mar 2024 18:27:34 -0400 From: Rich Felker To: Maks Mishin Cc: musl@lists.openwall.com Message-ID: <20240321222733.GJ15722@brightrain.aerifal.cx> References: <20240321204014.31675-1-maks.mishinFZ@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20240321204014.31675-1-maks.mishinFZ@gmail.com> User-Agent: Mutt/1.5.21 (2010-09-15) Subject: [musl] Re: [PATCH] vfscanf: Remove if-condition with unused value On Thu, Mar 21, 2024 at 11:40:14PM +0300, Maks Mishin wrote: > Remove else branch because the value of 'c' is unused. > > Found by RASU JSC. > > Signed-off-by: Maks Mishin > --- > src/stdio/vfscanf.c | 2 -- > 1 file changed, 2 deletions(-) > > diff --git a/src/stdio/vfscanf.c b/src/stdio/vfscanf.c > index b78a374d..fad88553 100644 > --- a/src/stdio/vfscanf.c > +++ b/src/stdio/vfscanf.c > @@ -263,8 +263,6 @@ int vfscanf(FILE *restrict f, const char *restrict fmt, va_list ap) > } else if ((s = dest)) { > while (scanset[(c=shgetc(f))+1]) > s[i++] = c; > - } else { > - while (scanset[(c=shgetc(f))+1]); > } > shunget(f); > if (!shcnt(f)) goto match_fail; > -- > 2.30.2 Did you even test this? The patch removes code with side effects and completely breaks %*[scanset] conversion specifiers by turning them into effective no-ops. The analysis tool was telling you the assignment to c is unused, not that the calls to shgetc can just be thrown away. Rich