[PATCH 01/15] stdio-common: Don't read real input beyond the field width in scanf [BZ #13988]

Maciej W. Rozycki macro@redhat.com
Tue May 6 15:05:22 GMT 2025


On Tue, 6 May 2025, Andreas Schwab wrote:

> > @@ -1657,7 +1657,8 @@ __vfscanf_internal (FILE *s, const char
> >  			    break;
> >  			  else
> >  			    {
> > -			      if (avail == 0 || inchar () == EOF)
> > +			      if ((avail == 0 && (c = EOF))
> 
> Please avoid assignment in a conditional.

 It is valid C and weighing pros and cons I concluded it'd be the most 
straightforward approach here.  Rewriting this piece such as to avoid the 
inline assignment will make code more complex I'm afraid.

 I might be wrong, so may I ask for a second opinion?

  Maciej



More information about the Libc-alpha mailing list