M
Mark
Hello
Given this little piece of code.
#include <stdio.h>
static char *mkw(void)
{
return "xyz";
}
int main(void)
{
char *s = NULL;
s = mkw();
printf("%s\n", s);
return 0;
}
Running 'splint' ("splint foo.c") results in complaints:
Splint 3.1.1 --- 11 Sep 2006
a.c: (in function mkw)
a.c:5:9: Observer storage returned without qualification: "xyz"
Observer storage is transferred to a non-observer reference. (Use
-observertrans to inhibit warning)
a.c:5:9: Storage becomes observer
a.c: (in function main)
a.c:14:11: Fresh storage s 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)
a.c:11:2: Fresh storage s created
Finished checking --- 2 code warningsSplint 3.1.1 --- 11 Sep 2006
What's wrong with it? GCC happily compiles though. I read that sometimes
'splint' may be too picky, is this the case?
Thanks in advance.
Given this little piece of code.
#include <stdio.h>
static char *mkw(void)
{
return "xyz";
}
int main(void)
{
char *s = NULL;
s = mkw();
printf("%s\n", s);
return 0;
}
Running 'splint' ("splint foo.c") results in complaints:
Splint 3.1.1 --- 11 Sep 2006
a.c: (in function mkw)
a.c:5:9: Observer storage returned without qualification: "xyz"
Observer storage is transferred to a non-observer reference. (Use
-observertrans to inhibit warning)
a.c:5:9: Storage becomes observer
a.c: (in function main)
a.c:14:11: Fresh storage s 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)
a.c:11:2: Fresh storage s created
Finished checking --- 2 code warningsSplint 3.1.1 --- 11 Sep 2006
What's wrong with it? GCC happily compiles though. I read that sometimes
'splint' may be too picky, is this the case?
Thanks in advance.