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

Keith Prickett keithp at marvell.com
Mon Apr 16 20:09:45 EDT 2007


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




More information about the splint-discuss mailing list