[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: CVS commit: src/usr.bin/patch
On Fri, Aug 15, 2008 at 10:34:40AM +0200, Christoph Badura wrote:
> On Mon, Aug 11, 2008 at 09:54:23PM +0100, David Laight wrote:
> > Better is to to close the file with the sequence:
> > fflush(outfile);
> > err = ferror(outfile);
> > fclose(outfile);
> > if (err != 0)
> > ...
> The fflush() is redundant. fclose() fflushes the stream anyway. So you
> should probably check:
> if (fclose(outfile) == EOF)
> warn("error closing outfile");
The point is to call ferror() after the last write(2) to the file.
Since ferror() returns a 'sticky' error indication it tells you
whether any of the previous writes to the file failed.
David Laight: david%l8s.co.uk@localhost
Main Index |
Thread Index |