EmbeddedRelated.com
Forums

PC Lint vs. splint

Started by JeanneP November 23, 2004
I'm trying to decide which static checker to recommend, and deciding 
between PC Lint (which costs some cash) and splint (which costs setup 
time).  Does anyone here have experience with both, and can comment 
on their preference?

Has anyone been so dissatisfied with splint that they switched to 
PC Lint, and did PC Lint solve the problem(s) that caused the 
dissatisfaction?

I have a more specific question, too, for users of PC Lint. I was just 
browsing the mailing list archives for splint, and found a mention 
where splint will complain about the following:
>>>
UINT8 n; static foo(void) { n = 5; } <<< because 5 is an int instead of an unsigned 8 bit int. Workarounds for this in the code are just ugly style wise, like casting (which may hide a real problem) or assigning n = '\0x05'. When that warning is turned off, a valid warning is also surpressed, as in this case:
>>>
UINT8 n; UINT16 k; static foo(void) { n = k; } <<< How does PC Lint handle these cases? Thanks, Jeanne (not my real email address - this account was set up long ago)
"JeanneP" <jpetrang@harris.com> wrote in message 
news:8e5676f9.0411231043.4df47f0a@posting.google.com...
> I'm trying to decide which static checker to recommend, and deciding > between PC Lint (which costs some cash) and splint (which costs setup > time). Does anyone here have experience with both, and can comment > on their preference? > > Has anyone been so dissatisfied with splint that they switched to > PC Lint, and did PC Lint solve the problem(s) that caused the > dissatisfaction? >
If you need c++ then PC Lint is the only option that I found so I didn't go too far down the splint route. Peter
On 23 Nov 2004 10:43:47 -0800, jpetrang@harris.com (JeanneP) wrote:

>I'm trying to decide which static checker to recommend, and deciding >between PC Lint (which costs some cash) and splint (which costs setup >time). Does anyone here have experience with both, and can comment >on their preference
PC-lint is an awesome tool, and cheap. Splint (lclint) is a good tool, and free. If you want to lint C++, PC-lint will do a good job of this. AFAIK, splint is C only.
> >Has anyone been so dissatisfied with splint that they switched to >PC Lint, and did PC Lint solve the problem(s) that caused the >dissatisfaction?
FWIW, I've used PC-lint for years (since the late 1980's), and have only played with lclint (precursor to splint), so I may not be the responder you're looking for.
> >I have a more specific question, too, for users of PC Lint. I was just >browsing the mailing list archives for splint, and found a mention >where splint will complain about the following: >>>> >UINT8 n; > >static foo(void) { > n = 5; >} ><<< > >because 5 is an int instead of an unsigned 8 bit int. Workarounds for
I would be surprised if splint flagged that. Have you tried it? At a PPOE I used a compiler that would flag extern void fn(unsigned char); fn(0); because converting the int (0) to unsigned char might lose significant bits. But that (and your example) are beyond picky -- they're just plain wrong.
>this in the code are just ugly style wise, like casting (which may >hide a real problem) or assigning n = '\0x05'. When that warning is
Assuming you mean '\x05'... That wouldn't make sense because '\x05' is every bit as much an int as 5 is.
>turned off, a valid warning is also surpressed, as in this case: > >>>> >UINT8 n; >UINT16 k; > >static foo(void) { > n = k; >} ><<< > >How does PC Lint handle these cases?
Here is a slightly modified version of your test code runt through PC-lint:
>>>--- begin included file ---
C:\Dave>type ltst.c typedef unsigned char UINT8; typedef unsigned short UINT16; UINT8 n, m; UINT16 k; static foo(void) { m = 5; n = k; } C:\Dave>lint-nt -u ltst.c PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004 --- Module: ltst.c _ static foo(void) { ltst.c 7 Info 808: No explicit type given symbol 'foo', int assumed _ n = k; ltst.c 9 Info 734: Loss of precision (assignment) (16 bits to 8 bits) _ } ltst.c 10 Warning 533: function 'foo(void)' should return a value (see line 7) ltst.c 7 Info 830: Location cited in prior message --- Wrap-up for Module: ltst.c Warning 528: Symbol 'foo(void)' (line 7, file ltst.c) not referenced ltst.c 7 Info 830: Location cited in prior message
>>>--- end included file ---
The "-u" option specifies a "unit lint," so messages such as "no main" are suppressed. Note I had to add the typedefs. The "m=5" line did not generate a message, but "n=k" did. Also note the fact that foo was declared with implicit int was noted, as well as the fact it does not return a value, and was not used, even though declared static. Making some slight modifications produces this result:
>>>--- begin included file ---
C:\Dave>type ltst.c typedef unsigned char UINT8; typedef unsigned short UINT16; UINT8 n, m; UINT16 k; void foo(void) { m = 5; n = k & 0xFF; } C:\Dave>lint-nt -u ltst.c PC-lint for C/C++ (NT) Ver. 8.00q, Copyright Gimpel Software 1985-2004 --- Module: ltst.c C:\Dave>
>>>--- end included file ---
I.e., no messages. PC-lint is smart enough to see you've purposely chopped off the MSB of k before storing it in n, so it generates no message. A cast would work as well. Two features that set PC-lint apart from splint (or any other lint AFAIK) are its customization features and its flexibility in selectively suppressing messages. The former is indidpensible when dealing with compilers for small embedded targets (dealing with things like in-line assembly and special syntax for I/O registers). The latter lets you suppress a message for an entire lint session, a single file, between a particular pair of braces, on a single line, within a single expression, or for a set of symbols. I can expand on this if you're interested. Also see www.gimpel.com for more info. Regards, -=Dave -- Change is inevitable, progress is not.
"Dave Hansen" <iddw@hotmail.com> wrote in message
news:41a38a44.1142687859@News.individual.net...
> On 23 Nov 2004 10:43:47 -0800, jpetrang@harris.com (JeanneP) wrote: > >I have a more specific question, too, for users of PC Lint. I was just > >browsing the mailing list archives for splint, and found a mention > >where splint will complain about the following: > >>>> > >UINT8 n; > > > >static foo(void) { > > n = 5; > >} > ><<< > > > >because 5 is an int instead of an unsigned 8 bit int. Workarounds for > > I would be surprised if splint flagged that. Have you tried it?
I did, and indeed, splint complains about it. Splint also complains about things like "if (n < 5)" when n is unsigned. Meindert
On 2004-11-23, Dave Hansen <iddw@hotmail.com> wrote:

> I would be surprised if splint flagged that. Have you tried it?
I have, and it does unless you tell it to consider all integer types equivalent. As was posted earlier, that then disable warnings for things like this: uint8_t b; uint32_t l; [...] b = l;
> because converting the int (0) to unsigned char might lose > significant bits. But that (and your example) are beyond > picky -- they're just plain wrong.
I thought so when I posted it to the splint mailing list. Nobody really seemed to care.
>>this in the code are just ugly style wise, like casting (which >>may hide a real problem) or assigning n = '\0x05'. When that >>warning is > > Assuming you mean '\x05'... > > That wouldn't make sense because '\x05' is every bit as much an int as > 5 is.
Splint doesn't think so.
>>UINT8 n; >>UINT16 k; >> >>static foo(void) { >> n = k; >>} >>How does PC Lint handle these cases? > > Here is a slightly modified version of your test code runt through > PC-lint: > > Note I had to add the typedefs. The "m=5" line did not generate a > message, but "n=k" did.
That's what a reasonable person would expect. That's not what split does. It considers the two lines sematically equivalent since '5' is an 'int'. You either get warnings on both or neither. At the point where splint generates the warning, the only information left is that the RHS was an 'INT'. It has discarded the information that it was a literal that will fit into 8 bits. To get reasonable behavior from splint would require extensive modifications.
> Also see www.gimpel.com for more info. Regards,
Last time I checked the Unix versions were hideously expensive, but I should check again. -- Grant Edwards grante Yow! ... Get me a GIN at and TONIC!!...make it visi.com HAIR TONIC!!
On 2004-11-23, Meindert Sprang <mhsprang@NOcustomSPAMware.nl> wrote:
> "Dave Hansen" <iddw@hotmail.com> wrote in message > news:41a38a44.1142687859@News.individual.net... >> On 23 Nov 2004 10:43:47 -0800, jpetrang@harris.com (JeanneP) wrote: >> >I have a more specific question, too, for users of PC Lint. I was just >> >browsing the mailing list archives for splint, and found a mention >> >where splint will complain about the following: >> >>>> >> >UINT8 n; >> > >> >static foo(void) { >> > n = 5; >> >} >> ><<< >> > >> >because 5 is an int instead of an unsigned 8 bit int. Workarounds for >> >> I would be surprised if splint flagged that. Have you tried it? > > I did, and indeed, splint complains about it. Splint also complains about > things like "if (n < 5)" when n is unsigned.
Yup. IMO, splint is pretty much useless unless. You either have to disable so many warnings that it lets bugs through, or you have to put in a half-dozen typecasts in every line of code. The sheer unreadability of the latter will probably create more bugs than turning off the warnings. -- Grant Edwards grante Yow! I think my CAREER at is RUINED!! visi.com
On 2004-11-23, Grant Edwards <grante@visi.com> wrote:

>> Also see www.gimpel.com for more info. Regards, > > Last time I checked the Unix versions were hideously > expensive,
Yup, still is. A node locked copy ofr Windows is $240, a node locked copy for Linux is $1000. What a bunch of maroons... -- Grant Edwards grante Yow! This ASEXUAL at PIG really BOILS visi.com my BLOOD... He's so... so... URGENT!!
On 23 Nov 2004 23:06:10 GMT, Grant Edwards <grante@visi.com> wrote:

>On 2004-11-23, Grant Edwards <grante@visi.com> wrote: > >>> Also see www.gimpel.com for more info. Regards, >> >> Last time I checked the Unix versions were hideously >> expensive, > >Yup, still is. A node locked copy ofr Windows is $240, a node >locked copy for Linux is $1000. What a bunch of maroons...
Maroons? That's a bit harsh, though I have never understood their FlexeLint pricing, even if it is distributed in source form. Note, however, the Windoze version includes DOS and OS/2 binaries, and the Win32 version is a console app. I have seen speculation it could run in DOSEMU or wine or something similar. Never tried it myself, though. They have a 30-day money back guarantee... Regards, -=Dave -- Change is inevitable, progress is not.
On 2004-11-24, Dave Hansen <iddw@hotmail.com> wrote:

>>>> Also see www.gimpel.com for more info. Regards, >>> >>> Last time I checked the Unix versions were hideously >>> expensive, >> >>Yup, still is. A node locked copy ofr Windows is $240, a node >>locked copy for Linux is $1000. What a bunch of maroons... > > Maroons? That's a bit harsh,
Really? I'll have to pay attention to my Bugs Bunny cartoons closer -- I didn't think it was a very harsh term.
> though I have never understood their FlexeLint pricing, even > if it is distributed in source form.
The fact that it's in obfuscated source files doesn't increase the value to the customer, so why should the price be higher? The attitude that an app for Linux should cost 5X the price for the same app on XP (a much more expensive system both SW-wise and HW-wise) seems quite silly and outdated. Just the type of thing that would cause Bugs to exclaim "What a maroon!" I'm also alergic to node-locked stuff. I've been burned too many times when a motherboard, disk drive, or whatnot died and I had to cough up a pile of cash for the privledge of running a program I already paid for once.
> Note, however, the Windoze version includes DOS and OS/2 > binaries, and the Win32 version is a console app. I have seen > speculation it could run in DOSEMU or wine or something > similar.
Probably so. I'm sure it would run under Win4Lin, but it's a lot of hassle either way and exceeds my pain threshold. Cranking up the warnings on gcc does a fair job.
> Never tried it myself, though. They have a 30-day > money back guarantee...
-- Grant Edwards grante Yow! Is this my STOP?? at visi.com
jpetrang@harris.com (JeanneP) wrote:


>I'm trying to decide which static checker to recommend, and deciding >between PC Lint (which costs some cash) and splint (which costs setup >time). Does anyone here have experience with both, and can comment >on their preference? > >Has anyone been so dissatisfied with splint that they switched to >PC Lint, and did PC Lint solve the problem(s) that caused the >dissatisfaction?
At the time I started contracting for a new client, I was a PC Lint user. I needed to lint the client's code looking for (among other things) header files that were included without necessity. Not wanting the client to pay for PC Lint, I decided to try splint. After a moderately length setup session, I discovered that (to my knowledge) splint does not report such things (unused header files). Having discovered that, and being unimpressed with splint in general compared to PC Lint, I recommended that the client purchase PC Lint and after others evaluated it also, they ended up with a site license. I don't think you can go wrong with PC Lint. IMHO, it's small price is worth it compared to what I've experienced of the free stuff. -- Dan Henry