Discarded Function Values (To Cast or Not to Cast)

T. William Wells bill at twwells.com
Sat Nov 18 17:23:22 AEST 1989


In article <1989Nov17.154621.2698 at aqdata.uucp> sullivan at aqdata.uucp (Michael T. Sullivan) writes:
: From article <316 at voa3.UUCP>, by ck at voa3.UUCP (Chris Kern):
: > ...  Should I cast the function
: > call to void, or am I just indulging in the trivial luxury of
: > silencing lint?
:
: Although you are merely silencing lint, you are also doing yourself
: a service.  If you start letting warnings like "return value ignored"
: pop up then you will someday miss an real warning/error message that
: is buried amongst the "fake" warning/error messages.  Silence as many
: lint warnings as you can (will somebody PLEASE do something about the
: malloc bugaboo) and the real ones will stand out easily.

I don't worry about lint warnings about functions whose return
value is never used. It is generally a very short list, things
like strcpy and the like, where the return value is never of
interest to me. I use a cast to void when I ignore the return
value of a function whose return value is used elsewhere.

---
Bill                    { uunet | novavax | ankh | sunvice } !twwells!bill
bill at twwells.com



More information about the Comp.lang.c mailing list