Yet Another Lint Foul-up

Andrew Duane duane at cg-atla.UUCP
Sat Jan 7 00:44:54 AEST 1989


In article <1298 at tank.uchicago.edu>, vevea at paideia.uchicago.edu (Jack L. Vevea) writes:
> 
> 	I've passively watched the discussion of lint's problems with
>   exit(0) from main(), and find myself wondering why it matters.  I use
>   lint to check my code, but I've gotten into the habit of automatically
>   ignoring certain output, including 'warning:  main() returns a random
>   value to the invocation environment.'  Being primarily a psychometrician,
>   and not a professional C (or any other language) programmer, I find myself
>   wondering if some of you out there are working under conditions in which
>   some higher authority requires you to produce a clean lint run as 
>   evidence of good coding.  Otherwise, it would seem to me that any
>   concern with the message would be evidence of your being a slave to
>   lint; why else be concerned when you _know_ that the warning is
>   inconsequential?

But sometimes the exit value of a program is important. I
regularly use many shell scripts that require correct (and
explicit) exit codes. Also, the system() library routine
returns (in a contorted fashion) the exit code of the program;
thus other programs can depend on it. GREP is a good example of
this.

If "main() returns a random value to the invocation environment"
then these scripts may break unpredictably; worse, they may
WORK unpredictably. And you never know when some little helper
program may be used in such a script. Big programs are not
immune, either. Someday, someone may want to wrap up that huge
database program in a little helper script for novices, and
need that exit value.

Andrew L. Duane (JOT-7)  w:(508)-658-5600 X5993  h:(603)-434-7934
Compugraphic Corp.			 decvax!cg-atla!duane
200 Ballardvale St.		       ulowell/ \laidback
Wilmington, Mass. 01887		   cbosgd!ima/   \cgeuro
Mail Stop 200II-3-5S		     ism780c/     \wizvax

Only my cat shares my opinions, and she hasn't returned to the
invocation environment yet.



More information about the Comp.lang.c mailing list