<<< Date Index >>>     <<< Thread Index >>>

Re: your mail



On Thu, Jul 10, 2008 at 09:10:46AM -0500, agriffis@xxxxxxxxx wrote:
> Clean up error handling in mutt_copy_header
> 
> mutt_copy_header unnecessarily tests the result of each fputc/fputs (well, 
> most
> of them anyway, it's not consistent).  This obfuscates the code and hides 
> bugs.
> Remove these extraneous checks since ferror/feof are checked at the bottom of
> the function, and get rid of all the early returns.

You also want to add a fflush() before testing ferror().

Interestingly lint will complain if you don't test (or cast away) the
result of fprintf().  Since fprintf() will only fail if the stdio
buffer fills and the write() fails, almost all calls can never fail
(unless bufferring is disabled).  The write() call happens during
fclose() - which probably can't return an appropriate error.
So if you care about the result of the fprintf() calls, you need
to do fflush(); ferror(); fclose().
(Testing ferror() in a loop might be useful in order to abort early.)

        David

-- 
David Laight: david@xxxxxxxxx