questions from using lint

Rex Ballard rb at ccird2.UUCP
Wed Apr 16 04:17:34 AEST 1986


In article <7097 at cca.UUCP> dewitt at cca.UUCP (Mark DeWitt) writes:
>*** REPLACE THIS LINE WITH YOUR MESSAGE ***
>I have three questions, the first of which was only brought to my
>attention by lint, not caused by it.  The code in question works under BSD4.2
>on both vaxes and suns.
>
>1.  I have code with declarations that look like the following:
>	struct tm *zulu, *gmtime();
>
>but I forgot to #include <sys/time.h> at the top.  Pretty careless,
>but what is remarkable is that I never noticed until I ran lint on
>it.  WHY DID THIS COMPILE SUCCESSFULLY?
>The lint message was:
>warning: structure tm never defined

If you did not attempt to access any of the structure members,
the compiler would just "fudge" the pointer.  If the pointer pointed
to an odd address, the execution would have bombed.  Compilers are
often very forgiving (I have one that exepts newlines as statement
terminators, but lint bombs from the syntax errors).

>
>3.  How do you get lint to shut up about variable numbers of arguments
>with stdio functions like printf, scanf, etc.?  I tried using /*VARARGS*/
>right, left, and sideways to no avail.  The doc is not great, but you
>knew that already.

The /*VARARGS*/ escape has to be put just before the code that defines
the function. ie:
/*VARARGS1*/
printf(s,p) char *s; int p; { int i; return(i) };

this should have been done when your lintlib was created.  You may
need to re-create the lintlib.  There are usually skeleton definitions
in the same directory as the lintlib (4.2).  V7 had these declarations
in source form only.

>After three years of C programming I'm just starting to use lint, so
>please no negative reinforcement by flaming about how stupid my questions
>are, lest I give up on it entirely :-).

YAHOO!!!  GOOD FOR YOU!!! :-).
You have taken a good step into the realm of clean, portable code.
We've cut our debug time by 60-70% doing this, and reduced maintenance
costs as well.  There is really no justification for not using lint.



More information about the Comp.lang.c mailing list