Re: [PATCH] Fix stdio init handling
Hans-Peter Nilsson <[email protected]>
| Newsgroups | gmane.comp.lib.newlib |
|---|---|
| Message-ID | <[email protected]> |
> From: Torbjorn SVENSSON <[email protected]> > 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