Re: head(1): check for stdio errors

2022-02-07 Thread Todd C . Miller
On Sun, 06 Feb 2022 23:41:26 -0600, Scott Cheloha wrote: > > On Feb 6, 2022, at 20:07, Todd C. Miller wrote: > > > > Since the input is opened read-only I don't see the point in checking > > the fclose() return value. However, if you are going to do so, you > > might as well combine it with

Re: head(1): check for stdio errors

2022-02-06 Thread Scott Cheloha
> On Feb 6, 2022, at 20:07, Todd C. Miller wrote: > > Since the input is opened read-only I don't see the point in checking > the fclose() return value. However, if you are going to do so, you > might as well combine it with the ferror() check. E.g. > >if (ferror(fp) || fclose(fp) ==

Re: head(1): check for stdio errors

2022-02-06 Thread Todd C . Miller
Since the input is opened read-only I don't see the point in checking the fclose() return value. However, if you are going to do so, you might as well combine it with the ferror() check. E.g. if (ferror(fp) || fclose(fp) == EOF) { warn("%s", name); status

head(1): check for stdio errors

2022-02-06 Thread Scott Cheloha
Add missing stdio error checks to head(1): - Output errors are terminal. The output is always stdout. - Input errors yield a warning and cause the program to fail gracefully. - Restructure the getc(3)/putchar(3) loop in head_file() to accomodate checking for errors. ok? P.S.