From brian.quinlan at iolfree.ie Tue Jan 4 09:53:22 2005 From: brian.quinlan at iolfree.ie (Brian Quinlan) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] Using Splint on Linux kernel modules Message-ID: <1104850401.1173.15.camel@dub1-odcl4> Hi, We (Duolog Technologies) use the steps below to use splint on Linux driver code. This works for us on a 2.4.23 kernel. Originally, we started off on a different kernel and when we changed to 2.4.23, it broke a few things. These were easy to fix, but it may indicate that there could be other problems if you try to apply them to other kernel versions. We had to make 3 sets of changes to get splint working for Linux kernel modules: (1) The main problem that we have with using splint for Linux kernel modules is that splint can't parse some of the gcc specific features used by the Linux kernel. To get around this we redefine a few things in our Makefile (see end of email). It is probably not necessary to give splint a definition of all the flags defined by gcc, but it was easier than finding out which ones are actually required. We also redefine asm & __signed__ via our Makefile. See also: http://www.splint.org/pipermail/splint-discuss/2002-December/000002.html (2) We also found it necessary to change the implementation of a few macros (for splint only, not for gcc). This was done by creating and including a file called SplintLinuxKernelHelper.h (see end of email). It must be included (AFTER any kernel headers) in any files where the redefined macros are used. We were lucky that this occurred for relatively few files - those that dealt specifically with Linux. (3) Finally, we had to surround lots of calls to kernel functions with splint annotations because we couldn't put the annotations directly into the kernel headers. This was a little tedious, but fortunately in our case it was restricted to relatively few file and in any case was well worth the tedium because of the number of errors that splint found. (4) We don't use +gnuextensions because it didn't fix anything for us. It might fix a few things for you. (5) It's possible that -sysdirerrors will also help (type "splint -help sysdirerrors" and "splint -help sysdirs"). We haven't had to try it, so it might cause other problems with the kernel code that we're not aware of. See also: http://www.splint.org/pipermail/splint-discuss/2003-January/000025.html Hope this helps someone. I am subscribed to the list, so if I can I'll try to answer questions. Bye, Brian Quinlan Duolog Technologies www.duolog.com ******************************************************************* Makefile: DEFINED_FOR_KERNEL=-D__KERNEL__ -DMODULE ifeq ($(SAVE_TEMPS_ENABLE), TRUE) SAVE_TEMPS=--save-temps SPLINT_KEEP=+keep endif # Splint fails to compile code for the Linux kernel largely because it does # not have some gcc specific features that the kernel code relies on. Defining # a list of FLAGS for splint that gcc defines by default helps with this. # Run "gcc -dM -E - < /dev/null" to see a list of gcc defined symbols. # # Note that __GNUC__ is defined to be 2, not 3, because of problems splint has # when compiling "typedef struct { } spinlock_t;" in . GCC_DEFINED_FLAGS_FOR_SPLINT= \ -D__HAVE_BUILTIN_SETJMP__=1 \ -D__unix__=1 \ -Dunix=1 \ -D__i386__=1 \ -D__SIZE_TYPE__="unsigned int" \ -D__ELF__=1 \ -D__GNUC_PATCHLEVEL__=0 \ -D__linux=1 \ -D__unix=1 \ -D__linux__=1 \ -D__USER_LABEL_PREFIX__ \ -Dlinux=1 \ -D__STDC_HOSTED__=1 \ -D__WCHAR_TYPE__="long int" \ -D__gnu_linux__=1 \ -D__WINT_TYPE__="unsigned int" \ -D__GNUC__=2 \ -D__GXX_ABI_VERSION=102 \ -Di386=1 \ -D__GNUC_MINOR__=2 \ -D__STDC__=1 \ -D__PTRDIFF_TYPE__=int \ -D__tune_i386__=1 \ -D__REGISTER_PREFIX__ \ -D__NO_INLINE__=1 \ -D__i386=1 \ -D__VERSION__="3.2 20020903 (Red Hat Linux 8.0 3.2-7)" # Splint flags # # Don't skip ansi headers because this causes linux/signal.h to be excluded, # which leads to parse errors. # "asm" is redefined as an empty macro because it would otherwise cause # parse errors for splint. SPLINT_FLAGS = $(SPLINT_KEEP) \ -skip-ansi-headers \ $(DEFINED_FOR_KERNEL) \ $(GCC_DEFINED_FLAGS_FOR_SPLINT) \ -Dasm'('w,x,y,z')'="" \ -D__signed__=signed SPLINT=Path to splint executable. SRCS=List of all C source files in your Linux kernel module. INC_FLAGS=List of all include paths (with -I prefix), e.g., -I/usr/src/linux-2.4.23/include -I/my/include/path do_splint: $(SPLINT) $(SPLINT_FLAGS) $(INC_FLAGS) $(SRCS) ******************************************************************* SplintLinuxKernelHelper.h: /* * Filename: $Id: SplintLinuxKernelHelper.h,v 1.2 2004/03/03 18:30:53 bquinl01 Exp $ * Description: Helps splint cope with Linux kernel headers. */ #ifndef __KERNEL__ #error This header should not be included in a non-kernel module. #endif #ifdef S_SPLINT_S #ifdef access_ok #undef access_ok #endif #define access_ok(type, addr, size) (addr = addr, TRUE) #ifdef get_user #undef get_user #endif #define get_user(x, ptr) (x = *ptr, 0) #ifdef put_user #undef put_user #endif #define put_user(x, ptr) (x = *ptr, 0) #ifdef copy_from_user #undef copy_from_user #endif #define copy_from_user(to, from, n) (memcpy(to, from, n), 0) #ifdef copy_to_user #undef copy_to_user #endif #define copy_to_user(to,from,n) (memcpy(to, from, n), 0) #ifdef wait_event_interruptible #undef wait_event_interruptible #endif #define wait_event_interruptible(wq, condition) #ifdef SET_MODULE_OWNER #undef SET_MODULE_OWNER #endif #define SET_MODULE_OWNER(dev) #ifdef module_init #undef module_init #endif typedef void* __splint_module_fptr; #define __splint_module_use_fptr(fn) \ /*@unused@*/ static \ __splint_module_fptr __splint_module_fptr##fn = \ (__splint_module_fptr)fn #define module_init(fn) __splint_module_use_fptr(fn) #ifdef module_exit #undef module_exit #endif #define module_exit(fn) __splint_module_use_fptr(fn) #ifdef MODULE_GENERIC_TABLE #undef MODULE_GENERIC_TABLE #endif #define MODULE_GENERIC_TABLE(gtype,name) \ static const unsigned long __module_##gtype##_size \ __attribute__ ((unused)) = (const unsigned long)sizeof(struct gtype##_id); \ static const struct gtype##_id * __module_##gtype##_table \ __attribute__ ((unused)) = name #ifdef MODULE_DEVICE_TABLE #undef MODULE_DEVICE_TABLE #endif #define MODULE_DEVICE_TABLE(type,name) \ MODULE_GENERIC_TABLE(type##_device,name) #endif /* S_SPLINT_S */ From allug4me at gmail.com Sun Jan 9 23:36:01 2005 From: allug4me at gmail.com (allug4me allug4me) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] using splint for large projects Message-ID: Hi, This is the first time I am using splint. I want to use splint on a large project for e.g. the Linux Kernel. Can someone tell me please how to set up the directories for include files and setting up of libraries. I used the -I option to give the path for the header files, but sometimes I am getting parse error on some of the files on which i run splint. Please help me. Regrads, A.B From brian.quinlan at iolfree.ie Mon Jan 10 07:56:09 2005 From: brian.quinlan at iolfree.ie (Brian Quinlan) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] using splint for large projects In-Reply-To: References: Message-ID: <1105361769.1146.29.camel@dub1-odcl4> Hi, I'm sorry for reposting a rather long email that I sent to the list last week, but the archives don't appear to have been updated since November: http://www.splint.org/pipermail/splint-discuss/ Does anybody know what's up? See end of mail, for a description of how we solved the problems you ask about. Bye, Brian On Mon, 2005-01-10 at 04:36, allug4me allug4me wrote: > Hi, > > This is the first time I am using splint. > I want to use splint on a large project for e.g. the Linux Kernel. > Can someone tell me please how to set up the directories for include > files and setting up of libraries. > I used the -I option to give the path for the header files, but > sometimes I am getting parse error on some of the files on which i run > splint. > > Please help me. > > > Regrads, > A.B > _______________________________________________ > splint-discuss mailing list > splint-discuss@cs.virginia.edu > http://www.splint.org/mailman/listinfo/splint-discuss -----Forwarded Message----- From: Brian Quinlan To: splint-discuss@cs.virginia.edu Subject: Using Splint on Linux kernel modules Date: 04 Jan 2005 14:53:22 +0000 Hi, We (Duolog Technologies) use the steps below to use splint on Linux driver code. This works for us on a 2.4.23 kernel. Originally, we started off on a different kernel and when we changed to 2.4.23, it broke a few things. These were easy to fix, but it may indicate that there could be other problems if you try to apply them to other kernel versions. We had to make 3 sets of changes to get splint working for Linux kernel modules: (1) The main problem that we have with using splint for Linux kernel modules is that splint can't parse some of the gcc specific features used by the Linux kernel. To get around this we redefine a few things in our Makefile (see end of email). It is probably not necessary to give splint a definition of all the flags defined by gcc, but it was easier than finding out which ones are actually required. We also redefine asm & __signed__ via our Makefile. See also: http://www.splint.org/pipermail/splint-discuss/2002-December/000002.html (2) We also found it necessary to change the implementation of a few macros (for splint only, not for gcc). This was done by creating and including a file called SplintLinuxKernelHelper.h (see end of email). It must be included (AFTER any kernel headers) in any files where the redefined macros are used. We were lucky that this occurred for relatively few files - those that dealt specifically with Linux. (3) Finally, we had to surround lots of calls to kernel functions with splint annotations because we couldn't put the annotations directly into the kernel headers. This was a little tedious, but fortunately in our case it was restricted to relatively few file and in any case was well worth the tedium because of the number of errors that splint found. (4) We don't use +gnuextensions because it didn't fix anything for us. It might fix a few things for you. (5) It's possible that -sysdirerrors will also help (type "splint -help sysdirerrors" and "splint -help sysdirs"). We haven't had to try it, so it might cause other problems with the kernel code that we're not aware of. See also: http://www.splint.org/pipermail/splint-discuss/2003-January/000025.html Hope this helps someone. I am subscribed to the list, so if I can I'll try to answer questions. Bye, Brian Quinlan Duolog Technologies www.duolog.com ******************************************************************* Makefile: DEFINED_FOR_KERNEL=-D__KERNEL__ -DMODULE ifeq ($(SAVE_TEMPS_ENABLE), TRUE) SAVE_TEMPS=--save-temps SPLINT_KEEP=+keep endif # Splint fails to compile code for the Linux kernel largely because it does # not have some gcc specific features that the kernel code relies on. Defining # a list of FLAGS for splint that gcc defines by default helps with this. # Run "gcc -dM -E - < /dev/null" to see a list of gcc defined symbols. # # Note that __GNUC__ is defined to be 2, not 3, because of problems splint has # when compiling "typedef struct { } spinlock_t;" in . GCC_DEFINED_FLAGS_FOR_SPLINT= \ -D__HAVE_BUILTIN_SETJMP__=1 \ -D__unix__=1 \ -Dunix=1 \ -D__i386__=1 \ -D__SIZE_TYPE__="unsigned int" \ -D__ELF__=1 \ -D__GNUC_PATCHLEVEL__=0 \ -D__linux=1 \ -D__unix=1 \ -D__linux__=1 \ -D__USER_LABEL_PREFIX__ \ -Dlinux=1 \ -D__STDC_HOSTED__=1 \ -D__WCHAR_TYPE__="long int" \ -D__gnu_linux__=1 \ -D__WINT_TYPE__="unsigned int" \ -D__GNUC__=2 \ -D__GXX_ABI_VERSION=102 \ -Di386=1 \ -D__GNUC_MINOR__=2 \ -D__STDC__=1 \ -D__PTRDIFF_TYPE__=int \ -D__tune_i386__=1 \ -D__REGISTER_PREFIX__ \ -D__NO_INLINE__=1 \ -D__i386=1 \ -D__VERSION__="3.2 20020903 (Red Hat Linux 8.0 3.2-7)" # Splint flags # # Don't skip ansi headers because this causes linux/signal.h to be excluded, # which leads to parse errors. # "asm" is redefined as an empty macro because it would otherwise cause # parse errors for splint. SPLINT_FLAGS = $(SPLINT_KEEP) \ -skip-ansi-headers \ $(DEFINED_FOR_KERNEL) \ $(GCC_DEFINED_FLAGS_FOR_SPLINT) \ -Dasm'('w,x,y,z')'="" \ -D__signed__=signed SPLINT=Path to splint executable. SRCS=List of all C source files in your Linux kernel module. INC_FLAGS=List of all include paths (with -I prefix), e.g., -I/usr/src/linux-2.4.23/include -I/my/include/path do_splint: $(SPLINT) $(SPLINT_FLAGS) $(INC_FLAGS) $(SRCS) ******************************************************************* SplintLinuxKernelHelper.h: /* * Filename: $Id: SplintLinuxKernelHelper.h,v 1.2 2004/03/03 18:30:53 bquinl01 Exp $ * Description: Helps splint cope with Linux kernel headers. */ #ifndef __KERNEL__ #error This header should not be included in a non-kernel module. #endif #ifdef S_SPLINT_S #ifdef access_ok #undef access_ok #endif #define access_ok(type, addr, size) (addr = addr, TRUE) #ifdef get_user #undef get_user #endif #define get_user(x, ptr) (x = *ptr, 0) #ifdef put_user #undef put_user #endif #define put_user(x, ptr) (x = *ptr, 0) #ifdef copy_from_user #undef copy_from_user #endif #define copy_from_user(to, from, n) (memcpy(to, from, n), 0) #ifdef copy_to_user #undef copy_to_user #endif #define copy_to_user(to,from,n) (memcpy(to, from, n), 0) #ifdef wait_event_interruptible #undef wait_event_interruptible #endif #define wait_event_interruptible(wq, condition) #ifdef SET_MODULE_OWNER #undef SET_MODULE_OWNER #endif #define SET_MODULE_OWNER(dev) #ifdef module_init #undef module_init #endif typedef void* __splint_module_fptr; #define __splint_module_use_fptr(fn) \ /*@unused@*/ static \ __splint_module_fptr __splint_module_fptr##fn = \ (__splint_module_fptr)fn #define module_init(fn) __splint_module_use_fptr(fn) #ifdef module_exit #undef module_exit #endif #define module_exit(fn) __splint_module_use_fptr(fn) #ifdef MODULE_GENERIC_TABLE #undef MODULE_GENERIC_TABLE #endif #define MODULE_GENERIC_TABLE(gtype,name) \ static const unsigned long __module_##gtype##_size \ __attribute__ ((unused)) = (const unsigned long)sizeof(struct gtype##_id); \ static const struct gtype##_id * __module_##gtype##_table \ __attribute__ ((unused)) = name #ifdef MODULE_DEVICE_TABLE #undef MODULE_DEVICE_TABLE #endif #define MODULE_DEVICE_TABLE(type,name) \ MODULE_GENERIC_TABLE(type##_device,name) #endif /* S_SPLINT_S */ From PRumble at ndsuk.com Mon Jan 10 10:41:07 2005 From: PRumble at ndsuk.com (Rumble, Phil) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] How do I find out what error splint is reporting Message-ID: <0EBB60C00763BA43BE535F213D568CFA81AB64@ukex04.uk.nds.com> Hello, I have recently integrated splint into the build system my company uses. My next task is to start turning off unwanted errors/warnings from splint. Is there any quick way of finding out what exact error is being reported so I can suppress it if so desired. Thanks in Advance Rumble ======================================================= Information contained in this email message is intended only for use of the individual or entity named above. If the reader of this message is not the intended recipient, or the employee or agent responsible to deliver it to the intended recipient, you are hereby notified that any dissemination, distribution or copying of this communication is strictly prohibited. If you have received this communication in error, please immediately notify us by email to postmaster@ndsuk.com and destroy the original message. From evans at cs.virginia.edu Mon Jan 10 10:49:22 2005 From: evans at cs.virginia.edu (David Evans) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] How do I find out what error splint is reporting In-Reply-To: <0EBB60C00763BA43BE535F213D568CFA81AB64@ukex04.uk.nds.com> References: <0EBB60C00763BA43BE535F213D568CFA81AB64@ukex04.uk.nds.com> Message-ID: <41E2A402.5060905@cs.virginia.edu> If you use the +forcehints flag, splint will include a message with each warning explaining what flag controls that message. --- Dave Rumble, Phil wrote: >Hello, > >I have recently integrated splint into the build system my company uses. > >My next task is to start turning off unwanted errors/warnings from splint. > >Is there any quick way of finding out what exact error is being reported so I can suppress it if so desired. > > >Thanks in Advance > >Rumble > > From cbfalconer at yahoo.com Mon Jan 10 11:49:42 2005 From: cbfalconer at yahoo.com (CBFalconer) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] How do I find out what error splint is reporting References: <0EBB60C00763BA43BE535F213D568CFA81AB64@ukex04.uk.nds.com> Message-ID: <41E2B225.4D893AC2@yahoo.com> "Rumble, Phil" wrote: > > I have recently integrated splint into the build system my company > uses. My next task is to start turning off unwanted errors/warnings > from splint. Is there any quick way of finding out what exact error > is being reported so I can suppress it if so desired. You can annotate your sources, but that is an ugly solution. I would suggest using only the weakest splint controls in your builds, and that in fact you may be better off just using the facilities of the compiler proper. At any rate, for splint operation I keep the following aliases in effect here (using 4dos under w98). The command splint is highly critical, splinthd is extremely critical, splintit corresponds with most normal usage, and splintwk is extremely weak. The '^' in the aliases is a statement separator. c:\>alias | grep splint splint=setsplint ^ c:\prgs\splint\splint-3.0.1.6\bin\splint.exe setsplint=set larch_path=.;c:\prgs\splint\splint-3.0.1.6\lib ^ set include=c:\djgpp\include splintit=splint -predassign -predboolint -nullret -boolops +charintliteral splintwk=splint -weak splinthd=splint -strict -- Chuck F (cbfalconer@yahoo.com) (cbfalconer@worldnet.att.net) Available for consulting/temporary embedded and systems. USE worldnet address! From evans at cs.virginia.edu Mon Jan 10 13:11:55 2005 From: evans at cs.virginia.edu (David Evans) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] using splint for large projects In-Reply-To: <1105361769.1146.29.camel@dub1-odcl4> References: <1105361769.1146.29.camel@dub1-odcl4> Message-ID: <41E2C56B.40008@cs.virginia.edu> Thanks for noticing the problem with the archive. This is fixed now. The December 2004 and January 2005 archives are now available at http://www.splint.org/pipermail/splint-discuss/ --- Dave Brian Quinlan wrote: >Hi, >I'm sorry for reposting a rather long email that I sent to the list last >week, but the archives don't appear to have been updated since November: > >http://www.splint.org/pipermail/splint-discuss/ > >Does anybody know what's up? > >See end of mail, for a description of how we solved the problems you ask >about. > >Bye, >Brian > > From sheep at atos.wmid.amu.edu.pl Wed Jan 12 17:21:15 2005 From: sheep at atos.wmid.amu.edu.pl (Radomir Dopieralski) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] Annotated libraries Message-ID: <20050112222115.GA21232@atos.wmid.amu.edu.pl> I was wondering whether there is a source for splint-annotated headers for popular libraries? For example, I want to use glib in my project, but splint produces so many warnings, that I'd have to throw away either glib or splint. Annotated headers would, probably, help to solve this. -- Radomir @**@_ Bee! Create your own computer role playing `The Sheep' ('') 3 game using the great H-World engine! Dopieralski .vvVvVVVVVVvVVvv.v. http://h-world.simugraph.com/ From lists at connectionbrazil.com Thu Jan 13 08:08:26 2005 From: lists at connectionbrazil.com (Gerhard Fiedler) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] Annotated libraries In-Reply-To: <20050112222115.GA21232@atos.wmid.amu.edu.pl> References: <20050112222115.GA21232@atos.wmid.amu.edu.pl> Message-ID: > I was wondering whether there is a source for splint-annotated headers > for popular libraries? > > For example, I want to use glib in my project, but splint produces so > many warnings, that I'd have to throw away either glib or splint. > > Annotated headers would, probably, help to solve this. As a workaround, you could try to add the offending headers to the sys-dirs option and then tell splint to skip the sys-headers: -sys-dirs +skip-sys-headers Gerhard From spam_account at sympatico.ca Fri Jan 14 13:55:12 2005 From: spam_account at sympatico.ca (spam_account@sympatico.ca) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] Unused assignments? Message-ID: I have a file with a unneeded assignment. In turn, the variable is never used. Ie, it just gets assigned values but those values are never used. I didn't see this discussed previously only the list although I have been using search tools and may not have the right key word to search on. Here is an example, [bpringle@localhost bpringle]$ cat foo.c int main(void) { int value; value = 10; return 0; } [bpringle@localhost bpringle]$ ../src/splint-3.0.1.6/src/splint -strict foo.c Splint 3.0.1.6 --- 27 Mar 2003 Finished checking --- no warnings Is there some flag I can turn on to get a warning about useless assignments? I see from some other posts that splint may not do enough flow analysis to determine that an assignment is useless. I also tried the +noeffect, but that was noted as redundant. My experience is that code like this shows that some one did not look closely at the routine (even if the used assignment is fine). thanks, Bill Pringlemeir. From evans at cs.virginia.edu Fri Jan 14 14:58:29 2005 From: evans at cs.virginia.edu (David Evans) Date: Wed Mar 22 17:10:50 2006 Subject: [splint-discuss] Unused assignments? In-Reply-To: References: Message-ID: <41E82465.8050906@cs.virginia.edu> spam_account@sympatico.ca wrote: > I have a file with a unneeded assignment. In turn, the variable is > never used. Ie, it just gets assigned values but those values are > never used. > Sorry, splint does not report these problems. It should, but there is no way to get the current version of splint to report them. --- Dave From luke.w.imhoff at medtronic.com Fri Jan 14 16:10:10 2005 From: luke.w.imhoff at medtronic.com (Imhoff, Luke) Date: Wed Mar 22 17:10:51 2006 Subject: [splint-discuss] Unused assignments? Message-ID: <59B9CBBED6EBDF4CB84259EEC828129D1270B5@MSPM1BMSGM14.ent.core.medtronic.com> We have all compiler warnings turned on (and set as errors). The compiler normally spots this thing for us. Let the compiler spot things like this and use splint for things the compiler can't catch. -----Original Message----- From: splint-discuss-bounces@cs.virginia.edu [mailto:splint-discuss-bounces@cs.virginia.edu]On Behalf Of spam_account@sympatico.ca Sent: Friday, January 14, 2005 12:55 PM To: splint-discuss@cs.virginia.edu Subject: [splint-discuss] Unused assignments? I have a file with a unneeded assignment. In turn, the variable is never used. Ie, it just gets assigned values but those values are never used. I didn't see this discussed previously only the list although I have been using search tools and may not have the right key word to search on. Here is an example, [bpringle@localhost bpringle]$ cat foo.c int main(void) { int value; value = 10; return 0; } [bpringle@localhost bpringle]$ ../src/splint-3.0.1.6/src/splint -strict foo.c Splint 3.0.1.6 --- 27 Mar 2003 Finished checking --- no warnings Is there some flag I can turn on to get a warning about useless assignments? I see from some other posts that splint may not do enough flow analysis to determine that an assignment is useless. I also tried the +noeffect, but that was noted as redundant. My experience is that code like this shows that some one did not look closely at the routine (even if the used assignment is fine). thanks, Bill Pringlemeir. _______________________________________________ splint-discuss mailing list splint-discuss@cs.virginia.edu http://www.splint.org/mailman/listinfo/splint-discuss