[splint-discuss] warning related to -onlytrans flag

Vishal Bayskar vishal.bayskar at nechclst.in
Sun Mar 30 00:37:14 PST 2008


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 



Thanks and Regards
 
Vishal Bayskar
 



More information about the splint-discuss mailing list