Improved testing of std.cfg regarding uninitialized variables.

This commit is contained in:
orbitcowboy 2015-09-01 11:29:28 +02:00
parent e683d31e71
commit 974414645a
3 changed files with 429 additions and 25 deletions

View File

@ -1119,7 +1119,7 @@
</arg>
</function>
<!-- int vfscanf(FILE *stream, const char * format, va_list arg); -->
<function name="vfscanf">
<function name="vfscanf,std::vfscanf">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1128,11 +1128,12 @@
<formatstr scan="true"/>
<arg nr="2">
<formatstr/>
<not-uninit/>
</arg>
<arg nr="3"/>
</function>
<!-- int vfwscanf(FILE *stream, const wchar_t * format, va_list arg); -->
<function name="vfwscanf">
<function name="vfwscanf,std::vfwscanf">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1144,7 +1145,7 @@
</arg>
</function>
<!-- int fseek(FILE* stream, long int offset, int origin); -->
<function name="fseek">
<function name="fseek,std::fseek">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1159,7 +1160,7 @@
</arg>
</function>
<!-- int fsetpos(FILE *stream, const fpos_t *ptr); -->
<function name="fsetpos">
<function name="fsetpos,std::fsetpos">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1172,7 +1173,7 @@
</arg>
</function>
<!-- char * fgets(char *buffer, int n, FILE *stream); -->
<function name="fgets">
<function name="fgets,std::fgets">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1190,7 +1191,7 @@
</arg>
</function>
<!-- wchar_t* fgetws(wchar_t* ws, int num, FILE* stream); -->
<function name="fgetws">
<function name="fgetws,std::fgetws">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1208,7 +1209,7 @@
</arg>
</function>
<!-- long int ftell(FILE *stream); -->
<function name="ftell">
<function name="ftell,std::ftell">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1217,7 +1218,7 @@
</arg>
</function>
<!-- int fwide(FILE* stream, int mode); -->
<function name="fwide">
<function name="fwide,std::fwide">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1229,7 +1230,7 @@
</arg>
</function>
<!-- size_t fwrite(const void *ptr, size_t size, size_t nobj, FILE *stream); -->
<function name="fwrite">
<function name="fwrite,std::fwrite">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1249,7 +1250,7 @@
</arg>
</function>
<!-- int mblen(const char *string, size_t size); -->
<function name="mblen">
<function name="mblen,std::mblen">
<use-retval/>
<noreturn>false</noreturn>
<leak-ignore/>
@ -1260,7 +1261,8 @@
<not-uninit/>
</arg>
</function>
<function name="mbtowc">
<!-- int mbtowc(wchar_t* pwc, const char* pmb, size_t max); -->
<function name="mbtowc,std::mbtowc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="2">
@ -1271,7 +1273,7 @@
</arg>
</function>
<!-- size_t mbrlen(const char* pmb, size_t max, mbstate_t* ps); -->
<function name="mbrlen">
<function name="mbrlen,std::mbrlen">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1287,7 +1289,7 @@
</arg>
</function>
<!-- wint_t btowc(int c); -->
<function name="btowc">
<function name="btowc,std::btowc">
<use-retval/>
<pure/>
<noreturn>false</noreturn>
@ -1297,7 +1299,7 @@
</arg>
</function>
<!-- int mbsinit(const mbstate_t* ps); -->
<function name="mbsinit">
<function name="mbsinit,std::mbsinit">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1310,7 +1312,7 @@
<leak-ignore/>
</function>
<!-- size_t mbstowcs(wchar_t *ws, const char *s, size_t n); -->
<function name="mbstowcs">
<function name="mbstowcs,std::mbstowcs">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="2">
@ -1322,7 +1324,7 @@
</arg>
</function>
<!-- size_t mbsrtowcs(wchar_t* dest, const char** src, size_t max, mbstate_t* ps); -->
<function name="mbsrtowcs">
<function name="mbsrtowcs,std::mbsrtowcs">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="2">
@ -1336,8 +1338,8 @@
<not-null/>
</arg>
</function>
<!-- int wctob(win_t c); -->
<function name="wctob">
<!-- int wctob(wint_t wc); -->
<function name="wctob,std::wctob">
<use-retval/>
<noreturn>false</noreturn>
<leak-ignore/>
@ -1347,7 +1349,7 @@
</arg>
</function>
<!-- int wctomb(char *s, wchar_t wchar); -->
<function name="wctomb">
<function name="wctomb,std::wctomb">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1358,7 +1360,7 @@
</arg>
</function>
<!-- size_t wcstombs(char *mbstr, const wchar_t *wcstr, size_t n);-->
<function name="wcstombs">
<function name="wcstombs,std::wcstombs">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="2">
@ -1370,7 +1372,7 @@
</arg>
</function>
<!-- int getc(FILE *stream); -->
<function name="getc">
<function name="getc,std::getc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1379,7 +1381,7 @@
</arg>
</function>
<!-- wint_t getwc(FILE* stream); -->
<function name="getwc">
<function name="getwc,std::getwc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1393,7 +1395,7 @@
<leak-ignore/>
</function>
<!-- int ungetc(int c, FILE *stream); -->
<function name="ungetc">
<function name="ungetc,std::ungetc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">
@ -1404,8 +1406,8 @@
<not-uninit/>
</arg>
</function>
<!-- win_t ungetwc(win_t c, FILE *stream); -->
<function name="ungetwc">
<!-- wint_t ungetwc(wint_t c, FILE *stream); -->
<function name="ungetwc,std::ungetwc">
<noreturn>false</noreturn>
<leak-ignore/>
<arg nr="1">

View File

@ -1372,6 +1372,207 @@ void uninitvar_fscanf(void)
(void)fscanf(stream,format,i);
}
void uninitvar_vfscanf(void)
{
FILE *stream;
char * format;
va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)vfscanf(stream,format,arg);
}
void uninitvar_vfwscanf(void)
{
FILE *stream;
wchar_t *format;
va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)vfwscanf(stream,format,arg);
}
void uninitvar_fseek(void)
{
FILE* stream;
long int offset;
int origin;
// cppcheck-suppress uninitvar
(void)fseek(stream,offset,origin);
}
void uninitvar_fsetpos(void)
{
FILE* stream;
fpos_t *ptr;
// cppcheck-suppress uninitvar
(void)fsetpos(stream,ptr);
}
void uninitvar_fgets(void)
{
char *buffer;
int n;
FILE *stream;
// cppcheck-suppress uninitvar
(void)fgets(buffer,n,stream);
}
void uninitvar_fgetws(void)
{
wchar_t *buffer;
int n;
FILE *stream;
// cppcheck-suppress uninitvar
(void)fgetws(buffer,n,stream);
}
void uninitvar_ftell(void)
{
FILE *stream;
// cppcheck-suppress uninitvar
(void)ftell(stream);
}
void uninitvar_fwide(void)
{
FILE *stream;
int mode;
// cppcheck-suppress uninitvar
(void)fwide(stream,mode);
}
void uninitvar_fwrite(void)
{
void *ptr;
size_t size;
size_t nobj;
FILE *stream;
// cppcheck-suppress uninitvar
(void)fwrite(ptr,size,nobj,stream);
}
void uninitvar_mblen(void)
{
char *string;
size_t size;
// cppcheck-suppress uninitvar
(void)mblen(string,size);
}
void uninitvar_mbtowc(void)
{
wchar_t* pwc;
char* pmb;
size_t max;
// cppcheck-suppress uninitvar
(void)mbtowc(pwc,pmb,max);
}
void uninitvar_mbrlen(const char* p, size_t m, mbstate_t* s)
{
char* pmb;
size_t max;
mbstate_t* ps;
// cppcheck-suppress uninitvar
(void)mbrlen(pmb,max,ps);
// cppcheck-suppress uninitvar
(void)mbrlen(pmb,m,s);
// cppcheck-suppress uninitvar
(void)mbrlen(p,max,s);
// cppcheck-suppress uninitvar
(void)mbrlen(p,m,ps);
// no warning is expected
(void)mbrlen(p,m,s);
}
void uninitvar_btowc(void)
{
int c;
// cppcheck-suppress uninitvar
(void)btowc(c);
}
void uninitvar_mbsinit(void)
{
mbstate_t* ps;
// cppcheck-suppress uninitvar
(void)mbsinit(ps);
}
void uninitvar_mbstowcs(void)
{
wchar_t *ws;
char *s;
size_t n;
// cppcheck-suppress uninitvar
(void)mbstowcs(ws,s,n);
}
void uninitvar_mbsrtowcs(void)
{
wchar_t* dest;
const char* src;
size_t max;
mbstate_t* ps;
// cppcheck-suppress uninitvar
(void)mbsrtowcs(dest,&src,max,ps);
}
void uninitvar_wctob(void)
{
wint_t wc;
// cppcheck-suppress uninitvar
(void)wctob(wc);
}
void uninitvar_wctomb(void)
{
char *s;
wchar_t wc;
// cppcheck-suppress uninitvar
(void)wctomb(s,wc);
}
void uninitvar_wcstombs(void)
{
char *mbstr;
wchar_t *wcstr;
size_t n;
// cppcheck-suppress uninitvar
(void)wcstombs(mbstr,wcstr,n);
}
void uninitvar_getc(void)
{
FILE *stream;
// cppcheck-suppress uninitvar
(void)getc(stream);
}
void uninitvar_getwc(void)
{
FILE *stream;
// cppcheck-suppress uninitvar
(void)getwc(stream);
}
void uninitvar_ungetc(void)
{
int c;
FILE *stream;
// cppcheck-suppress uninitvar
(void)ungetc(c,stream);
}
void uninitvar_ungetwc(void)
{
wint_t c;
FILE *stream;
// cppcheck-suppress uninitvar
(void)ungetwc(c,stream);
}
void ignoreretrn(void)
{
char szNumbers[] = "2001 60c0c0 -1101110100110100100000 0x6fffff";

View File

@ -888,3 +888,204 @@ void uninitvar_fscanf(void)
// cppcheck-suppress uninitvar
(void)std::fscanf(stream,format,i);
}
void uninitvar_vfscanf(void)
{
FILE *stream;
char *format;
va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)std::vfscanf(stream,format,arg);
}
void uninitvar_vfwscanf(void)
{
FILE *stream;
wchar_t *format;
va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)std::vfwscanf(stream,format,arg);
}
void uninitvar_fseek(void)
{
FILE* stream;
long int offset;
int origin;
// cppcheck-suppress uninitvar
(void)std::fseek(stream,offset,origin);
}
void uninitvar_fsetpos(void)
{
FILE* stream;
fpos_t *ptr;
// cppcheck-suppress uninitvar
(void)std::fsetpos(stream,ptr);
}
void uninitvar_fgets(void)
{
char *buffer;
int n;
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::fgets(buffer,n,stream);
}
void uninitvar_fgetws(void)
{
wchar_t *buffer;
int n;
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::fgetws(buffer,n,stream);
}
void uninitvar_ftell(void)
{
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::ftell(stream);
}
void uninitvar_fwide(void)
{
FILE *stream;
int mode;
// cppcheck-suppress uninitvar
(void)std::fwide(stream,mode);
}
void uninitvar_fwrite(void)
{
void *ptr;
size_t size;
size_t nobj;
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::fwrite(ptr,size,nobj,stream);
}
void uninitvar_mblen(void)
{
char *string;
size_t size;
// cppcheck-suppress uninitvar
(void)std::mblen(string,size);
}
void uninitvar_mbtowc(void)
{
wchar_t* pwc;
char* pmb;
size_t max;
// cppcheck-suppress uninitvar
(void)std::mbtowc(pwc,pmb,max);
}
void uninitvar_mbrlen(const char* p, size_t m, mbstate_t* s)
{
char* pmb;
size_t max;
mbstate_t* ps;
// cppcheck-suppress uninitvar
(void)std::mbrlen(pmb,max,ps);
// cppcheck-suppress uninitvar
(void)std::mbrlen(pmb,m,s);
// cppcheck-suppress uninitvar
(void)std::mbrlen(p,max,s);
// cppcheck-suppress uninitvar
(void)std::mbrlen(p,m,ps);
// no warning is expected
(void)std::mbrlen(p,m,s);
}
void uninitvar_btowc(void)
{
int c;
// cppcheck-suppress uninitvar
(void)std::btowc(c);
}
void uninitvar_mbsinit(void)
{
mbstate_t* ps;
// cppcheck-suppress uninitvar
(void)std::mbsinit(ps);
}
void uninitvar_mbstowcs(void)
{
wchar_t *ws;
char *s;
size_t n;
// cppcheck-suppress uninitvar
(void)std::mbstowcs(ws,s,n);
}
void uninitvar_mbsrtowcs(void)
{
wchar_t* dest;
const char* src;
size_t max;
mbstate_t* ps;
// cppcheck-suppress uninitvar
(void)std::mbsrtowcs(dest,&src,max,ps);
}
void uninitvar_wctob(void)
{
wint_t wc;
// cppcheck-suppress uninitvar
(void)std::wctob(wc);
}
void uninitvar_wctomb(void)
{
char *s;
wchar_t wc;
// cppcheck-suppress uninitvar
(void)std::wctomb(s,wc);
}
void uninitvar_wcstombs(void)
{
char *mbstr;
wchar_t *wcstr;
size_t n;
// cppcheck-suppress uninitvar
(void)std::wcstombs(mbstr,wcstr,n);
}
void uninitvar_getc(void)
{
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::getc(stream);
}
void uninitvar_getwc(void)
{
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::getwc(stream);
}
void uninitvar_ungetc(void)
{
int c;
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::ungetc(c,stream);
}
void uninitvar_ungetwc(void)
{
wint_t c;
FILE *stream;
// cppcheck-suppress uninitvar
(void)std::ungetwc(c,stream);
}