I’ve been tasked with seeing if there are any static code analyzers which are as good as Lint but less expensive. We currently use PC-lint on our drivers. Has anyone used something cheaper than that which they would recommend? Or indeed, *not* recommend? Thanks for any feedback on your experiences - M
prefast - see the WDK
Avoid sdv
On Aug 18, 2010 12:59 PM, wrote:
I’ve been tasked with seeing if there are any static code analyzers which
are as good as Lint but less expensive. We currently use PC-lint on our
drivers. Has anyone used something cheaper than that which they would
recommend? Or indeed, not recommend? Thanks for any feedback on your
experiences - M
—
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
Well hopefully you are using PreFast also, and /W4 from the Microsoft
compiler. This will catch many of the items PC-LINT does but far from all
of them. While PC-LINT has gone up in price, it is still a good bargain,
check some of the third party software stores I found some decent discounts
in a couple minutes.
–
Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
wrote in message news:xxxxx@ntdev…
> I’ve been tasked with seeing if there are any static code analyzers which
> are as good as Lint but less expensive. We currently use PC-lint on our
> drivers. Has anyone used something cheaper than that which they would
> recommend? Or indeed, not recommend? Thanks for any feedback on your
> experiences - M
>
>
> Information from ESET NOD32 Antivirus, version of virus
> signature database 5376 (20100818)
>
> The message was checked by ESET NOD32 Antivirus.
>
> http://www.eset.com
>
>
>
Information from ESET NOD32 Antivirus, version of virus signature database 5376 (20100818)
The message was checked by ESET NOD32 Antivirus.
http://www.eset.com
>expensive. We currently use PC-lint on our drivers. Has anyone used something cheaper
PREfast. It’s free.
–
Maxim S. Shatskih
Windows DDK MVP
xxxxx@storagecraft.com
http://www.storagecraft.com
You could also try to use an alternate compiler, to find additional
warnings that your main one doesn’t. I’ve used GCC to find multiple
errors that MSC can’t find.
Thanks guys. Yes, we do use /W4 and PreFast ![]()
Given that you currently use BOTH PreFast and PC-Lint, would you take a few minutes and tell us – from your experience – which types of issues PC-Lint identifies that PreFast does not and vice versa?
I think the comparison would be interesting to a lot of us here.
Peter
OSR
Well, I don’t pretend to be any expert, but roughly…
There is some overlap (for example, they’ll both tell you when they think you’re dereferencing a null pointer) but …
PreFast will tell you things like “this function changed the IRQL but it didn’t change it back” - driver-specific stuff - which PC-lint won’t (*)
whereas PC-Lint is good at telling you things like “you ignored a return value here” or “the destructor of the base class of this class isn’t virtual” - general language stuff but quite detailed. It picks up stuff that PreFast doesn’t.
(*) for all I know it might be possible to make it look for these things, but why would anyone bother when PreFast does it for free?
Thanks Maria.
When I’ve used PC-Lint in the past, I was surprised at all the very cool stuff that it seemed to find. OTOH, I was annoyed by all the spurious noise it generated… but that really IS what these tools are about, isn’t it? Making lots of checks, and making you thoroughly review your coding practices.
Thanks again,
Peter
OSR
+1
mm
-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of
xxxxx@googlemail.com
Sent: Thursday, August 19, 2010 11:50 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Static code analysis : Lint alternatives?
Well, I don’t pretend to be any expert, but roughly…
There is some overlap (for example, they’ll both tell you when they think
you’re dereferencing a null pointer) but …
PreFast will tell you things like “this function changed the IRQL but it
didn’t change it back” - driver-specific stuff - which PC-lint won’t (*)
whereas PC-Lint is good at telling you things like “you ignored a return
value here” or “the destructor of the base class of this class isn’t
virtual” - general language stuff but quite detailed. It picks up stuff that
PreFast doesn’t.
(*) for all I know it might be possible to make it look for these things,
but why would anyone bother when PreFast does it for free?
NTDEV is sponsored by OSR
For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars
To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer
After setting up pc-lint to match your style and wdk conventions which is definitely tedious, it will eliminate false positives and so you will only get clean compiles or real bugs from then after. If Microsoft would just run it on their samples it would clean out some of the bugs in them. Couple useful examples:
* can check every KdPrint parameter which is invaluable since these normally get no type checking at all nor even a check the parameter count is even right which is very error prone during development as these lines are often fiddled with.
* a global wrapup where pc-lint examines all the source files collectively and shows unused things that can be chopped out.
If I want to know if my code is right, I only trust pc-lint results for this. Nothing else holds a candle to it, but to do the best job requires a lot of tedious customization work to tell it about WDK specific things like ExAllocatePoolWithTag is like malloc, KdPrint is like printf, etc, etc.
It would be very nice, and also exceptionally helpful, if you’d share your customizations (the settings file) with the community.
We did this several years back (see http://www.osronline.com/article.cfm?id=143) when Udo Eberhardt (USB guru and founder of Thesycon GmbH) made HIS settings available for folks.
What do you say? It would certainly help A LOT of people… We’d be happy to distribute it on your behalf, with full credit and many thanks, here from OSR Online if that would be helpful and encourage you do it!
Peter
OSR
My lint file is long and has customization that might not be ideally suited to all. Rather than just dump that, below are 7 useful lines anyone would probably wish to cut and paste into their lint file. One could do much more than this, so this is just a sampling. And remember, this is an addition to the zillion things pc-lint does automatically.
-printf( 1, KdPrint )
-printf( 1, DbgPrint )
-printf_code(wZ, UNICODE_STRING *)
-printf_code(ws, WCHAR *)
-function( free, ExFreePool, ExFreePoolWithTag, IoCompleteRequest )
-sem( ExAllocatePoolWithTag, @P == malloc(2n) || @P == 0 )
-sem( PsTerminateSystemThread, r_no )
Explanation:
Line 1 & 2 validate parameters to KdPrint & DbgPrint.
Line 3 & 4 add several WDK specific printf format strings.
Line 5 makes it an error to access an IRP after completing it or accessing freed memory.
Line 6 verifies code is aware NULL can be returned from memory allocation and assures the memory gets freed.
Line 7 flags anything after terminating a thread as dead code.
That’s nice, and definitely useful, thanks… but I was hoping you’d share a “lot of tedious customization.”
Sigh! I wish driver developers had more “community spirit”…
P