Why use (void) func() ? (lint beef)

Karl Heuer karl at haddock.ima.isc.com
Mon Oct 8 13:36:43 AEST 1990


In article <151806 at felix.UUCP> asylvain at felix.UUCP (Alvin E. Sylvain) writes:
>In article <12141 at crdgw1.crd.ge.com> volpe at underdog.crd.ge.com (Christopher R Volpe) writes:
>>It fails to warn about ignored return values from *my* routines, and
>>always warns about ignored return values from printf and scanf!
>
>I agree with this assessment of lint...

As I pointed out to Chris V. by email, it's not true that lint distinguishes
between user functions and library functions this way.  And of course lint has
no way of knowing the difference between a critical printf() call and a benign
one, unless you tell it (see my example of enclosing the former in a routine
that *does* check the return value).

>IMHO, lint is a good idea, but it is usually so durnedably
>verbose that I'd rather not bother.  It's a matter (as expressed above)
>of reporting problems one could just as well not hear about.

The particular issue mentioned above is a single item at the bottom of the
lint output--easy enough to visually skip past.  If you're going to complain
about inappropriate lint verbosity, complain about the malloc() bug, which
yields a warning on every call.

In article <1014 at gistdev.gist.com> flint at gistdev.gist.com (Flint Pellett) writes:
>1. An option to ignore extern declarations made in a .h that aren't used.
>   (Ever run lint on something that #includes <curses.h>?  You get to wade
>   through 3 pages of curses routines that were extern'ed but not used.)

Assuming you remember to specify "-lcurses", what you are observing is a bug
in <curses.h> and/or llib-lcurses.  Report it to your vendor.

>   The same goes for declarations I put in my own .h files.
>   Now if I have an extern right there in the file that I haven't used, I
>   want to know about that, but if it's in some .h, who cares?

If the object being declared extern doesn't have a corresponding definition
anywhere, then why does your header declare it?  If a defining declaration
does exist but is not visible to lint (because you're linting only some of the
files), then you should be using the lint options that say so.

Karl W. Z. Heuer (karl at kelp.ima.isc.com or ima!kelp!karl), The Walking Lint



More information about the Comp.lang.c mailing list