🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.misc
Article #6044

Re: Yet Another Lint Foul-up

#6044
From: Guy Harris
Date: Fri, 06 Jan 1989 18:13
49 lines
2393 bytes
>	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.'

Sometimes messages like this may *not* be inconsequential; it's probably
better to tweak your code to eliminate as many such messages as
possible, rather than to ignore them.

>  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.

At Sun, the kernel is expected to pass "lint"; the "-h", "-b", "-x", and
"-n" flags are used, and the only messages removed (with "grep -v") are

	struct/union <XXX> never defined

and

	possible pointer alignment problem

Many times I have been *V*E*R*Y* grateful that "lint" caught coding
errors in my, and other people's, code before I tested a kernel.

>  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?

Because, as noted, the message may *not* be inconsequential; a program
that

	1) falls off the end of "main"

and

	2) is used in a context where exit statuses are checked

may screw up.  Consider some program used in a Makefile, for instance;
if it randomly returns a non-zero exit status, and you haven't told
"make" to keep going if that command fails, your Makefile will fail. 
Yes, this really happens.

Since it's quite easy to make the complaint go away (e.g. by sticking
/*NOTREACHED*/ after the call to "exit"), it's better to do so than to
filter the complaints out.
Technical Details
Message-ID: <806@auspex.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!auspex!guy
References: <1298@tank.uchicago.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!attcan!uunet!auspex!guy
From: guy@auspex.UUCP (Guy Harris)
Newsgroups: comp.lang.misc,comp.lang.c,comp.lang.c++
Subject: Re: Yet Another Lint Foul-up
Keywords: Idle curiosity.
Message-ID: <806@auspex.UUCP>
Date: 6 Jan 89 18:13:11 GMT
References: <1298@tank.uchicago.edu>
Reply-To: guy@auspex.UUCP (Guy Harris)
Followup-To: comp.lang.c
Organization: Auspex Systems, Santa Clara
Lines: 49