lint question

T. William Wells bill at twwells.uucp
Wed Jan 11 01:39:31 AEST 1989


In article <491 at babbage.acc.virginia.edu> pts at watt.acc.Virginia.EDU (Paul T. Shannon) writes:
: I've been following the lint discussion, and decided it was high
: time for me to use lint myself.  Here's a question for style experts:
: Lint complains:
:
: function returns value which is always ignored
:     fprintf       printf
:
: Is it bad style to use these functions without also checking the
: returned value?

The return values of the printf family functions are not very
consistently defined. Because of this, one should never use their
return value.  You have to do the checking of printf before the
printf executes, i.e., either at the time you write the code or in
the code itself before the printf executes. (Except that I/O errors
need to be checked sometime after a flush has need done.  But that is
another can of worms entirely, caused by standard I/O buffering.)

I just ignore the lint message. On the other hand, if it said that
the function values were *sometimes* ignored, I'd go hunting for the
portability problem caused by using the return value.

---
Bill
{ uunet!proxftl | novavax } !twwells!bill



More information about the Comp.lang.c mailing list