[splint-discuss] Unallocated storage warning
Dimiter Andonov
dimiter.andonov at gmail.com
Mon Jan 18 11:26:26 PST 2010
Hello guys,
Here's a small application I use to test splint with:
#include <stdlib.h>
/*@only@*//*@out@*//*@null@*/ static int *alloc_int(void);
static void free_int(/*@null@*//*@out@*/ int**);
int main(void)
{
int *p = NULL;
p = alloc_int();
if (p != NULL) {
free_int(&p);
}
return EXIT_SUCCESS;
}
static int *alloc_int(void)
{
int *p = malloc(sizeof *p);
return p;
}
static void free_int(int **p)
/*@requires only *p@*/
{
if (p != NULL) {
free(*p); /* this is the line 29 */
*p = NULL;
}
}
When I pass the app above to splint I am getting the following warning:
main.c: (in function free_list)
main.c:29:8: Unallocated storage *p passed as out parameter: *p
An rvalue is used that may not be initialized to a value on some execution
path. (Use -usedef to inhibit warning)
Can someone, please, explain what's wrong with the code snippet above?
Thanks,
Dimiter
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.cs.virginia.edu/pipermail/splint-discuss/attachments/20100118/dbc18073/attachment.html
More information about the splint-discuss
mailing list