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

Isabelle, Francois Francois.Isabelle at ca.kontron.com
Tue Apr 17 08:17:59 EDT 2007


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
>



More information about the splint-discuss mailing list