Article View: comp.bugs.4bsd
Article #335lint fails to be my friend
From: David Steffens
Date: Wed, 03 Apr 1991 22:05
Date: Wed, 03 Apr 1991 22:05
32 lines
1415 bytes
1415 bytes
When beginning maintenance activities on code that someone else has written,
the first thing I do is to run lint on the code to see what pops out.
This time, lint failed to find something that I think it should have.
Try the following on your favorite flavor of lint. The first four if's
generate "variable may be used before set" complains as expected.
The fifth if statement does not. I think it should. If not, why not??
Tested on 4.2bsd, 4.3bsd, SunOS4.0.3, SunOS4.1 and RTU5.0 (SysV variant).
main()
{
int foo;
int *bar, *blap, *flap;
int baz[10];
if (foo == 0)
printf("Yikes!\n");
if (bar == 0)
printf("Egads!\n");
if (*blap == 0)
printf("Gadzooks!\n");
if (flap[2] == 0)
printf("Ack!\n");
if (baz[2] == 0)
printf("Eh?\n");
exit(0);
}
--
David Allan Steffens | I believe in learning from past mistakes...
Eaton-Peabody Laboratory | ...but does a good education require so many?
Mass. Eye & Ear Infirmary, 243 Charles Street, Boston, MA 02114
{harvard,mit-eddie,think}!eplunix!das (617) 573-3748 (1400-1900h EST)
Technical Details
Message-ID:
<1059@eplunix.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!eplunix!dasShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!rpi!zaphod.mps.ohio-state.edu!think.com!eplunix!das From: das@eplunix.UUCP (David Steffens) Newsgroups: comp.bugs.4bsd Subject: lint fails to be my friend Message-ID: <1059@eplunix.UUCP> Date: 3 Apr 91 22:05:13 GMT Organization: Eaton-Peabody Lab, Boston, MA Lines: 32