NO

Author Topic: Splint  (Read 16087 times)

JohnF

  • Guest
Splint
« on: August 20, 2009, 08:56:11 AM »
Has anyone managed to get Splint working, specifically when using windows headers?

It would be a good additional tool to have.

Splint is a tool for statically checking C programs for security vulnerabilities and coding mistakes.

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Splint
« Reply #1 on: August 23, 2009, 08:22:29 AM »
I found this from net:
http://www.splint.org/vc.splintrc
.splintrc
Code: [Select]
-I.
-D_M_IX86=400
-DWIN32
-D_NTSYSTEM
-D_WIN32_WINNT=0x0400
-DWINVER=600
-DNOGDI
-DNOKERNEL
-DNOUSER
-DWIN32_LEAN_AND_MEAN
-likelybool
-D__int64=long
-D_int64=int
-D_wtoi=atoi
-DSTRICT
May the source be with you

JohnF

  • Guest
Re: Splint
« Reply #2 on: August 23, 2009, 11:16:54 AM »
Thanks, yes I have that one.

I've managed to compile a version of Splint, it's huge, for me anyway. Have changed the way it loads its .splintrc to be splint.flags - seems more reasonable.

The .splintrc file (or splint.flags) btw has to be in the folder where splint is testing, not in the bin folder which is what I thought at first.

I've added -DHWND=void to that splintrc list that you showed.

Anyway, it's a good tool but getting it to accept windows headers will not be easy.

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Splint
« Reply #3 on: August 24, 2009, 07:04:55 AM »
Can you put that splint.exe and those PellesC projectfiles to your homesite ?
May the source be with you

JohnF

  • Guest
Re: Splint
« Reply #4 on: August 24, 2009, 08:26:27 AM »
The Splint.exe requires splint.flags to be in the folder you are testing which you will find in the bin folder..

The project on my site is here


http://www.johnfindlay.plus.com/pellesc/splint-3.0.1.6-2.win32.zip


I have removed many files that were gcc specific, the original package can be had from here


http://www.splint.org/downloads/binaries/splint-3.0.1.6-2.win32.zip


EDIT: for anyone interested - set up splint.exe to be called as a tool form the IDE. Set it to capture the output from splint.exe.

Arguments example - $(FileDir)\*.c

John
« Last Edit: August 24, 2009, 08:39:39 AM by JohnF »

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Splint
« Reply #5 on: August 25, 2009, 12:53:59 PM »
I'm now testing Splint 3.1.1
From: http://lclint.cs.virginia.edu/downloads/binaries/splint-3.1.1.win32.zip

In PellesC IDE Tools:

Menu text:  Splint-3.1.1
Command:   C:\CODE\Splint-3.1.1\bin\Splint.exe
Arguments: $(FilePath)  -f C:\CODE\Splint-3.1.1\bin\.splintrc

Use output tab

Result using windef.h :

Splint 3.1.1 --- 12 April 2003

C:\Program Files\PellesC6\Include\Win\winnt.h(3012,13):
    Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
*** Program return 1 ***

May the source be with you

JohnF

  • Guest
Re: Splint
« Reply #6 on: August 25, 2009, 02:12:41 PM »
Yes that's the problem.

If you try it on an C files that doesn't use any windows stuff it should be ok.

>>Arguments: $(FilePath)  -f C:\CODE\Splint-3.1.1\bin\.splintrc

However I'm not sure why you are calling up the .splintrc file, you should be testing a C file. Or have I misunderstood?

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Splint
« Reply #7 on: August 25, 2009, 02:37:30 PM »
>>Arguments: $(FilePath)  -f C:\CODE\Splint-3.1.1\bin\.splintrc

This way you don't have to worry about that working directory.
May the source be with you

JohnF

  • Guest
Re: Splint
« Reply #8 on: August 25, 2009, 03:10:42 PM »
>>Arguments: $(FilePath)  -f C:\CODE\Splint-3.1.1\bin\.splintrc

This way you don't have to worry about that working directory.


But you need to tell it where the C files are.

Arguments - $(FileDir)\*.c

Slpnit.exe will look in that folder for the .splintrc automatically.

John

Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Splint
« Reply #9 on: August 25, 2009, 03:17:58 PM »
>>Arguments: $(FilePath)  -f C:\CODE\Splint-3.1.1\bin\.splintrc

This way you don't have to worry about that working directory.
But you need to tell it where the C files are.

Arguments - $(FileDir)\*.c

Slpnit.exe will look in that folder for the .splintrc automatically.
I think the -f switch is keeping you from the need to copy the configuration file to any folder containing source code to check, which in turn keeps it simple to update the settings if needed and check again.

No littering of the disk too.
---
Stefan

Proud member of the UltraDefrag Development Team

JohnF

  • Guest
Re: Splint
« Reply #10 on: August 25, 2009, 03:22:42 PM »
Oh, ok.

Of course you might want different splintrc files for different projects.

John


Offline Stefan Pendl

  • Global Moderator
  • Member
  • *****
  • Posts: 582
    • Homepage
Re: Splint
« Reply #11 on: August 25, 2009, 03:29:57 PM »
Since this is a .rc file it is a UNIX utility, where you usually have the following order of precedence for .rc files:
  • application installation folder
  • system configuration folder
  • executing user home folder
  • current working folder

For Windows the developer has to make sure to search for system-wide, user-specific and location-specific setting files.
---
Stefan

Proud member of the UltraDefrag Development Team

JohnF

  • Guest
Re: Splint
« Reply #12 on: August 25, 2009, 03:48:01 PM »
Since this is a .rc file it is a UNIX utility, where you usually have the following order of precedence for .rc files:
  • application installation folder
  • system configuration folder
  • executing user home folder
  • current working folder

For Windows the developer has to make sure to search for system-wide, user-specific and location-specific setting files.


Thanks for the information, I know nothing of Unix.

John

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2091
Re: Splint
« Reply #13 on: August 26, 2009, 01:13:00 PM »
http://lclint.cs.virginia.edu/downloads/binaries/splint-3.1.1.win32.zip
http://www.cs.virginia.edu/pipermail/splint-discuss/2006-May/000772.html
This config goes thru windows.h in PellesC 6 and i can check my own code too.
Code: [Select]
##### BEGIN .splintrc #####

-booltype BOOL

#naming

#-globalprefix g_
#+globalprefixexclude

#includes

-I.
-IC:\Progra~1\PellesC6\include
-IC:\Progra~1\PellesC6\include\Win

#Visual Studio .NET

-D_M_IX86=600
-DWIN32
-D_WIN32
-D_NTSYSTEM
-D_WIN32_WINNT=0x0400
-DWINVER=600
-DNOGDI
-DNOKERNEL
-DNOUSER
-DWIN32_LEAN_AND_MEAN
-likelybool
-D__int64=long
-D_int64=int
#-DHWND=void
-D_wtoi=atoi
-DSTRICT
-D__try=
-D__except(x)=
-Dlint
-DGetExceptionCode()=1
-noret
-nullret

-larchpath C:\CODE\Splint-3.1.1\lib
-lclimportdir C:\CODE\Splint-3.1.1\imports
-linelen 255

##### END .splintrc #####
Edit 2009-08-27: import -> imports
« Last Edit: August 27, 2009, 07:29:45 AM by timovjl »
May the source be with you

JohnF

  • Guest
Re: Splint
« Reply #14 on: August 26, 2009, 01:38:58 PM »
I'm sure you have improved things but I get

------------------------------------------
D:\PellesC\Projects\pro\pro.c(24,1): Macro WIN32_LEAN_AND_MEAN already defined
  (0): Previous definition of WIN32_LEAN_AND_MEAN
D:\PellesC\Include\Win\winnt.h(2255,33): Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
*** Program return 1 ***
-------------------------------------------

The second error in winnt.h is this line.

    RtlApplicationVerifierStop((Code), \

I'll have to make time to study all the options.

Thanks.

John
« Last Edit: August 26, 2009, 02:18:26 PM by JohnF »