[splint-discuss] How to check Uninitialized variable
Vijayendra Suman
vijayendra.suman at gmail.com
Tue May 12 04:22:44 PDT 2009
Hello All,
Thanks for the prompt response,
Here is the small piece of code this is compilable
1 #include <stdio.h>
2 void Call(int *a)
3 {
4 int StatusUpdate;
5 int MyOne()
6 {
7 printf("One \n");
8 return 1;
9 }
10 int MyTwo()
11 {
12 printf("Two \n");
13 return 2;
14 }
15 if (a==NULL) return;
16 if (*a == 1 )
17 StatusUpdate = MyOne();
18 else
19 StatusUpdate = MyTwo();
20 }
21
22 int main(int argc, char * argv[])
23 {
24 int call; /* call is not initialized */
25 Call(&call);
26 return 0;
27 }
I compiled using
gcc -o my my.c -Wall
Problem definition:
int call; /* call is not initialized */
The call variable is not initialized, Even with -Wall i do not get any
warnings.
This is a problem as it may have any value. I want to make sure there are no
such problems in my code which i can detect through the static analyzer.
I have tried using splint i get the following problem when i invoked splint
[root at localhost vijay]# splint -compdef 1.c
Splint 3.1.2 --- 13 Nov 2008
1.c:6:6: Parse Error. (For help on parse errors, see splint -help
parseerrors.)
*** Cannot continue.
I am not sure about this problem.
Splint :
Do we have some flags in splint which can detect this kind of errors,
specially in such case
16 if (*a == 1 )
This line is a problem.
If there is some flags, that will be fine or if it is needed to done i can
start with it.
With Sincere Regards
Vijayendra Suman
On Tue, May 12, 2009 at 4:03 PM, Ludolf Holzheid <
lholzheid at bihl-wiedemann.de> wrote:
> On Tue, 2009-05-12 15:06:08 +0530, Vijayendra Suman wrote:
> > [..]
> >
> > Do we have a mechanism to check such kind of errors with splint tool.
>
> Hmm.
>
> I tried to run your code snippet through splint. Among other messages
> it gave:
>
> > y.c(17,7): 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)
>
> Do you think this is wrong? Or what's your exact 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
>
--
https://mail.google.com/mail/?ui=2&view=bsp&ver=1qygpcgurkovy
Regards
Vijayendra Suman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20090512/a3fd54bb/attachment-0003.html
More information about the splint-discuss
mailing list