Improved testing of std.cfg regarding <arg nr=any> configured functions and added more test cases.

This commit is contained in:
Martin Ettl 2015-09-30 12:18:56 +02:00
parent c64f9cf9b1
commit 4fcd324ccd
3 changed files with 175 additions and 50 deletions

View File

@ -972,7 +972,7 @@
<formatstr/> <formatstr/>
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="any"> <arg nr="3">
<not-uninit/> <not-uninit/>
</arg> </arg>
</function> </function>
@ -989,7 +989,7 @@
<formatstr/> <formatstr/>
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="any"> <arg nr="3">
<not-uninit/> <not-uninit/>
</arg> </arg>
</function> </function>
@ -2567,7 +2567,7 @@
<formatstr/> <formatstr/>
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="any"> <arg nr="2">
<not-uninit/> <not-uninit/>
</arg> </arg>
</function> </function>
@ -2580,7 +2580,7 @@
<formatstr/> <formatstr/>
<not-uninit/> <not-uninit/>
</arg> </arg>
<arg nr="any"> <arg nr="2">
<not-uninit/> <not-uninit/>
</arg> </arg>
</function> </function>
@ -3673,6 +3673,7 @@
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"> <arg nr="1">
<not-uninit/>
<minsize type="strlen" arg="2"/> <minsize type="strlen" arg="2"/>
</arg> </arg>
<formatstr/> <formatstr/>
@ -3745,7 +3746,10 @@
<function name="snprintf,std::snprintf"> <function name="snprintf,std::snprintf">
<noreturn>false</noreturn> <noreturn>false</noreturn>
<leak-ignore/> <leak-ignore/>
<arg nr="1"/> <arg nr="1">
<not-uninit/>
<minsize type="argvalue" arg="2"/>
</arg>
<arg nr="2"> <arg nr="2">
<not-uninit/> <not-uninit/>
</arg> </arg>

View File

@ -35,7 +35,8 @@ void bufferAccessOutOfBounds(void)
// cppcheck-suppress redundantCopy // cppcheck-suppress redundantCopy
snprintf(a, 5, "abcde%i", 1); snprintf(a, 5, "abcde%i", 1);
// cppcheck-suppress redundantCopy // cppcheck-suppress redundantCopy
snprintf(a, 6, "abcde%i", 1); //TODO: cppcheck-suppress bufferAccessOutOfBounds // cppcheck-suppress bufferAccessOutOfBounds
snprintf(a, 6, "abcde%i", 1);
// cppcheck-suppress redundantCopy // cppcheck-suppress redundantCopy
strcpy(a,"abcd"); strcpy(a,"abcd");
// cppcheck-suppress bufferAccessOutOfBounds // cppcheck-suppress bufferAccessOutOfBounds
@ -1261,16 +1262,25 @@ void uninitar_fopen(void)
fclose(fp); fclose(fp);
} }
void uninitar_fprintf(void) void uninitar_fprintf(FILE *Stream, char *Format, int Argument)
{ {
FILE *stream; FILE *stream;
char *format; char *format;
int argument; int argument;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)fprintf(stream, format, argument); (void)fprintf(stream, format, argument);
// cppcheck-suppress uninitvar
(void)fprintf(stream, Format, Argument);
// cppcheck-suppress uninitvar
(void)fprintf(Stream, format, Argument);
// cppcheck-suppress uninitvar
(void)fprintf(Stream, Format, argument);
// no warning is expected
(void)fprintf(Stream, Format, Argument);
} }
void uninitar_vfprintf(void) void uninitar_vfprintf(FILE *Stream, const char *Format, va_list Arg)
{ {
FILE *stream; FILE *stream;
char *format; char *format;
@ -1278,9 +1288,19 @@ void uninitar_vfprintf(void)
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)vfprintf(stream, format, arg); (void)vfprintf(stream, format, arg);
// cppcheck-suppress uninitvar
(void)vfprintf(stream, Format, Arg);
// cppcheck-suppress uninitvar
(void)vfprintf(Stream, format, Arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)vfprintf(Stream, Format, arg);
// no warning is expected
(void)vfprintf(Stream, Format, Arg);
} }
void uninitar_vfwprintf(FILE *s, wchar_t *f, va_list a) void uninitar_vfwprintf(FILE *Stream, wchar_t *Format, va_list Arg)
{ {
FILE *stream; FILE *stream;
wchar_t *format; wchar_t *format;
@ -1289,11 +1309,15 @@ void uninitar_vfwprintf(FILE *s, wchar_t *f, va_list a)
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)vfwprintf(stream, format, arg); (void)vfwprintf(stream, format, arg);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)vfwprintf(s, format, a); (void)vfwprintf(stream, Format, Arg);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)vfwprintf(stream, f, a); (void)vfwprintf(Stream, format, Arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)vfwprintf(Stream, Format, arg);
// no warning is expected // no warning is expected
(void)vfwprintf(s, f, a); (void)vfwprintf(Stream, Format, Arg);
} }
void uninitvar_fputc(void) void uninitvar_fputc(void)
@ -2561,34 +2585,57 @@ void uninitvar_remquo(void)
(void)remquol(ld1,ld2,i3); (void)remquol(ld1,ld2,i3);
} }
void uninivar_printf(void) void uninivar_printf(char *Format, int Argument)
{ {
char * format; char * format;
int i; int argument;
// no warning is expected // no warning is expected
(void)printf("x"); (void)printf("x");
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)printf(format,i); (void)printf(format,argument);
// cppcheck-suppress uninitvar
(void)printf(Format,argument);
// cppcheck-suppress uninitvar
(void)printf(format,Argument);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)printf(format,1); (void)printf(format,1);
// no warning is expected
(void)printf(Format,Argument);
} }
void uninivar_vprintf(void) void uninivar_vprintf(char *Format, va_list Arg)
{ {
char * format; char * format;
va_list arg; va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)vprintf(format,arg); (void)vprintf(format,arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)vprintf(Format,arg);
// cppcheck-suppress uninitvar
(void)vprintf(format,Arg);
// no warning is expected
(void)vprintf(Format,Arg);
} }
void uninivar_vwprintf(void) void uninivar_vwprintf(wchar_t *Format, va_list Arg)
{ {
wchar_t * format; wchar_t * format;
va_list arg; va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)vwprintf(format,arg); (void)vwprintf(format,arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)vwprintf(Format,arg);
// cppcheck-suppress uninitvar
(void)vwprintf(format,Arg);
// no warning is expected
(void)vwprintf(Format,Arg);
} }
void uninivar_bsearch(void) void uninivar_bsearch(void)
@ -3247,30 +3294,42 @@ void uninivar_wcstol(void)
(void)wcstoull(s,endp,base); (void)wcstoull(s,endp,base);
} }
void uninitvar_wprintf(wchar_t *format, int input) void uninitvar_wprintf(wchar_t *Format, int Argument)
{ {
const wchar_t *f; const wchar_t *format;
int i; int argument;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)wprintf(f,i); (void)wprintf(format,argument);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)wprintf(f);
// cppcheck-suppress uninitvar
(void)wprintf(f,input);
// cppcheck-suppress uninitvar
(void)wprintf(format,i);
// no warning is expected
(void)wprintf(format,input);
(void)wprintf(format); (void)wprintf(format);
// cppcheck-suppress uninitvar
(void)wprintf(Format,argument);
// cppcheck-suppress uninitvar
(void)wprintf(format,Argument);
// no warning is expected
(void)wprintf(Format,Argument);
(void)wprintf(Format);
} }
void uninitvar_sprintf(void) void uninitvar_sprintf(char *S, char *Format, int Argument)
{ {
char *s; char *s;
const char *format; const char *format;
int i; int argument;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)sprintf(s,format,i); (void)sprintf(s,format,argument);
// cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar
(void)sprintf(s,Format,Argument);
// cppcheck-suppress uninitvar
(void)sprintf(S,format,Argument);
// cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar
(void)sprintf(S,Format,argument);
// no warning is expected for
// cppcheck-suppress redundantCopy
(void)sprintf(S,Format,Argument);
} }
void uninitvar_swprintf(void) void uninitvar_swprintf(void)
@ -3329,7 +3388,12 @@ void uninivar_snprintf(char *S, size_t N, char *Format, int Int)
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)snprintf(S,N,Format,i); // i is uninitialized (void)snprintf(S,N,Format,i); // i is uninitialized
// cppcheck-suppress redundantCopy // cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar
(void)snprintf(s,N,Format,Int); (void)snprintf(s,N,Format,Int);
// no warning is expected for
// cppcheck-suppress redundantCopy
(void)snprintf(S,N,Format,Int);
} }
void uninivar_vsnprintf(void) void uninivar_vsnprintf(void)

View File

@ -791,16 +791,25 @@ void uninitar_fopen(void)
fclose(fp); fclose(fp);
} }
void uninitar_fprintf(void) void uninitar_fprintf(FILE *Stream, char *Format, int Argument)
{ {
FILE *stream; FILE *stream;
char *format; char *format;
int argument; int argument;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::fprintf(stream, format, argument); (void)std::fprintf(stream, format, argument);
// cppcheck-suppress uninitvar
(void)std::fprintf(stream, Format, Argument);
// cppcheck-suppress uninitvar
(void)std::fprintf(Stream, format, Argument);
// cppcheck-suppress uninitvar
(void)std::fprintf(Stream, Format, argument);
// no warning is expected
(void)std::fprintf(Stream, Format, Argument);
} }
void uninitar_vfprintf(void) void uninitar_vfprintf(FILE *Stream, const char *Format, va_list Arg)
{ {
FILE *stream; FILE *stream;
char *format; char *format;
@ -808,9 +817,19 @@ void uninitar_vfprintf(void)
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::vfprintf(stream, format, arg); (void)std::vfprintf(stream, format, arg);
// cppcheck-suppress uninitvar
(void)std::vfprintf(stream, Format, Arg);
// cppcheck-suppress uninitvar
(void)std::vfprintf(Stream, format, Arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)std::vfprintf(Stream, Format, arg);
// no warning is expected
(void)std::vfprintf(Stream, Format, Arg);
} }
void uninitar_vfwprintf(void) void uninitar_vfwprintf(FILE *Stream, wchar_t *Format, va_list Arg)
{ {
FILE *stream; FILE *stream;
wchar_t *format; wchar_t *format;
@ -818,6 +837,16 @@ void uninitar_vfwprintf(void)
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::vfwprintf(stream, format, arg); (void)std::vfwprintf(stream, format, arg);
// cppcheck-suppress uninitvar
(void)std::vfwprintf(stream, Format, Arg);
// cppcheck-suppress uninitvar
(void)std::vfwprintf(Stream, format, Arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)std::vfwprintf(Stream, Format, arg);
// no warning is expected
(void)std::vfwprintf(Stream, Format, Arg);
} }
void uninitvar_fputc(void) void uninitvar_fputc(void)
@ -1890,34 +1919,57 @@ void uninitvar_remquo(void)
(void)std::remquol(ld1,ld2,i3); (void)std::remquol(ld1,ld2,i3);
} }
void uninivar_printf(void) void uninivar_printf(char *Format, int Argument)
{ {
char * format; char * format;
int i; int argument;
// no warning is expected // no warning is expected
(void)std::printf("x"); (void)std::printf("x");
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::printf(format,i); (void)std::printf(format,argument);
// cppcheck-suppress uninitvar
(void)std::printf(Format,argument);
// cppcheck-suppress uninitvar
(void)std::printf(format,Argument);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::printf(format,1); (void)std::printf(format,1);
// no warning is expected
(void)std::printf(Format,Argument);
} }
void uninivar_vprintf(void) void uninivar_vprintf(char *Format, va_list Arg)
{ {
char * format; char * format;
va_list arg; va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::vprintf(format,arg); (void)std::vprintf(format,arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)std::vprintf(Format,arg);
// cppcheck-suppress uninitvar
(void)std::vprintf(format,Arg);
// no warning is expected
(void)std::vprintf(Format,Arg);
} }
void uninivar_vwprintf(void) void uninivar_vwprintf(wchar_t *Format, va_list Arg)
{ {
wchar_t * format; wchar_t * format;
va_list arg; va_list arg;
// cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::vwprintf(format,arg); (void)std::vwprintf(format,arg);
// cppcheck-suppress va_list_usedBeforeStarted
// cppcheck-suppress uninitvar
(void)std::vwprintf(Format,arg);
// cppcheck-suppress uninitvar
(void)std::vwprintf(format,Arg);
// no warning is expected
(void)std::vwprintf(Format,Arg);
} }
void uninivar_bsearch(void) void uninivar_bsearch(void)
@ -2679,21 +2731,21 @@ void uninivar_wcstol(void)
(void)wcstoumax(s,endp,base); (void)wcstoumax(s,endp,base);
} }
void uninitvar_wprintf(wchar_t *format, int input) void uninitvar_wprintf(wchar_t *Format, int Argument)
{ {
const wchar_t *f; const wchar_t *format;
int i; int argument;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::wprintf(f,i); (void)std::wprintf(format,argument);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::wprintf(f);
// cppcheck-suppress uninitvar
(void)std::wprintf(f,input);
// cppcheck-suppress uninitvar
(void)std::wprintf(format,i);
// no warning is expected
(void)std::wprintf(format,input);
(void)std::wprintf(format); (void)std::wprintf(format);
// cppcheck-suppress uninitvar
(void)std::wprintf(Format,argument);
// cppcheck-suppress uninitvar
(void)std::wprintf(format,Argument);
// no warning is expected
(void)std::wprintf(Format,Argument);
(void)std::wprintf(Format);
} }
void uninitvar_sprintf(void) void uninitvar_sprintf(void)
@ -2761,7 +2813,12 @@ void uninivar_snprintf(char *S, size_t N, char *Format, int Int)
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::snprintf(S,N,Format,i); // i is uninitialized (void)std::snprintf(S,N,Format,i); // i is uninitialized
// cppcheck-suppress redundantCopy // cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar
(void)std::snprintf(s,N,Format,Int); (void)std::snprintf(s,N,Format,Int);
// no warning is expected for
// cppcheck-suppress redundantCopy
(void)std::snprintf(S,N,Format,Int);
} }
void uninivar_vsnprintf(void) void uninivar_vsnprintf(void)