[splint-discuss] Dependency on run time function

Ludolf Holzheid lholzheid at bihl-wiedemann.de
Sun Mar 30 03:14:08 PST 2008


On Sun, 2008-03-30 12:24:10 +0530, Vishal Bayskar wrote:
> Dear All,
> 
> In my program a variable is initializing by read command
> 
> As
> 
> len = read (sockfd, &hdr, sizeof (HEADER));
> 
> Here hdr is a structure 
> sockfd is a socket descriptor
> 
> And after this line of code I am using a member of hdr 
> 
> As
> hdr.member == 2
> 
> And Splint is showing warning
> 
> Field hdr.member used before definition
>   An rvalue is used that may not be initialized to a value on some execution
>   path. (Use -usedef to inhibit warning)
> 
> 
> I think as hdr initializing at runtime that's why splint is not recognizing that hdr is initialized and giving the warning

No. Splint is a static code checker and does not run the code.

For some reasons, splint thinks hdr is possibly not initialized, maybe
due to the wrong library has been selected (e.g. standard instead of
POSIX) and thus splint does not know the second argument to read() is
an /*@out*/ parameter.

> [..]
> Same in case of gettimeofday()

gettimeofday() is not even POSIX. You'll have to specify the UNIX
library to get this function declared for splint.

> [..]
> How does it behave for functions that really depend upon runtime?

Again, splint does not run the code. For the functions declared in its
libraries, it knows which calling parameter is /*@in@*/ and which is
/*@out@*/ (besides other annotations). Other functions have to be
annotated in the sources to be checked.

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