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

Ludolf Holzheid lholzheid at bihl-wiedemann.de
Wed Apr 18 16:21:28 EDT 2007


On Wed, 2007-04-18 09:10:50 -0700, Keith Prickett wrote:
> [..]
> I am just not seeing where "listOfMyOwnType" may become null.
> [..]

Keith,

I think the problem is, splint knows listOfMyOwnType[1] being NULL and
warns about this fact. However, there seems to be no code annotation
for the object a pointer points to. i.e., if you write the prototype
for initializeItem1() as follows:

 void initializeItem1 (/*@null@*/ MY_OWN_TYPE **arg);

you allow **arg to be NULL, but *arg still has to be non-NULL (unless
**art is NULL, of course).

In your case, you want initializeItem1() to _return_ *arg in **arg, so
you should explain _this_ to splint:

 void initializeItem1 (/*@out@*/ MY_OWN_TYPE **arg);

In this case, *arg may be NULL or even undefined.

HTH,

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
---------------------------------------------------------------



More information about the splint-discuss mailing list