From srinivas.vutukuri at gmail.com Mon Sep 3 03:57:45 2007 From: srinivas.vutukuri at gmail.com (srinivas naga vutukuri) Date: Mon, 3 Sep 2007 16:27:45 +0530 Subject: [splint-discuss] will the splint checks the boundary condition of for loop logic expression? Message-ID: Hi, Am just trying out this small piece of code whether the splint can check the for loop logic expression boundary check. If you see, the following for loop leads into infinite loop condition. When i tried +inf-loops Or +loop-exec Or +for-loop-exec, i was't given any warnings... Could the splint checks the following kind of areas? I used splint - 3.1.1 version -------snippet--------------------- /*@unused@*/ int f(void) { int i; int j; for (i=0;i<2;) j = 2; return 0; } -------snippet-------------------- Best regards, srinivas. From liranorevi at hotmail.com Tue Sep 4 03:22:41 2007 From: liranorevi at hotmail.com (Liran Orevi) Date: Tue, 4 Sep 2007 10:22:41 +0000 Subject: [splint-discuss] will the splint checks the boundary condition of for loop logic expression? Message-ID: I'm not sure about the use of 'for', but the 'while' eqvivulent: i=0; while (i _________________________________________________________________ Discover the new Windows Vista http://search.msn.com/results.aspx?q=windows+vista&mkt=en-US&form=QBRE From liranorevi at hotmail.com Tue Sep 4 07:58:41 2007 From: liranorevi at hotmail.com (Liran Orevi) Date: Tue, 4 Sep 2007 14:58:41 +0000 Subject: [splint-discuss] will the splint checks the boundary condition of for loop logic expression? In-Reply-To: References: Message-ID: I'm not sure about the use of 'for', but the 'while' eqvivulent (which I'm unable to send) does produce a warning. _________________________________________________________________ Invite your mail contacts to join your friends list with Windows Live Spaces. It's easy! http://spaces.live.com/spacesapi.aspx?wx_action=create&wx_url=/friends.aspx&mkt=en-us From jjose at globo.com Fri Sep 7 09:33:00 2007 From: jjose at globo.com (juan abba) Date: Fri, 07 Sep 2007 13:33:00 -0300 Subject: [splint-discuss] how to satisfy splint on the " global variable" declaration. Message-ID: <46E17D3C.2080209@globo.com> hi I cant find the way to satisfy splint on the " global variable" declaration. I declare a global on the MAIN file, out of any block. on another " C" file, were same variable will be used, I declare it using the " external" keyword before the declaration, but splint don't like it, as follows ================================================================================= teste_anexo.c(17,18): Variable Daa declared more than once A function or variable is declared in more than one place. This is not necessarily a problem, since the declarations are consistent. (Use -redecl to inhibit warning) doubleXlong_main.c(87,8): Previous declaration of Daa ============================================================== if I declare it as extern withing the function I get: ================================================ teste_anexo.c(25,18): Variable Daa shadows outer declaration An outer declaration is shadowed by the local declaration. (Use -shadow to inhibit warning) doubleXlong_main.c(87,8): Previous definition of Daa: double teste_anexo.c(25,22): Declaration using extern inside function scope: double Daa An extern declaration is used inside a function scope. (Use -nestedextern to inhibit warning) ================================================================ of course I can inhibit the warnings, but I wonder which is the way to use "external" correctly and 100% withing the SPLINT criteria?????? thanks in advance juan From raeburn at raeburn.org Fri Sep 7 10:21:13 2007 From: raeburn at raeburn.org (Ken Raeburn) Date: Fri, 7 Sep 2007 13:21:13 -0400 Subject: [splint-discuss] how to satisfy splint on the " global variable" declaration. In-Reply-To: <46E17D3C.2080209@globo.com> References: <46E17D3C.2080209@globo.com> Message-ID: On Sep 7, 2007, at 12:33, juan abba wrote: > I declare a global on the MAIN file, out of any block. > > on another " C" file, were same variable will be used, I declare it > using the " external" keyword before the declaration, but splint don't > like it, as follows Try declaring it in a header file that you include from both source files. Declare it there, and nowhere else. Ken From Michael.Wojcik at MicroFocus.com Fri Sep 7 12:07:15 2007 From: Michael.Wojcik at MicroFocus.com (Michael Wojcik) Date: Fri, 7 Sep 2007 12:07:15 -0700 Subject: [splint-discuss] how to satisfy splint on the " globalvariable" declaration. In-Reply-To: References: <46E17D3C.2080209@globo.com> Message-ID: <11352F9641010A418AD5057945A3A6598B4608@MTV-EXCHANGE.microfocus.com> > From: splint-discuss-bounces at cs.virginia.edu > [mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of > Ken Raeburn > Sent: Friday, 07 September, 2007 13:21 > > On Sep 7, 2007, at 12:33, juan abba wrote: > > I declare a global on the MAIN file, out of any block. > > > > on another " C" file, were same variable will be used, I declare it > > using the " external" keyword before the declaration, but splint don't > > like it, as follows > > Try declaring it in a header file that you include from both > source files. Declare it there, and nowhere else. That produces undefined behavior. An object that is declared with external linkage, but never defined, is not guaranteed to exist: ----- An external definition is an external declaration that is also a definition of a function (other than an inline definition) or an object. If an identifier declared with external linkage is used in an expression (other than as part of the operand of a sizeof operator whose result is an integer constant), somewhere in the entire program there shall be exactly one external definition for the identifier; otherwise, there shall be no more than one. ----- ISO 9899:1999 + Cor1 & Cor2, 6.9 #5 In other words, in addition to the external declaration (which best practice would indeed put in a header), there should be exactly one definition of the object (ie, without the "extern" storage-class specifier) somewhere in the program, unless the object is never used in an expression (other than as the operand of the sizeof operator). This is a semantic rule, not a constraint, so implementations need not issue a diagnostic for it. Per J.2 #1, violating a "shall" requirement outside a constraint produces undefined behavior. (Annex J is informative, not normative, but the same consequence can be derived from Clause 4.) Most implementations, following the original Unix ones, will provide an implicit definition for any object that is declared with external linkage but not defined by the program. But they're not required to. The correct, portable, best practice for global objects is to: - Declare them in a header file using the extern sc-specifier, and include that in all C files that will use the object. - In one C file, add a definition for the object, which should be the same as the declaration except without the extern sc-specifier. Usually there's one C file that conceptually "owns" the global, so that's where the definition typically goes, by convention. For example: ----- foo.h ----- extern int foo; ----- ----- foo.c ----- #include "foo.h" int foo; ----- ----- bar.c ----- #include "foo.h" ----- Some people like to have the header serve both purposes, by changing the declaration into a definition using a macro that's defined in only one C file. That strikes me as just as likely to cause problems as to cure them. -- Michael Wojcik Principal Software Systems Developer, Micro Focus From raeburn at raeburn.org Sat Sep 8 18:19:49 2007 From: raeburn at raeburn.org (Ken Raeburn) Date: Sat, 8 Sep 2007 21:19:49 -0400 Subject: [splint-discuss] how to satisfy splint on the " globalvariable" declaration. In-Reply-To: <11352F9641010A418AD5057945A3A6598B4608@MTV-EXCHANGE.microfocus.com> References: <46E17D3C.2080209@globo.com> <11352F9641010A418AD5057945A3A6598B4608@MTV-EXCHANGE.microfocus.com> Message-ID: <6830694D-CA5C-4542-AC5C-1715AB205D3F@raeburn.org> On Sep 7, 2007, at 15:07, Michael Wojcik wrote: >> From: splint-discuss-bounces at cs.virginia.edu >> [mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of >> Ken Raeburn >> Sent: Friday, 07 September, 2007 13:21 >> >> Try declaring it in a header file that you include from both >> source files. Declare it there, and nowhere else. > > That produces undefined behavior. An object that is declared with > external linkage, but never defined, is not guaranteed to exist: Yes, sorry, you're correct. I wasn't thinking about the definition (which technically includes a declaration as well). There should be one "extern" declaration in one header that is seen everywhere, and one definition; for maximum type-checking, the extern declaration should be in scope where the definition is given, so that the compiler can check consistency between them. (And the header file declaration should use "extern". Omitting it causes use of "common" storage on some systems, but it's not a universal extension, and may result in multiple definitions in some implementations.) Ken From Bob.van.der.Putten at KONE.com Fri Sep 28 08:29:32 2007 From: Bob.van.der.Putten at KONE.com (Putten van der Bob) Date: Fri, 28 Sep 2007 14:29:32 +0200 Subject: [splint-discuss] Char and Int Message-ID: <950490263C4BD711B9E600096B717ECC0D353F01@tnlnts10.nt.kone.com> I wrote the following code: Unsigned char MiniMalInsDuration = 10; Now SPLint say's: Variable MiniMalInsDuration initialized to type int, expects unsigned char: 10 How can I tell SPLint that '10' should be handled as a unsigned char? (Is there some way to easily brows or search The splint-discuss Archives ) With kind regards / Mit freundlichen Gr?ssen B.F.A. van der Putten Engineer D&D KONE Deursystemen BV Accustraat 21 3903 LX Veenendaal Postbus 94 3900 AB Veenendaal * Phone: +31 (0) 318 532 333 * Fax: +31 (0) 318 532 339 * Email: bob.van.der.putten at kone.com * Website: www.kone.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20070928/ff5d0b7c/attachment.html From Francois.Isabelle at ca.kontron.com Fri Sep 28 08:55:12 2007 From: Francois.Isabelle at ca.kontron.com (Isabelle, Francois) Date: Fri, 28 Sep 2007 08:55:12 -0400 Subject: [splint-discuss] Char and Int In-Reply-To: <950490263C4BD711B9E600096B717ECC0D353F01@tnlnts10.nt.kone.com> Message-ID: use an explicit cast ((unsigned char)10) use a macro #define MIN_DUR ((unsigned char)10) , MinDur = MIN_DUR Francois Isabelle Francois.Isabelle at ca.kontron.com Concepteur de logiciel Software designer Kontron Canada L'information contenue dans le pr?sent document est la propri?t? de Kontron Canada inc. et est divulgu?e en toute confidentialit?. Cette information ne doit pas ?tre utilis?e, divulgu?e ? d'autres personnes ou reproduite sans le consentement ?crit explicite de Kontron Canada inc. The information contained in this document is confidential and the sole property of Kontron Canada Inc. It shall not be used, disclosed to others or reproduced without the express written consent of Kontron Canada Inc. -----Original Message----- From: splint-discuss-bounces at cs.virginia.edu [mailto:splint-discuss-bounces at cs.virginia.edu]On Behalf Of Putten van der Bob Sent: 28 septembre, 2007 08:30 To: Splint group (splint-discuss at mail.cs.virginia.edu) Subject: [splint-discuss] Char and Int I wrote the following code: Unsigned char MiniMalInsDuration = 10; Now SPLint say's: Variable MiniMalInsDuration initialized to type int, expects unsigned char: 10 How can I tell SPLint that '10' should be handled as a unsigned char? (Is there some way to easily brows or search The splint-discuss Archives ) With kind regards / Mit freundlichen Gr?ssen B.F.A. van der Putten Engineer D&D KONE Deursystemen BV Accustraat 21 3903 LX Veenendaal Postbus 94 3900 AB Veenendaal * Phone: +31 (0) 318 532 333 * Fax: +31 (0) 318 532 339 * Email: bob.van.der.putten at kone.com * Website: www.kone.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20070928/9488c4df/attachment.html From Francois.Isabelle at ca.kontron.com Fri Sep 28 08:55:12 2007 From: Francois.Isabelle at ca.kontron.com (Isabelle, Francois) Date: Fri, 28 Sep 2007 08:55:12 -0400 Subject: [splint-discuss] Char and Int In-Reply-To: <950490263C4BD711B9E600096B717ECC0D353F01@tnlnts10.nt.kone.com> Message-ID: use an explicit cast ((unsigned char)10) use a macro #define MIN_DUR ((unsigned char)10) , MinDur = MIN_DUR Francois Isabelle Francois.Isabelle at ca.kontron.com Concepteur de logiciel Software designer Kontron Canada L'information contenue dans le pr?sent document est la propri?t? de Kontron Canada inc. et est divulgu?e en toute confidentialit?. Cette information ne doit pas ?tre utilis?e, divulgu?e ? d'autres personnes ou reproduite sans le consentement ?crit explicite de Kontron Canada inc. The information contained in this document is confidential and the sole property of Kontron Canada Inc. It shall not be used, disclosed to others or reproduced without the express written consent of Kontron Canada Inc. -----Original Message----- From: splint-discuss-bounces at cs.virginia.edu [mailto:splint-discuss-bounces at cs.virginia.edu]On Behalf Of Putten van der Bob Sent: 28 septembre, 2007 08:30 To: Splint group (splint-discuss at mail.cs.virginia.edu) Subject: [splint-discuss] Char and Int I wrote the following code: Unsigned char MiniMalInsDuration = 10; Now SPLint say's: Variable MiniMalInsDuration initialized to type int, expects unsigned char: 10 How can I tell SPLint that '10' should be handled as a unsigned char? (Is there some way to easily brows or search The splint-discuss Archives ) With kind regards / Mit freundlichen Gr?ssen B.F.A. van der Putten Engineer D&D KONE Deursystemen BV Accustraat 21 3903 LX Veenendaal Postbus 94 3900 AB Veenendaal * Phone: +31 (0) 318 532 333 * Fax: +31 (0) 318 532 339 * Email: bob.van.der.putten at kone.com * Website: www.kone.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20070928/9488c4df/attachment-0001.html