From b3f9df968b6c5b77fbc086d4f0f6ecd158aaeaaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sun, 3 Oct 2021 20:32:39 +0200 Subject: [PATCH] Uninitvar: fixed 'make checkcfg' --- test/cfg/bsd.c | 10 +- test/cfg/posix.c | 6 +- test/cfg/std.c | 236 ++++++++++++++++++++++--------------------- test/cfg/std.cpp | 201 ++++++++++++++++++------------------ test/cfg/windows.cpp | 16 +-- 5 files changed, 239 insertions(+), 230 deletions(-) diff --git a/test/cfg/bsd.c b/test/cfg/bsd.c index 725f6cfe1..8ab7e9640 100644 --- a/test/cfg/bsd.c +++ b/test/cfg/bsd.c @@ -45,15 +45,15 @@ void nullPointer_timercmp(struct timeval t) // size_t strlcat(char *dst, const char *src, size_t size); void uninitvar_strlcat(char *Ct, const char *S, size_t N) { - char *ct; - char *s; + char *ct1, *ct2; + char *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)strlcat(ct,s,n1); + (void)strlcat(ct1,s1,n1); // cppcheck-suppress uninitvar - (void)strlcat(ct,S,N); + (void)strlcat(ct2,S,N); // cppcheck-suppress uninitvar - (void)strlcat(Ct,s,N); + (void)strlcat(Ct,s2,N); // cppcheck-suppress uninitvar (void)strlcat(Ct,S,n2); diff --git a/test/cfg/posix.c b/test/cfg/posix.c index ca3240d32..71dd978ed 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -426,15 +426,15 @@ void uninitvar(int fd) // cppcheck-suppress gcvtCalled gcvt(3.141, 2, buf); - char *filename; + char *filename1, *filename2; struct utimbuf *times; // cppcheck-suppress uninitvar // cppcheck-suppress utimeCalled - utime(filename, times); + utime(filename1, times); struct timeval times1[2]; // cppcheck-suppress uninitvar // cppcheck-suppress utimeCalled - utime(filename, times1); + utime(filename2, times1); // cppcheck-suppress unreadVariable // cppcheck-suppress uninitvar diff --git a/test/cfg/std.c b/test/cfg/std.c index 7856cedf5..afb1e1947 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -119,13 +119,13 @@ void unusedRetVal_aligned_alloc(void) void uninitvar_aligned_alloc(size_t alignment, size_t size) { - size_t uninitVar; + size_t uninitVar1, uninitVar2, uninitVar3; // cppcheck-suppress uninitvar - free(aligned_alloc(uninitVar, size)); + free(aligned_alloc(uninitVar1, size)); // cppcheck-suppress uninitvar - free(aligned_alloc(alignment, uninitVar)); + free(aligned_alloc(alignment, uninitVar2)); // cppcheck-suppress uninitvar - free(aligned_alloc(uninitVar, uninitVar)); + free(aligned_alloc(uninitVar3, uninitVar3)); // no warning is expected free(aligned_alloc(alignment, size)); } @@ -450,24 +450,24 @@ void uninitvar_fopen(void) void uninitvar_feof(void) { - FILE *fp; + FILE *fp1, *fp2; // cppcheck-suppress ignoredReturnValue // cppcheck-suppress uninitvar - feof(fp); + feof(fp1); // cppcheck-suppress uninitvar - (void)feof(fp); + (void)feof(fp2); } void uninitvar_ferror(void) { - FILE *fp; + FILE *fp1, *fp2; // cppcheck-suppress ignoredReturnValue // cppcheck-suppress uninitvar - ferror(fp); + ferror(fp1); // cppcheck-suppress uninitvar - (void)ferror(fp); + (void)ferror(fp2); } void uninitvar_fflush(void) @@ -1104,15 +1104,15 @@ void uninitvar_atof(void) void uninitvar_atol(void) { - char * c; + char * c1, *c2, *c3; // cppcheck-suppress uninitvar - (void)atoi(c); + (void)atoi(c1); // cppcheck-suppress uninitvar - (void)atol(c); + (void)atol(c2); // cppcheck-suppress uninitvar - (void)atoll(c); + (void)atoll(c3); } void uninitvar_calloc(void) @@ -1493,13 +1493,13 @@ void uninitvar_fmod(void) void uninitvar_fprintf(FILE *Stream, char *Format, int Argument) { - FILE *stream; + FILE *stream1, *stream2; char *format1, *format2; int argument1, argument2; // cppcheck-suppress uninitvar - (void)fprintf(stream, format1, argument1); + (void)fprintf(stream1, format1, argument1); // cppcheck-suppress uninitvar - (void)fprintf(stream, Format, Argument); + (void)fprintf(stream2, Format, Argument); // cppcheck-suppress uninitvar (void)fprintf(Stream, format2, Argument); // cppcheck-suppress uninitvar @@ -1511,14 +1511,14 @@ void uninitvar_fprintf(FILE *Stream, char *Format, int Argument) void uninitvar_vfprintf(FILE *Stream, const char *Format, va_list Arg) { - FILE *stream; + FILE *stream1, *stream2; char *format1, *format2; va_list arg; // cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress uninitvar - (void)vfprintf(stream, format1, arg); + (void)vfprintf(stream1, format1, arg); // cppcheck-suppress uninitvar - (void)vfprintf(stream, Format, Arg); + (void)vfprintf(stream2, Format, Arg); // cppcheck-suppress uninitvar (void)vfprintf(Stream, format2, Arg); @@ -1530,14 +1530,14 @@ void uninitvar_vfprintf(FILE *Stream, const char *Format, va_list Arg) void uninitvar_vfwprintf(FILE *Stream, wchar_t *Format, va_list Arg) { - FILE *stream; + FILE *stream1, *stream2; wchar_t *format1, *format2; va_list arg; // cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress uninitvar - (void)vfwprintf(stream, format1, arg); + (void)vfwprintf(stream1, format1, arg); // cppcheck-suppress uninitvar - (void)vfwprintf(stream, Format, Arg); + (void)vfwprintf(stream2, Format, Arg); // cppcheck-suppress uninitvar (void)vfwprintf(Stream, format2, Arg); @@ -1708,13 +1708,13 @@ void uninitvar_mbtowc(void) void uninitvar_mbrlen(const char* p, size_t m, mbstate_t* s) { - char* pmb; + char* pmb1, *pmb2; size_t max1, max2; mbstate_t* ps1, *ps2; // cppcheck-suppress uninitvar - (void)mbrlen(pmb,max1,ps1); + (void)mbrlen(pmb1,max1,ps1); // cppcheck-suppress uninitvar - (void)mbrlen(pmb,m,s); + (void)mbrlen(pmb2,m,s); // cppcheck-suppress uninitvar (void)mbrlen(p,max2,s); // cppcheck-suppress uninitvar @@ -2454,13 +2454,13 @@ void uninitvar_islessgreater(void) void uninitvar_nan(void) { - char *tagp; + char *tagp1, *tagp2, *tagp3; // cppcheck-suppress uninitvar - (void)nanf(tagp); + (void)nanf(tagp1); // cppcheck-suppress uninitvar - (void)nan(tagp); + (void)nan(tagp2); // cppcheck-suppress uninitvar - (void)nanl(tagp); + (void)nanl(tagp3); } void uninitvar_isnan(void) @@ -3070,11 +3070,11 @@ void uninitvar_setvbuf(void) void uninitvar_strcat(char *dest, const char * const source) { char *deststr1, *deststr2; - char *srcstr; + char *srcstr1, *srcstr2; // cppcheck-suppress uninitvar - (void)strcat(deststr1,srcstr); + (void)strcat(deststr1,srcstr1); // cppcheck-suppress uninitvar - (void)strcat(dest,srcstr); + (void)strcat(dest,srcstr2); // cppcheck-suppress uninitvar (void)strcat(deststr2,source); @@ -3225,13 +3225,15 @@ void uninitvar_strcmp(char *s1, char *s2) { char *str1; char *str2; + char *str3; + char *str4; // cppcheck-suppress uninitvar (void)strcmp(str1,s2); // cppcheck-suppress uninitvar (void)strcmp(s1,str2); // cppcheck-suppress uninitvar - (void)strcmp(str1,str2); + (void)strcmp(str3,str4); // No warning is expected (void)strcmp(s1,s2); @@ -3241,13 +3243,15 @@ void uninitvar_wcscmp(wchar_t *s1, wchar_t *s2) { wchar_t *str1; wchar_t *str2; + wchar_t *str3; + wchar_t *str4; // cppcheck-suppress uninitvar (void)wcscmp(str1,s2); // cppcheck-suppress uninitvar (void)wcscmp(s1,str2); // cppcheck-suppress uninitvar - (void)wcscmp(str1,str2); + (void)wcscmp(str3,str4); // No warning is expected (void)wcscmp(s1,s2); @@ -3255,15 +3259,15 @@ void uninitvar_wcscmp(wchar_t *s1, wchar_t *s2) void uninitvar_strcpy(char *d, char *s) { - char *dest; - char *src; + char *dest1, *dest2; + char *src1, *src2; // cppcheck-suppress uninitvar - (void)strcpy(dest,s); + (void)strcpy(dest1,s); // cppcheck-suppress uninitvar - (void)strcpy(d,src); + (void)strcpy(d,src1); // cppcheck-suppress uninitvar - (void)strcpy(dest,src); + (void)strcpy(dest2,src2); // No warning is expected (void)strcpy(d,s); @@ -3288,15 +3292,15 @@ void uninitvar_strcpy_s(char * strDest, ssize_t s, char *source) void uninitvar_wcscpy(wchar_t *d, wchar_t*s) { - wchar_t *dest; - wchar_t *src; + wchar_t *dest1, *dest2; + wchar_t *src1, *src2; // cppcheck-suppress uninitvar - (void)wcscpy(dest,s); + (void)wcscpy(dest1,s); // cppcheck-suppress uninitvar - (void)wcscpy(d,src); + (void)wcscpy(d,src1); // cppcheck-suppress uninitvar - (void)wcscpy(dest,src); + (void)wcscpy(dest2,src2); // No warning is expected (void)wcscpy(d,s); @@ -3359,18 +3363,18 @@ void uninitvar_strncpy(char * dest, const char * src, size_t num) void uninitvar_strncpy_s(char *Ct, size_t N1, char *S, size_t N2) { char dest[42]; - char *s; + char *s1, *s2; size_t n1; size_t n2; size_t n3; size_t n4; // cppcheck-suppress uninitvar - (void)strncpy_s(dest,n1,s,n2); + (void)strncpy_s(dest,n1,s1,n2); // cppcheck-suppress uninitvar (void)strncpy_s(Ct,n3,S,N2); // cppcheck-suppress uninitvar - (void)strncpy_s(Ct,N1,s,N2); + (void)strncpy_s(Ct,N1,s2,N2); // cppcheck-suppress uninitvar (void)strncpy_s(Ct,N1,S,n4); @@ -3409,14 +3413,14 @@ void uninitvar_strncat(char *d, char *s, size_t n) void uninitvar_strcat_s(char *Ct, size_t N, char *S) { char *ct_1, *ct_2; - char *s; + char *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)strcat_s(ct_1,n1,s); + (void)strcat_s(ct_1,n1,s1); // cppcheck-suppress uninitvar (void)strcat_s(ct_2,N,S); // cppcheck-suppress uninitvar - (void)strcat_s(Ct,N,s); + (void)strcat_s(Ct,N,s2); // cppcheck-suppress uninitvar (void)strcat_s(Ct,n2,S); @@ -3428,14 +3432,14 @@ void uninitvar_strcat_s(char *Ct, size_t N, char *S) void uninitvar_wcscat_s(wchar_t *Ct, size_t N, wchar_t *S) { wchar_t *ct_1, *ct_2; - wchar_t *s; + wchar_t *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)wcscat_s(ct_1,n1,s); + (void)wcscat_s(ct_1,n1,s1); // cppcheck-suppress uninitvar (void)wcscat_s(ct_2,N,S); // cppcheck-suppress uninitvar - (void)wcscat_s(Ct,N,s); + (void)wcscat_s(Ct,N,s2); // cppcheck-suppress uninitvar (void)wcscat_s(Ct,n2,S); @@ -3446,20 +3450,20 @@ void uninitvar_wcscat_s(wchar_t *Ct, size_t N, wchar_t *S) void uninitvar_strncat_s(char *Ct, size_t N1, char *S, size_t N2) { char *ct_1, *ct_2; - char *s; + char *s1, *s2; size_t n1; size_t n2; size_t n3; size_t n4; // cppcheck-suppress uninitvar - (void)strncat_s(ct_1,n1,s,n2); + (void)strncat_s(ct_1,n1,s1,n2); // cppcheck-suppress uninitvar (void)strncat_s(ct_2,N1,S,N2); // cppcheck-suppress uninitvar (void)strncat_s(Ct,n3,S,N2); // cppcheck-suppress uninitvar - (void)strncat_s(Ct,N1,s,N2); + (void)strncat_s(Ct,N1,s2,N2); // cppcheck-suppress uninitvar (void)strncat_s(Ct,N1,S,n4); @@ -3470,14 +3474,14 @@ void uninitvar_strncat_s(char *Ct, size_t N1, char *S, size_t N2) void uninitvar_wcsncat(wchar_t *Ct, wchar_t *S, size_t N) { wchar_t *ct_1, *ct_2; - wchar_t *s; + wchar_t *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)wcsncat(ct_1,s,n1); + (void)wcsncat(ct_1,s1,n1); // cppcheck-suppress uninitvar (void)wcsncat(ct_2,S,N); // cppcheck-suppress uninitvar - (void)wcsncat(Ct,s,N); + (void)wcsncat(Ct,s2,N); // cppcheck-suppress uninitvar (void)wcsncat(Ct,S,n2); @@ -3504,15 +3508,15 @@ void uninitvar_strncmp(char *Ct, char *S, size_t N) void uninitvar_wcsncmp(wchar_t *Ct, wchar_t *S, size_t N) { - wchar_t *ct; - wchar_t *s; + wchar_t *ct1, *ct2; + wchar_t *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)wcsncmp(ct,s,n1); + (void)wcsncmp(ct1,s1,n1); // cppcheck-suppress uninitvar - (void)wcsncmp(ct,S,N); + (void)wcsncmp(ct2,S,N); // cppcheck-suppress uninitvar - (void)wcsncmp(Ct,s,N); + (void)wcsncmp(Ct,s2,N); // cppcheck-suppress uninitvar (void)wcsncmp(Ct,S,n2); @@ -3700,40 +3704,40 @@ void uninitvar_strtok(void) void uninitvar_strtoimax(void) { - const char *s; - char **endp; - int base; + const char *s1, *s2; + char **endp1, **endp2; + int base1, base2; // cppcheck-suppress uninitvar - (void)strtoimax(s,endp,base); + (void)strtoimax(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)strtoumax(s,endp,base); + (void)strtoumax(s2,endp2,base2); } void uninitvar_strtof(void) { - const char *s; - char **endp; + const char *s1, *s2, *s3; + char **endp1, **endp2, **endp3; // cppcheck-suppress uninitvar - (void)strtof(s,endp); + (void)strtof(s1,endp1); // cppcheck-suppress uninitvar - (void)strtod(s,endp); + (void)strtod(s2,endp2); // cppcheck-suppress uninitvar - (void)strtold(s,endp); + (void)strtold(s3,endp3); } void uninitvar_strtol(void) { - const char *s; - char **endp; - int base; + const char *s1, *s2, *s3, *s4; + char **endp1, **endp2, **endp3, **endp4; + int base1, base2, base3, base4; // cppcheck-suppress uninitvar - (void)strtol(s,endp,base); + (void)strtol(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)strtoll(s,endp,base); + (void)strtoll(s2,endp2,base2); // cppcheck-suppress uninitvar - (void)strtoul(s,endp,base); + (void)strtoul(s3,endp3,base3); // cppcheck-suppress uninitvar - (void)strtoull(s,endp,base); + (void)strtoull(s4,endp4,base4); } void uninitvar_time(void) @@ -3752,11 +3756,13 @@ void uninitvar_tmpnam(void) void uninitvar_tolower(int character) { - int c; + int c1; // cppcheck-suppress uninitvar - (void)tolower(c); + (void)tolower(c1); - int *pc=&c; + // cppcheck-suppress unassignedVariable + int c2; + int *pc=&c2; // cppcheck-suppress uninitvar (void)tolower(*pc); @@ -3770,11 +3776,13 @@ void uninitvar_tolower(int character) void uninitvar_toupper(int character) { - int c; + int c1; // cppcheck-suppress uninitvar - (void)toupper(c); + (void)toupper(c1); - int *pc=&c; + // cppcheck-suppress unassignedVariable + int c2; + int *pc=&c2; // cppcheck-suppress uninitvar (void)toupper(*pc); @@ -3788,14 +3796,14 @@ void uninitvar_toupper(int character) void uninitvar_wcstof(void) { - const wchar_t *s; - wchar_t **endp; + const wchar_t *s1, *s2, *s3; + wchar_t **endp1, **endp2, **endp3; // cppcheck-suppress uninitvar - (void)wcstof(s,endp); + (void)wcstof(s1,endp1); // cppcheck-suppress uninitvar - (void)wcstod(s,endp); + (void)wcstod(s2,endp2); // cppcheck-suppress uninitvar - (void)wcstold(s,endp); + (void)wcstold(s3,endp3); } void uninitvar_mbrtowc(void) @@ -3819,28 +3827,28 @@ void uninitvar_wcstok(void) void uninitvar_wcstoimax(void) { - const wchar_t *s; - wchar_t ** endp; - int base; + const wchar_t *s1, *s2; + wchar_t ** endp1, **endp2; + int base1, base2; // cppcheck-suppress uninitvar - (void)wcstoimax(s,endp,base); + (void)wcstoimax(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)wcstoumax(s,endp,base); + (void)wcstoumax(s2,endp2,base2); } void uninitvar_wcstol(void) { - const wchar_t *s; + const wchar_t *s1, *s2, *s3, *s4; wchar_t ** endp; - int base; + int base1, base2, base3, base4; // cppcheck-suppress uninitvar - (void)wcstol(s,endp,base); + (void)wcstol(s1,endp,base1); // cppcheck-suppress uninitvar - (void)wcstoll(s,endp,base); + (void)wcstoll(s2,endp,base2); // cppcheck-suppress uninitvar - (void)wcstoul(s,endp,base); + (void)wcstoul(s3,endp,base3); // cppcheck-suppress uninitvar - (void)wcstoull(s,endp,base); + (void)wcstoull(s4,endp,base4); } void uninitvar_wprintf(wchar_t *Format, int Argument) @@ -3937,15 +3945,15 @@ void uninitvar_fwprintf(void) void uninitvar_snprintf(char *S, size_t N, char *Format, int Int) { size_t n1,n2; - char *format; + char *format1, *format2; int i1, i2; char *s1, *s2; // cppcheck-suppress uninitvar - (void)snprintf(s1,n1,format,i1); + (void)snprintf(s1,n1,format1,i1); // cppcheck-suppress uninitvar (void)snprintf(S,n2,Format,Int); // n is uninitialized // cppcheck-suppress uninitvar - (void)snprintf(S,N,format,Int); // format is uninitialized + (void)snprintf(S,N,format2,Int); // format is uninitialized // cppcheck-suppress uninitvar (void)snprintf(S,N,Format,i2); // i is uninitialized // cppcheck-suppress uninitvar @@ -3979,26 +3987,26 @@ void uninitvar_vsnprintf(char *S, size_t N, char *Format, va_list Arg) void uninitvar_wscanf(void) { - wchar_t *format; + wchar_t *format1, *format2; int i; // cppcheck-suppress uninitvar - (void)wscanf(format); + (void)wscanf(format1); // cppcheck-suppress uninitvar - (void)wscanf(format,&i); + (void)wscanf(format2,&i); } void uninitvar_sscanf(char *s, const char *f, int i, int *ip) { - char *string; + char *string1, *string2, *string3; const char * format; int *pInteger; // cppcheck-suppress uninitvar - (void)sscanf(string,f); + (void)sscanf(string1,f); // cppcheck-suppress uninitvar - (void)sscanf(string,f,i); + (void)sscanf(string2,f,i); // cppcheck-suppress uninitvar - (void)sscanf(string,f,ip); + (void)sscanf(string3,f,ip); // cppcheck-suppress uninitvar (void)sscanf(s,format,&i); // cppcheck-suppress uninitvar diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 5caf8e0e0..ee072d30b 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -604,15 +604,15 @@ void uninitvar_atof(void) void uninitvar_atol(void) { - char * c; + char * c1, *c2, *c3; // cppcheck-suppress uninitvar - (void)std::atoi(c); + (void)std::atoi(c1); // cppcheck-suppress uninitvar - (void)std::atol(c); + (void)std::atol(c2); // cppcheck-suppress uninitvar - (void)std::atoll(c); + (void)std::atoll(c3); } void uninitvar_ceil(void) @@ -1026,13 +1026,13 @@ void uninitar_fopen(void) void uninitar_fprintf(FILE *Stream, char *Format, int Argument) { - FILE *stream; + FILE *stream1, *stream2; char *format1, *format2; int argument1, argument2; // cppcheck-suppress uninitvar - (void)std::fprintf(stream, format1, argument1); + (void)std::fprintf(stream1, format1, argument1); // cppcheck-suppress uninitvar - (void)std::fprintf(stream, Format, Argument); + (void)std::fprintf(stream2, Format, Argument); // cppcheck-suppress uninitvar (void)std::fprintf(Stream, format2, Argument); // cppcheck-suppress uninitvar @@ -1044,14 +1044,14 @@ void uninitar_fprintf(FILE *Stream, char *Format, int Argument) void uninitar_vfprintf(FILE *Stream, const char *Format, va_list Arg) { - FILE *stream; + FILE *stream1, *stream2; char *format1, *format2; va_list arg; // cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress uninitvar - (void)std::vfprintf(stream, format1, arg); + (void)std::vfprintf(stream1, format1, arg); // cppcheck-suppress uninitvar - (void)std::vfprintf(stream, Format, Arg); + (void)std::vfprintf(stream2, Format, Arg); // cppcheck-suppress uninitvar (void)std::vfprintf(Stream, format2, Arg); @@ -1063,14 +1063,14 @@ void uninitar_vfprintf(FILE *Stream, const char *Format, va_list Arg) void uninitar_vfwprintf(FILE *Stream, wchar_t *Format, va_list Arg) { - FILE *stream; + FILE *stream1, *stream2; wchar_t *format1, *format2; va_list arg; // cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress uninitvar - (void)std::vfwprintf(stream, format1, arg); + (void)std::vfwprintf(stream1, format1, arg); // cppcheck-suppress uninitvar - (void)std::vfwprintf(stream, Format, Arg); + (void)std::vfwprintf(stream2, Format, Arg); // cppcheck-suppress uninitvar (void)std::vfwprintf(Stream, format2, Arg); @@ -1281,13 +1281,13 @@ void uninitvar_mbtowc(void) void uninitvar_mbrlen(const char* p, size_t m, mbstate_t* s) { - char* pmb; + char* pmb1, *pmb2; size_t max1, max2; mbstate_t* ps1, *ps2; // cppcheck-suppress uninitvar - (void)std::mbrlen(pmb,max1,ps1); + (void)std::mbrlen(pmb1,max1,ps1); // cppcheck-suppress uninitvar - (void)std::mbrlen(pmb,m,s); + (void)std::mbrlen(pmb2,m,s); // cppcheck-suppress uninitvar (void)std::mbrlen(p,max2,s); // cppcheck-suppress uninitvar @@ -1838,13 +1838,13 @@ void uninitvar_islessgreater(void) void uninitvar_nan(void) { - char *tagp; + char *tagp1, *tagp2, *tagp3; // cppcheck-suppress uninitvar - (void)std::nanf(tagp); + (void)std::nanf(tagp1); // cppcheck-suppress uninitvar - (void)std::nan(tagp); + (void)std::nan(tagp2); // cppcheck-suppress uninitvar - (void)std::nanl(tagp); + (void)std::nanl(tagp3); } void uninitvar_isnan(void) @@ -2449,11 +2449,11 @@ void uninivar_setvbuf(void) void uninitvar_strcat(char *dest, const char * const source) { char *deststr1, *deststr2; - char *srcstr; + char *srcstr1, *srcstr2; // cppcheck-suppress uninitvar - (void)std::strcat(deststr1,srcstr); + (void)std::strcat(deststr1,srcstr1); // cppcheck-suppress uninitvar - (void)std::strcat(dest,srcstr); + (void)std::strcat(dest,srcstr2); // cppcheck-suppress uninitvar (void)std::strcat(deststr2,source); @@ -2464,11 +2464,11 @@ void uninitvar_strcat(char *dest, const char * const source) void uninitvar_wcscat(wchar_t *dest, const wchar_t * const source) { wchar_t *deststr_1, *deststr_2; - wchar_t *srcstr; + wchar_t *srcstr1, *srcstr2; // cppcheck-suppress uninitvar - (void)std::wcscat(deststr_1,srcstr); + (void)std::wcscat(deststr_1,srcstr1); // cppcheck-suppress uninitvar - (void)std::wcscat(dest,srcstr); + (void)std::wcscat(dest,srcstr2); // cppcheck-suppress uninitvar (void)std::wcscat(deststr_2,source); @@ -2577,14 +2577,14 @@ void uninivar_strpbrk(void) void uninivar_strncat(char *Ct, char *S, size_t N) { char *ct_1, *ct_2; - char *s; + char *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)std::strncat(ct_1,s,n1); + (void)std::strncat(ct_1,s1,n1); // cppcheck-suppress uninitvar (void)std::strncat(ct_2,S,N); // cppcheck-suppress uninitvar - (void)std::strncat(Ct,s,N); + (void)std::strncat(Ct,s2,N); // cppcheck-suppress uninitvar (void)std::strncat(Ct,S,n2); @@ -2595,14 +2595,14 @@ void uninivar_strncat(char *Ct, char *S, size_t N) void uninivar_wcsncat(wchar_t *Ct, wchar_t *S, size_t N) { wchar_t *ct_1, *ct_2; - wchar_t *s; + wchar_t *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)std::wcsncat(ct_1,s,n1); + (void)std::wcsncat(ct_1,s1,n1); // cppcheck-suppress uninitvar (void)std::wcsncat(ct_2,S,N); // cppcheck-suppress uninitvar - (void)std::wcsncat(Ct,s,N); + (void)std::wcsncat(Ct,s2,N); // cppcheck-suppress uninitvar (void)std::wcsncat(Ct,S,n2); @@ -2612,15 +2612,15 @@ void uninivar_wcsncat(wchar_t *Ct, wchar_t *S, size_t N) void uninivar_strncmp(char *Ct, char *S, size_t N) { - char *ct; - char *s; + char *ct1, *ct2; + char *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)std::strncmp(ct,s,n1); + (void)std::strncmp(ct1,s1,n1); // cppcheck-suppress uninitvar - (void)std::strncmp(ct,S,N); + (void)std::strncmp(ct2,S,N); // cppcheck-suppress uninitvar - (void)std::strncmp(Ct,s,N); + (void)std::strncmp(Ct,s2,N); // cppcheck-suppress uninitvar (void)std::strncmp(Ct,S,n2); @@ -2630,15 +2630,15 @@ void uninivar_strncmp(char *Ct, char *S, size_t N) void uninivar_wcsncmp(wchar_t *Ct, wchar_t *S, size_t N) { - wchar_t *ct; - wchar_t *s; + wchar_t *ct1, *ct2; + wchar_t *s1, *s2; size_t n1, n2; // cppcheck-suppress uninitvar - (void)std::wcsncmp(ct,s,n1); + (void)std::wcsncmp(ct1,s1,n1); // cppcheck-suppress uninitvar - (void)std::wcsncmp(ct,S,N); + (void)std::wcsncmp(ct2,S,N); // cppcheck-suppress uninitvar - (void)std::wcsncmp(Ct,s,N); + (void)std::wcsncmp(Ct,s2,N); // cppcheck-suppress uninitvar (void)std::wcsncmp(Ct,S,n2); @@ -2795,48 +2795,49 @@ void uninivar_strtok(void) void uninivar_strtoimax(void) { - const char *s; - char **endp; - int base; + const char *s1, *s2; + char **endp1, **endp2; + int base1, base2; // cppcheck-suppress uninitvar - (void)std::strtoimax(s,endp,base); + (void)std::strtoimax(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)std::strtoumax(s,endp,base); + (void)std::strtoumax(s2,endp2,base2); } void uninivar_strtof(void) { - const char *s; - char **endp; + const char *s1, *s2, *s3; + char **endp1, **endp2, **endp3; // cppcheck-suppress uninitvar - (void)std::strtof(s,endp); + (void)std::strtof(s1,endp1); // cppcheck-suppress uninitvar - (void)std::strtod(s,endp); + (void)std::strtod(s2,endp2); // cppcheck-suppress uninitvar - (void)std::strtold(s,endp); + (void)std::strtold(s3,endp3); } void uninivar_strtol(void) { - const char *s; - char **endp; - int base; + const char *s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8; + char **endp1, **endp2, **endp3, **endp4, **endp5, **endp6, **endp7, **endp8; + int base1, base2, base3, base4, base5, base6, base7, base8; + // cppcheck-suppress uninitvar - (void)std::strtol(s,endp,base); + (void)std::strtol(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)std::strtoll(s,endp,base); + (void)std::strtoll(s2,endp2,base2); // cppcheck-suppress uninitvar - (void)std::strtoul(s,endp,base); + (void)std::strtoul(s3,endp3,base3); // cppcheck-suppress uninitvar - (void)std::strtoull(s,endp,base); + (void)std::strtoull(s4,endp4,base4); // cppcheck-suppress uninitvar - (void)std::strtoimax(s,endp,base); + (void)std::strtoimax(s5,endp5,base5); // cppcheck-suppress uninitvar - (void)strtoimax(s,endp,base); + (void)strtoimax(s6,endp6,base6); // cppcheck-suppress uninitvar - (void)std::strtoumax(s,endp,base); + (void)std::strtoumax(s7,endp7,base7); // cppcheck-suppress uninitvar - (void)strtoumax(s,endp,base); + (void)strtoumax(s8,endp8,base8); } void uninitvar_time(void) @@ -2869,14 +2870,14 @@ void uninivar_toupper(void) void uninivar_wcstof(void) { - const wchar_t *s; - wchar_t **endp; + const wchar_t *s1, *s2, *s3; + wchar_t **endp1, **endp2, **endp3; // cppcheck-suppress uninitvar - (void)std::wcstof(s,endp); + (void)std::wcstof(s1,endp1); // cppcheck-suppress uninitvar - (void)std::wcstod(s,endp); + (void)std::wcstod(s2,endp2); // cppcheck-suppress uninitvar - (void)std::wcstold(s,endp); + (void)std::wcstold(s3,endp3); } void uninivar_stoX(void) @@ -3016,50 +3017,50 @@ void uninivar_wcstok(void) void uninivar_wcstoimax(void) { - const wchar_t *s; - wchar_t ** endp; - int base; + const wchar_t *s1, *s2; + wchar_t ** endp1, **endp2; + int base1, base2; // cppcheck-suppress uninitvar - (void)std::wcstoimax(s,endp,base); + (void)std::wcstoimax(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)std::wcstoumax(s,endp,base); + (void)std::wcstoumax(s2,endp2,base2); } void uninivar_wcstol(void) { - const wchar_t *s; - wchar_t ** endp; - int base; + const wchar_t *s1,*s2,*s3,*s4,*s5,*s6,*s7,*s8; + wchar_t **endp1, **endp2, **endp3, **endp4, **endp5, **endp6, **endp7, **endp8; + int base1, base2, base3, base4, base5, base6, base7, base8; // cppcheck-suppress uninitvar - (void)std::wcstol(s,endp,base); + (void)std::wcstol(s1,endp1,base1); // cppcheck-suppress uninitvar - (void)std::wcstoll(s,endp,base); + (void)std::wcstoll(s2,endp2,base2); // cppcheck-suppress uninitvar - (void)std::wcstoul(s,endp,base); + (void)std::wcstoul(s3,endp3,base3); // cppcheck-suppress uninitvar - (void)std::wcstoull(s,endp,base); + (void)std::wcstoull(s4,endp4,base4); // cppcheck-suppress uninitvar - (void)std::wcstoimax(s,endp,base); + (void)std::wcstoimax(s5,endp5,base5); // cppcheck-suppress uninitvar - (void)wcstoimax(s,endp,base); + (void)wcstoimax(s6,endp6,base6); // cppcheck-suppress uninitvar - (void)std::wcstoumax(s,endp,base); + (void)std::wcstoumax(s7,endp7,base7); // cppcheck-suppress uninitvar - (void)wcstoumax(s,endp,base); + (void)wcstoumax(s8,endp8,base8); } void uninitvar_wprintf(wchar_t *Format, int Argument) { - const wchar_t *format; + const wchar_t *format1, *format2, *format3; int argument1, argument2; // cppcheck-suppress uninitvar - (void)std::wprintf(format,argument1); + (void)std::wprintf(format1,argument1); // cppcheck-suppress uninitvar - (void)std::wprintf(format); + (void)std::wprintf(format2); // cppcheck-suppress uninitvar (void)std::wprintf(Format,argument2); // cppcheck-suppress uninitvar - (void)std::wprintf(format,Argument); + (void)std::wprintf(format3,Argument); // no warning is expected (void)std::wprintf(Format,Argument); (void)std::wprintf(Format); @@ -3124,15 +3125,15 @@ void uninivar_fwprintf(void) void uninivar_snprintf(char *S, size_t N, char *Format, int Int) { size_t n1, n2; - char *format; + char *format1, *format2; int i1, i2; char *s1, *s2; // cppcheck-suppress uninitvar - (void)std::snprintf(s1,n1,format,i1); + (void)std::snprintf(s1,n1,format1,i1); // cppcheck-suppress uninitvar (void)std::snprintf(S,n2,Format,Int); // n is uninitialized // cppcheck-suppress uninitvar - (void)std::snprintf(S,N,format,Int); // format is uninitialized + (void)std::snprintf(S,N,format2,Int); // format is uninitialized // cppcheck-suppress uninitvar (void)std::snprintf(S,N,Format,i2); // i is uninitialized // cppcheck-suppress uninitvar @@ -3146,17 +3147,17 @@ void uninivar_vsnprintf(char *S, size_t N, char *Format, va_list Arg) { char *s1, *s2; size_t n1, n2; - char *format; + char *format1, *format2; va_list arg; // cppcheck-suppress va_list_usedBeforeStarted // cppcheck-suppress uninitvar - (void)std::vsnprintf(s1,n1,format,arg); + (void)std::vsnprintf(s1,n1,format1,arg); // cppcheck-suppress uninitvar (void)std::vsnprintf(s2,N,Format,Arg); // cppcheck-suppress uninitvar (void)std::vsnprintf(S,n2,Format,Arg); // cppcheck-suppress uninitvar - (void)std::vsnprintf(S,N,format,Arg); + (void)std::vsnprintf(S,N,format2,Arg); // no warning is expected for (void)std::vsnprintf(S,N,Format,Arg); @@ -3166,23 +3167,23 @@ void uninivar_vsnprintf(char *S, size_t N, char *Format, va_list Arg) void uninivar_wscanf(void) { - wchar_t *format; + wchar_t *format1, *format2; int i; // cppcheck-suppress uninitvar - (void)std::wscanf(format); + (void)std::wscanf(format1); // cppcheck-suppress uninitvar - (void)std::wscanf(format,&i); + (void)std::wscanf(format2,&i); } void uninivar_sscanf(void) { - char *string; + char *string1, *string2; const char * format; int i; // cppcheck-suppress uninitvar - (void)std::sscanf(string,format); + (void)std::sscanf(string1,format); // cppcheck-suppress uninitvar - (void)std::sscanf(string,format,&i); + (void)std::sscanf(string2,format,&i); } void uninivar_fwscanf(void) diff --git a/test/cfg/windows.cpp b/test/cfg/windows.cpp index 6428fa274..cb62468d2 100644 --- a/test/cfg/windows.cpp +++ b/test/cfg/windows.cpp @@ -688,15 +688,15 @@ void uninitvar() // cppcheck-suppress uninitvar CloseHandle(hMutex2); - HANDLE hEvent; + HANDLE hEvent1, hEvent2, hEvent3, hEvent4; // cppcheck-suppress uninitvar - PulseEvent(hEvent); + PulseEvent(hEvent1); // cppcheck-suppress uninitvar - ResetEvent(hEvent); + ResetEvent(hEvent2); // cppcheck-suppress uninitvar - SetEvent(hEvent); + SetEvent(hEvent3); // cppcheck-suppress uninitvar - CloseHandle(hEvent); + CloseHandle(hEvent4); char buf_uninit1[10]; char buf_uninit2[10]; @@ -900,11 +900,11 @@ HANDLE test_CreateThread(LPSECURITY_ATTRIBUTES lpThreadAttributes, unsigned char * uninitvar_mbscat(unsigned char *strDestination, const unsigned char *strSource) { unsigned char *uninit_deststr; - unsigned char *uninit_srcstr; + unsigned char *uninit_srcstr1, *uninit_srcstr2; // cppcheck-suppress uninitvar - (void)_mbscat(uninit_deststr,uninit_srcstr); + (void)_mbscat(uninit_deststr,uninit_srcstr1); // cppcheck-suppress uninitvar - (void)_mbscat(strDestination,uninit_srcstr); + (void)_mbscat(strDestination,uninit_srcstr2); // no warning shall be shown for return _mbscat(strDestination,strSource);