[splint-discuss] Help on "Storage x may become null" error

Keith Prickett keithp at marvell.com
Tue Apr 17 13:22:07 EDT 2007


Even if I add /*@null@*/ in front of the line: "MY_OWN_TYPE *
listOfMyOwnType[2];" I still see the same warnings, plus some.  This
splint warning just doesn't make sense to me.  I have declared a list of
pointers.  The list itself will never be null.  The items in the list
may be, but how does splint want me to deal with that?


--
Keith Prickett


-----Original Message-----
From: splint-discuss-bounces at cs.virginia.edu
[mailto:splint-discuss-bounces at cs.virginia.edu] On Behalf Of Isabelle,
Francois
Sent: Tuesday, April 17, 2007 5:18 AM
To: Discussions about the Splint annotation-assisted static
analysisproject; splint-discuss at ares.cs.Virginia.EDU
Subject: RE: [splint-discuss] Help on "Storage x may become null" error

It's not an error. As you sais, the item _may_ be null, and it instructs
you to specify /*@null@*/ annotations for items that may become null. 

This can be added to return types, parameter types and  variable
declaration

/*@null@*/ void*  function(/*@null@*/ void * ptr)

/*@null@*/ void* listofvoid[2];



Francois Isabelle


>-----Original Message-----
>From: splint-discuss-bounces at cs.virginia.edu
>[mailto:splint-discuss-bounces at cs.virginia.edu]On Behalf Of Keith 
>Prickett
>Sent: 16 avril, 2007 20:10
>To: splint-discuss at ares.cs.Virginia.EDU
>Subject: [splint-discuss] Help on "Storage x may become null" error
>
>
>I've got code that looks kind of like this:
>
>-----------------
>typedef struct
>{
>  int a;
>  int b;
>  char c;
>} MY_OWN_TYPE;
>
>static MY_OWN_TYPE gAType;
>
>void init( void )
>{
>
>  // create a list of my own types
>  MY_OWN_TYPE * listOfMyOwnType[2];
>
>
>  // initialize item 0 to non-null value  listOfMyOwnType[0] = &gAType;

> // initialize item 1 to null value  listOfMyOwnType[1] = NULL;
>
>
>  // initializes item 1 to non-null value  initializeItem1( 
> &listOfMyOwnType[1] );  // ensure value is not null  ASSERT( NULL != 
> listOfMyOwnType[1] );
>
>  // pass list to function who wants list  useMyOwnList( 
> listOfMyOwnType );
>
>
>  return;
>}
>----------------------------
>First, Splint says: Possibly null storage listOfMyOwnType[] derivable 
>from parameter
>     useMyOwnList (..., listOfMyOwnType, ...)...
>Why would it say that?  If it's what I think it is (complaining that a 
>particular item _may_ be null), then how can I say that each of the 
>items individually can be null.
>
>Second, Splint is reporting that Storage listOfMyOwnType[] may become 
>null on the line where item 0 is assigned to the address of a static 
>global.  Why is it complaining about that?  It seems like that would 
>NEVER become null.
>
>Thanks,
>
>--
>Keith Prickett
>
>
>_______________________________________________
>splint-discuss mailing list
>splint-discuss at ares.cs.Virginia.EDU
>http://www.cs.Virginia.EDU/mailman-2.1.5/listinfo/splint-discuss
>

_______________________________________________
splint-discuss mailing list
splint-discuss at ares.cs.Virginia.EDU
http://www.cs.Virginia.EDU/mailman-2.1.5/listinfo/splint-discuss



More information about the splint-discuss mailing list