Yet Another Lint Foul-up

T. William Wells bill at twwells.uucp
Sun Jan 8 10:35:52 AEST 1989


In article <1298 at tank.uchicago.edu> vevea at paideia.UUCP (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?

Here are the two reasons why one deals with this:

    1) Having put an exit() in the program, you should add
       /*NOTREACHED*/ right after it; this tells lint that you know
       what you are doing.

    2) If you do 1), as you should, getting the lint message means you
       screwed up: you didn't put an exit() or return where it
       belongs.

In short, if you are in the habit of ignoring this particular message,
you should change your habit. Always do 1) and, should you get the
message, investigate and fix the problem.

---
Bill
{ uunet!proxftl | novavax } !twwells!bill



More information about the Comp.lang.c mailing list