[splint-discuss] How to check Uninitialized variable

Vijayendra Suman vijayendra.suman at gmail.com
Tue May 12 21:54:57 PDT 2009


Hello Sebastian,

> Two problems:
> 1. You use sometimes use not a real blank (0x20) but a chracter that
> looks like a blank (0xa0).
>
> 2. In C it is not allowed to definie functions inside other
> functions.  I did not even know gcc accepts this.
>


1. I am not sure about this character '0xa0', I used vim editor for this, I
am not sure how come such characters come in a standard vim editor, I will
check with this problem.
I think dos2unix utility should be able to convert this kind of issue, if
all it is there.

2. I use gcc my o/p for gcc -v is

[root at localhost vijay]# gcc -v
Using built-in specs.
Target: i386-redhat-linux
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--enable-checking=release --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions
--enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk
--disable-dssi --enable-plugin
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-1.5.0.0/jre
--enable-libgcj-multifile --enable-java-maintainer-mode
--with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-cpu=generic
--host=i386-redhat-linux
Thread model: posix
gcc version 4.1.2 20070925 (Red Hat 4.1.2-33)

I also tried with another version of gcc on my other system with gcc version


[root at suman_linux vijay]# gcc -v
Reading specs from /usr/lib/gcc/i386-redhat-linux/3.4.6/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --with-system-zlib --enable-__cxa_atexit
--disable-libunwind-exceptions --enable-java-awt=gtk
--host=i386-redhat-linux
Thread model: posix
gcc version 3.4.6 20060404 (Red Hat 3.4.6-8)

This also compiles the code perfectly fine with

gcc -o my my.c -O -Wall

Many of open source C projects have been using this functionality example
glibc...., Also it may be used where we need to call common functions with
different definition.
Please, have a look at this part of code

#include <stdio.h>
static void Call(int *a)
{
 int StatusUpdate;
 int MyOne()
 {
  return 1;
 }
 if (a==NULL) return;
 if (*a == 1 )
   StatusUpdate = MyOne();
 else
   StatusUpdate = (*a);
}

int main()
{
 int call; /* call is not initialized */
 int MyOne()
 {
  return 2;
 }
 Call( &call);
 MyOne();
 return 0;
}

Again this gives me a error  with splint

[root at suman_linux vijay]# splint 1.c
Splint 3.1.1 --- 15 Jun 2004

1.c:6:3: Parse Error. (For help on parse errors, see splint -help
parseerrors.)
*** Cannot continue.

Sincere Regards
Vijayendra Suman


On Tue, May 12, 2009 at 5:28 PM, Sebastian Waschik <sebastian.waschik at gmx.de
> wrote:

> Hello,
>
> Vijayendra Suman <vijayendra.suman at gmail.com> writes:
> > 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         {
>
> Two problems:
> 1. You use sometimes use not a real blank (0x20) but a chracter that
> looks like a blank (0xa0).
>
> 2. In C it is not allowed to definie functions inside other
>   functions.  I did not even know gcc accepts this.
>
>
> With cleanup a get the following messages.  Source code follows.
>
> Greetings from Hamburg
> Sebastian Waschik
>
>
> Splint 3.1.1 --- 21 Apr 2006
>
> test.c: (in function main)
> test.c:26: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)
> test.c:23:14: Parameter argc not used
>  A function parameter is not used in the body of the function. If the
> argument
>  is needed for type compatibility or future plans, use /*@unused@*/ in the
>  argument declaration. (Use -paramuse to inhibit warning)
> test.c:23:27: Parameter argv not used
> test.c:2:5: Variable exported but not used outside test: StatusUpdate
>  A declaration is exported, but not used outside this module. Declaration
> can
>  use static qualifier. (Use -exportlocal to inhibit warning)
> test.c:3:5: Function exported but not used outside test: MyOne
>   test.c:7:1: Definition of MyOne
> test.c:8:5: Function exported but not used outside test: MyTwo
>   test.c:12:1: Definition of MyTwo
> test.c:14:6: Function exported but not used outside test: Call
>   test.c:21:1: Definition of Call
>
>
> #include <stdio.h>
> int StatusUpdate;
> int MyOne()
> {
>  printf("One \n");
>  return 1;
> }
> int MyTwo()
> {
>  printf("Two \n");
>  return 2;
> }
>
> void Call(int *a)
> {
>  if (a==NULL) return;
>  if (*a == 1 )
>    StatusUpdate = MyOne();
>  else
>    StatusUpdate = MyTwo();
> }
>
> int main(int argc, char * argv[])
> {
>  int call; /* call is not initialized */
>   Call(&call);
>   return 0;
> }
>
> _______________________________________________
> 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/20090513/0686b31b/attachment-0001.html 


More information about the splint-discuss mailing list