[splint-discuss] DIR *dire storage created but not released??

Michael Wojcik Michael.Wojcik at MicroFocus.com
Fri Nov 7 10:09:17 PST 2008


> From: splint-discuss-bounces at cs.virginia.edu [mailto:splint-discuss-
> bounces at cs.virginia.edu] On Behalf Of Greg White
> Sent: Thursday, 06 November, 2008 20:17
> To: splint-discuss at mail.cs.virginia.edu
> 
> I ran splint on some source code that compiles with no errors using -
> Wall and works great.  I get:
> 
> main.c:29: Include file  matches the name of a POSIX library, but the
> POSIX library is not being used.  Consider using +posixlib or
>     +posixstrictlib to select the POSIX library, or -warnposix to
> suppress this message.

Splint is in effect a C implementation. It provides its own version of
the C standard library, and when you include a header from the standard
library Splint skips it and applies its own definitions, based on the
standard.

Similarly, Splint comes with its own set of POSIX definitions, based on
the standard. That message is telling you that you should have told
Splint that you were using POSIX functionality, by specifying +posixlib
(or +posixstrictlib for stricter checking). That way, Splint can apply
its knowledge of POSIX to your program.

This is described in the Splint documentation:

http://splint.org/manual/html/sec14.html

> main.c: (in function findfiles)
> main.c:79:2: Fresh storage dire not released before return
>   A memory leak has been detected. Storage allocated locally is not
> released before the last reference to it is lost. (Use -mustfreefresh
> to inhibit warning)
>    main.c:58:3: Fresh storage dire created
> 
> As you can see I close what I open, but splint still sees a memory
> leak.  Can splint be educated about closedir so I don't get this
error?

Try running with +posixlib, as Splint suggested.

> Yes I could do -mustfreefresh to suppress the error but I would rather
> have splint fixed.

You haven't shown that Splint is broken yet, so asking for a fix is a
bit premature.

Note that if you continue to get the warning even when Splint is running
in the correct mode, you can always suppress the error just for this one
case using code annotations. See the manual.

-- 
Michael Wojcik
Principal Software Systems Developer, Micro Focus




More information about the splint-discuss mailing list