NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: bin/53226: cat.c if block never true

The following reply was made to PR bin/53226; it has been noted by GNATS.

From: Robert Elz <kre%munnari.OZ.AU@localhost>
Subject: Re: bin/53226: cat.c if block never true
Date: Sun, 29 Apr 2018 15:45:50 +0700

     Date:        Sun, 29 Apr 2018 04:55:00 +0000 (UTC)
     Message-ID:  <>
   | >Description:
   | If block is never true.
   | -       if (fclose(stdout))
   | +       if (fclose(stdout) != 0)
 Aside from style, which is a matter of personal
 preference, those two lines are identical - nothing
   | It also seems there isn't consensus on the proper check.
   | Should it be (fclose(fd) != 0) or (fclose(fd) == EOF)?
 It makes no difference, 0 and EOF are the only possibilities
 (could also do fclose(fd) < 0 as we "know" EOF == -1 but
 that would not be a good idea.)
 And wrt: said:
   | fclose(3) also indicates that other return values (from close(3) among
   | others) are also possible.  So checking explicitly for EOF would not be
   | correct.
 That is referring to bvalues that can appear in errno, not the result from
 fclose(), so checking == EOF is OK, as is checking for 0.

Home | Main Index | Thread Index | Old Index