[splint-discuss] How to check Uninitialized variable
Jonathan and Caroline Moore
jandcmoore at gmail.com
Tue May 12 06:00:30 PDT 2009
I get the same result with Splint 3.1.2 --- 07 May 2008. A complaint
when not initialized, no complaint when initialized.
Jonathan
2009/5/12 Ludolf Holzheid <lholzheid at bihl-wiedemann.de>:
> On Tue, 2009-05-12 16:52:44 +0530, Vijayendra Suman wrote:
>> Hello All,
>>
>> Thanks for the prompt response,
>>
>> Here is the small piece of code this is compilable
>> [..]
>
> If you move the nested functions out of Call() like this:
>
>>> #include <stdio.h>
>>>
>>> static int MyOne(void)
>>> {
>>> printf("One \n");
>>> return 1;
>>> }
>>>
>>> static int MyTwo(void)
>>> {
>>> printf("Two \n");
>>> return 2;
>>> }
>>>
>>> static void Call(int *a)
>>> {
>>> int StatusUpdate;
>>> if (a==NULL) return;
>>> if (*a == 1 )
>>> StatusUpdate = MyOne();
>>> else
>>> StatusUpdate = MyTwo();
>>> }
>>>
>>> int main(void)
>>> {
>>> int call; /* call is not initialized */
>>> Call(&call);
>>> return 0;
>>> }
>
> and run the result through splint, you will get the following:
>
>>> $ /c/Program\ Files/splint-3.1.1/bin/splint y.c
>>> Splint 3.1.1 --- 12 April 2003
>>>
>>> y.c: (in function main)
>>> y.c(28,8): Passed storage &call not completely defined: Call (&call)
>>> 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)
>>>
>>> Finished checking --- 1 code warning
>
> That is, splint _does_ complain about using 'call' without prior
> initialization.
>
> Does this answer your question?
>
> Ludolf
>
> --
>
> ---------------------------------------------------------------
> Ludolf Holzheid Tel: +49 621 339960
> Bihl+Wiedemann GmbH Fax: +49 621 3392239
> Floßwörthstraße 41 e-mail: lholzheid at bihl-wiedemann.de
> D-68199 Mannheim, Germany
> ---------------------------------------------------------------
>
> _______________________________________________
> splint-discuss mailing list
> splint-discuss at mail.cs.virginia.edu
> http://www.cs.virginia.edu/mailman/listinfo/splint-discuss
>
--
Jonathan (and Caroline)
Jonathan and Caroline Moore
JandCMoore at gmail.com (Jonathan)
CandJMoore at gmail.com (Caroline)
http://jandcmoore.googlepages.com/
More information about the splint-discuss
mailing list