mailing list of musl libc
 help / color / mirror / code / Atom feed
* [musl] Re: [PATCH] vfscanf: Remove if-condition with unused value
       [not found] <20240321204014.31675-1-maks.mishinFZ@gmail.com>
@ 2024-03-21 22:27 ` Rich Felker
  0 siblings, 0 replies; only message in thread
From: Rich Felker @ 2024-03-21 22:27 UTC (permalink / raw)
  To: Maks Mishin; +Cc: musl

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2024-03-21 22:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240321204014.31675-1-maks.mishinFZ@gmail.com>
2024-03-21 22:27 ` [musl] Re: [PATCH] vfscanf: Remove if-condition with unused value Rich Felker

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).