From: Rich Felker <dalias@aerifal.cx>
To: Maks Mishin <maks.mishinfz@gmail.com>
Cc: musl@lists.openwall.com
Subject: [musl] Re: [PATCH] vfscanf: Remove if-condition with unused value
Date: Thu, 21 Mar 2024 18:27:34 -0400 [thread overview]
Message-ID: <20240321222733.GJ15722@brightrain.aerifal.cx> (raw)
In-Reply-To: <20240321204014.31675-1-maks.mishinFZ@gmail.com>
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 <maks.mishinFZ@gmail.com>
> ---
> 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
parent reply other threads:[~2024-03-21 22:27 UTC|newest]
Thread overview: expand[flat|nested] mbox.gz Atom feed
[parent not found: <20240321204014.31675-1-maks.mishinFZ@gmail.com>]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240321222733.GJ15722@brightrain.aerifal.cx \
--to=dalias@aerifal.cx \
--cc=maks.mishinfz@gmail.com \
--cc=musl@lists.openwall.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/musl/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).