Subject: Re: ignoring return values from functions.
To: James Graham <greywolf@starwolf.com>
From: Todd Vierling <tv@wasabisystems.com>
List: tech-userlevel
Date: 09/21/2001 01:59:50
On Thu, 20 Sep 2001, James Graham wrote:

: Error checking is one thing.
: Pedantry is another.

: (void) falls into the realm of the latter -- the only thing it makes
: clear to me is that either the programmer or the compilation requirements
: are pedantic to the point of being anal.  I don't hold at all that
: a (void) before the call as opposed to lack of same conjoined with a lack
: of a variable assignment or comparison to said call makes anything at
: all clearer except that the programmer is scared that the compiler's
: going to say something.

: (void) does NOT fall into the category of meaningful error checking;
: if you're error checking something, you're presumably going to write
: the code to handle said error-checking!

A developer for real-time or fault-tolerant systems would shoot you in the
head right about here.  8-)

Lint's purpose is to find problems in robustness of a program, not check its
syntax against standards.  "Robustness" here refers to a more strict
programming *strategy*, not syntax, so that obscure problems don't crop up
because a legal integer conversion accidentally sign-extended an unsigned
value, or a forgotten return value caused a runtime memory leak.

The reason for the warning is that functions which return values normally do
so for a reason.  Any place where a return value is ignored is a robustness
failure.  If you deliberately want to ignore a return value, then the best
style in the name of robust strategy is to (void) cast it; that's why lint
warns about it.

-- 
-- Todd Vierling <tv@wasabisystems.com>  *  Wasabi NetBSD:  Run with it.
-- NetBSD 1.5.2 available on CD-ROM soon!  --  http://www.wasabisystems.com/