NO

Author Topic: Splint  (Read 18513 times)

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Splint
« Reply #15 on: August 27, 2009, 07:36:17 AM »
I use splint.exe from this package:
http://lclint.cs.virginia.edu/downloads/binaries/splint-3.1.1.win32.zip

SplintTest.c
Code: [Select]
#define WIN32_DEFAULT_LIBS
#include <windows.h>

splintrc.ini
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 #####

Result:
Code: [Select]
Splint 3.1.1 --- 12 April 2003

C:\Progra~1\PellesC6\include\Win\winnt.h: (in function MemoryBarrier)
C:\Progra~1\PellesC6\include\Win\winnt.h(2728,42): Variable Barrier declared but not used
  A variable is declared but never used. Use /*@unused@*/ in front of declaration to suppress message. (Use -varuse to inhibit warning)
< Location unknown >: Field name reused:
  Code cannot be parsed.  For help on parse errors, see splint -help parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of
C:\Progra~1\PellesC6\include\Win\winnt.h: (in function RtlSecureZeroMemory)
C:\Progra~1\PellesC6\include\Win\winnt.h(4973,12): Test expression for while not BOOL, type SIZE_T: cnt
  Test expression type is not boolean or int. (Use -predboolint to inhibit warning)
C:\Progra~1\PellesC6\include\Win\winnt.h(4973,19): Assignment of int to char: *vptr = 0
  Types are incompatible. (Use -type to inhibit warning)
C:\Progra~1\PellesC6\include\Win\winnt.h(4975,12): Implicitly temp storage ptr returned as implicitly only: ptr
  Temp storage (associated with a formal parameter) is transferred to a non-temporary reference. The storage may be released or new aliases created. (Use -temptrans to inhibit warning)
< Location unknown >: Previous use of
< Location unknown >: Previous use of

Finished checking --- 5 code warnings
*** Program return 1 ***
May the source be with you

JohnF

  • Guest
Re: Splint
« Reply #16 on: August 27, 2009, 08:38:33 AM »
Yes that's a better splint.exe. Using your splintrc settings I get this for FindFile.c

Code: [Select]
Splint 3.1.1 --- 12 April 2003

D:\PellesC\Projects\Findfile_Uni\find.h(6,1): Macro WIN32_LEAN_AND_MEAN already defined
  Command Line: Previous definition of WIN32_LEAN_AND_MEAN
< Location unknown >: Field name reused:
  Code cannot be parsed.  For help on parse errors, see splint -help parseerrors. (Use -syntax to inhibit warning)
< Location unknown >: Previous use of
< Location unknown >: Previous use of
< Location unknown >: Previous use of
< Location unknown >: Previous use of
D:\PellesC\Projects\Findfile_Uni\FindFile.c(54,31): Static g_strDepends initialized to null value: g_strDepends = NULL
  A reference with no null annotation is assigned or initialized to NULL.  Use /*@null@*/ to declare the reference as a possibly null pointer. (Use -nullassign to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(54,31): Static g_strDepends initialized to null value: TCHAR * g_strDepends = NULL = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(65,45): Static pSubClassPictureBoxProc initialized to null value: pSubClassPictureBoxProc = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(65,45): Static pSubClassPictureBoxProc initialized to null value: WNDPROC pSubClassPictureBoxProc = NULL = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(66,43): Static pSubClassTextBoxProc initialized to null value: pSubClassTextBoxProc = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(66,43): Static pSubClassTextBoxProc initialized to null value: WNDPROC pSubClassTextBoxProc = NULL = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(67,47): Static pSubClassRenameEditBoxProc initialized to null value: pSubClassRenameEditBoxProc = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(67,47): Static pSubClassRenameEditBoxProc initialized to null value: WNDPROC pSubClassRenameEditBoxProc = NULL = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(68,43): Static pSubClassExtPaneProc initialized to null value: pSubClassExtPaneProc = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(68,43): Static pSubClassExtPaneProc initialized to null value: WNDPROC pSubClassExtPaneProc = NULL = NULL
D:\PellesC\Projects\Findfile_Uni\FindFile.c(93,19): Initializer block for g_dlg has 5 fields, but RD has 8 fields: 1, 3, 320, 203, 1
  Initializer does not set every field in the structure. (Use -fullinitblock to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(94,19): Initializer block for g_bk has 4 fields, but RD has 8 fields: 3, 4, 80, 204
D:\PellesC\Projects\Findfile_Uni\FindFile.c: (in function CallBackProc)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(138,23): Initializer block for lvI has 1 field, but LVITEMA has 10 fields: 0
D:\PellesC\Projects\Findfile_Uni\FindFile.c(142,12): New fresh storage (type HWND) passed as implicitly temp (not released): GetDlgItem(g_hwndMain, 2)
  A memory leak has been detected. Storage allocated locally is not released before the last reference to it is lost. (Use -mustfreefresh to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(142,3): Return value (type HWND) ignored: SetFocus(GetDlgI...
  Result returned by function call is not used. If this is intended, can cast result to (void) to eliminate message. (Use -retvalother to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(147,34): New fresh storage (type HWND) passed as implicitly temp (not released): (GetDlgItem(g_hwndMain, 153))
D:\PellesC\Projects\Findfile_Uni\FindFile.c(149,3): Implicitly only storage lvI.pszText (type LPSTR) not released before assignment: lvI.pszText = NULL
  A memory leak has been detected. Only-qualified storage is not released before the last reference to it is lost. (Use -mustfreeonly to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(151,3): Return value (type LRESULT) ignored: SendDlgItemMessa...
D:\PellesC\Projects\Findfile_Uni\FindFile.c(157,28): Passed storage s not completely defined (*s is undefined): LoadStringA (..., s, ...)
  Storage derivable from a parameter, return value or global is not defined. Use /*@out@*/ to denote passed or returned storage which need not be defined. (Use -compdef to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(157,3): Return value (type int) ignored: LoadStringA(g_hI...
  Result returned by function call is not used. If this is intended, can cast result to (void) to eliminate message. (Use -retvalint to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(159,10): Parameter 1 (g_sGen0) to function strcat is declared unique but may be aliased externally by parameter 2 ((TCHAR *)name)
  A unique or only parameter may be aliased by some other parameter or visible global. (Use -mayaliasunique to inhibit warning)
D:\PellesC\Projects\Findfile_Uni\FindFile.c(160,3): Return value (type LRESULT) ignored: SendDlgItemMessa...
D:\PellesC\Projects\Findfile_Uni\FindFile.c(167,9): Parse Error. (For help on parse errors, see splint -help parseerrors.)
*** Cannot continue.
*** Program return 1 ***

Thanks for your input.

John