[PATCH] Fix stdio init handling
Hans-Peter Nilsson
hp@axis.com
Tue Jun 7 14:40:17 GMT 2022
> From: Torbjorn SVENSSON <torbjorn.svensson@st.com>
> Date: Tue, 7 Jun 2022 08:05:01 +0200
> > FILE *f = fopen("fff", "r");
> > int c = fgetc(f);
> >
> > if (f == NULL)
> > {
> > perror("fopen");
> > abort();
> > }
> >
>
> Unrelated to the patch proposed, but I think you should
> avoid calling fgetc(f) prior to checking if f is NULL or a
> valid pointer.
>
> Kind regards,
> Torbjörn
You're absolutely right, and I am fully aware. I'll
clarify: this was only intended was a quick reproducer of
the problem, not a model program.
brgds, H-P
More information about the Newlib
mailing list