On Sun, 2008-03-30 14:07:14 +0530, Vishal Bayskar wrote:
> Dear All,
> 
> I am puzzled why splint is giving warning
> 
> 
> 
> Following line of code is used in program
> 
> temp_file = (char *)calloc(10, sizeof(char))
> 
> Here temp_file is static char *temp_file;
> 
> 
> And after this line, check is used like
> 
> if (temp_file==NULL)
>       {
>               return 1;
>       }
> 
> 
> In program memory allocation (calloc) to temp_file is used only one time
> 
> 
> But splint is showing the following warning
> 
> Only storage assigned to unqualified static:
>                        temp_file = (char *)calloc(10, sizeof(char))
> 
>   The only reference to this storage is transferred to another reference
> (e.g.,
>   by returning it) that does not have the only annotation. This may lead
> to a
>   memory leak, since the new reference is not necessarily released. (Use
>   -onlytrans to inhibit warning)
> 
> Pleas help me understanding why this warning is coming how to solve this
> without using flag onlytrans 

Vishal,

the concept /[EMAIL PROTECTED]@*/ annotation is explained in section 5.2.1 of 
the
manual. In your case, you could declare the temp_file pointer as
/[EMAIL PROTECTED]@*/:

  static char /[EMAIL PROTECTED]@*/ *temp_file = NULL;

Ludolf

-- 

---------------------------------------------------------------
Ludolf Holzheid             Tel:    +49 621 339960
Bihl+Wiedemann GmbH         Fax:    +49 621 3392239
Floßwörthstraße 41          e-mail: [EMAIL PROTECTED]
D-68199 Mannheim, Germany
---------------------------------------------------------------

_______________________________________________
splint-discuss mailing list
splint-discuss@mail.cs.virginia.edu
http://www.cs.virginia.edu/mailman/listinfo/splint-discuss

Reply via email to