Improved testing of std.cfg regarding uninitialized variables.

This commit is contained in:
orbitcowboy 2015-08-31 11:59:57 +02:00
parent f653189bd4
commit d1ba919e39
3 changed files with 59 additions and 3 deletions

View File

@ -1033,7 +1033,7 @@
</arg>
</function>
<!-- size_t fread(void *ptr, size_t size, size_t nobj, FILE *stream); -->
<function name="fread">
<function name="fread,std::fread">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1052,14 +1052,14 @@
</arg>
</function>
<!-- void free(void *block); -->
<function name="free">
<function name="free,std::free">
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>
</arg>
</function>
<!-- FILE *freopen(const char *filename, const char *mode, FILE *stream); -->
<function name="freopen">
<function name="freopen,std::freopen">
<noreturn>false</noreturn>
<arg nr="1">
<not-uninit/>

View File

@ -1296,6 +1296,34 @@ void uninitvar_fputws(void)
(void)fputws(string,stream);
}
void uninitvar_fread(void)
{
void *ptr;
size_t size;
size_t nobj;
FILE *stream;
// cppcheck-suppress uninitvar
(void)fread(ptr,size,nobj,stream);
}
void uninitvar_free(void)
{
// cppcheck-suppress unassignedVariable
void *block;
// cppcheck-suppress uninitvar
free(block);
}
void uninitvar_freopen(void)
{
char *filename;
char *mode;
FILE *stream;
// cppcheck-suppress uninitvar
FILE * p = freopen(filename,mode,stream);
free(p);
}
void ignoreretrn(void)
{
char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff";

View File

@ -818,3 +818,31 @@ void uninitvar_fputws(void)
// cppcheck-suppress uninitvar
(void)std::fputws(string,stream);
}
void uninitvar_fread(void)
{
void *ptr;
size_t size;
size_t nobj;
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::fread(ptr,size,nobj,stream);
}
void uninitvar_free(void)
{
// cppcheck-suppress unassignedVariable
void *block;
// cppcheck-suppress uninitvar
std::free(block);
}
void uninitvar_freopen(void)
{
char *filename;
char *mode;
FILE *stream;
// cppcheck-suppress uninitvar
FILE * p = std::freopen(filename,mode,stream);
free(p);
}