Fixed #8076 (unmatched suppression when calling ./runtests.sh (test/cfg))

This commit is contained in:
Daniel Marjamäki 2018-01-10 15:52:06 +01:00
parent dc0bcce3c2
commit 58034dee86
5 changed files with 30 additions and 51 deletions

View File

@ -163,7 +163,7 @@ void uninitvar(int fd)
void *p; void *p;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
write(x,"ab",2); write(x,"ab",2);
// cppcheck-suppress uninitvar // TODO cppcheck-suppress uninitvar
write(fd,buf,2); // #6325 write(fd,buf,2); // #6325
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
write(fd,"ab",x); write(fd,"ab",x);
@ -232,10 +232,9 @@ void timet_h(struct timespec* ptp1)
clock_settime(clk_id, ptp1); clock_settime(clk_id, ptp1);
struct timespec tp; struct timespec tp;
// cppcheck-suppress uninitvar // TODO cppcheck-suppress uninitvar
clock_settime(CLOCK_REALTIME, &tp); // #6577 - false negative clock_settime(CLOCK_REALTIME, &tp); // #6577 - false negative
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
// cppcheck-suppress clock_settimeCalled
clock_settime(clk_id, &tp); clock_settime(clk_id, &tp);
time_t clock = time(0); time_t clock = time(0);

View File

@ -24,7 +24,6 @@ void QString1(QString s)
int QString2() int QString2()
{ {
QString s; QString s;
// cppcheck-suppress ignoredReturnValue
// cppcheck-suppress reademptycontainer // cppcheck-suppress reademptycontainer
return s.size(); return s.size();
} }

View File

@ -7,7 +7,7 @@ if [[ $(pwd) == */test/cfg ]] ; then # we are in test/cfg
DIR="" DIR=""
else # assume we are in repo root else # assume we are in repo root
CPPCHECK="./cppcheck" CPPCHECK="./cppcheck"
DIR=./test/cfg/ DIR=test/cfg/
fi fi
# Cppcheck options # Cppcheck options

View File

@ -162,7 +162,7 @@ void nullpointer(int value)
// #6100 False positive nullPointer - calling mbstowcs(NULL,) // #6100 False positive nullPointer - calling mbstowcs(NULL,)
res += mbstowcs(0,"",0); res += mbstowcs(0,"",0);
// cppcheck-suppress unreadVariable // TODO cppcheck-suppress unreadVariable
res += wcstombs(0,L"",0); res += wcstombs(0,L"",0);
strtok(NULL,"xyz"); strtok(NULL,"xyz");
@ -441,7 +441,7 @@ void uninitvar_asctime(void)
void uninitvar_assert(void) void uninitvar_assert(void)
{ {
int i; int i;
// cppcheck-suppress uninitvar // TODO cppcheck-suppress uninitvar
assert(i); assert(i);
} }
#endif #endif
@ -1206,17 +1206,14 @@ void uninitvar_floor(void)
void uninitvar_fma(void) void uninitvar_fma(void)
{ {
// cppcheck-suppress unassignedVariable
float f1,f2,f3; float f1,f2,f3;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)fmaf(f1,f2,f3); (void)fmaf(f1,f2,f3);
// cppcheck-suppress unassignedVariable
double d1,d2,d3; double d1,d2,d3;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)fma(d1,d2,d3); (void)fma(d1,d2,d3);
// cppcheck-suppress unassignedVariable
long double ld1,ld2,ld3; long double ld1,ld2,ld3;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)fmal(ld1,ld2,ld3); (void)fmal(ld1,ld2,ld3);
@ -3364,17 +3361,14 @@ void uninitvar_sprintf(char *S, char *Format, int Argument)
int argument; int argument;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)sprintf(s,format,argument); (void)sprintf(s,format,argument);
// cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)sprintf(s,Format,Argument); (void)sprintf(s,Format,Argument);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)sprintf(S,format,Argument); (void)sprintf(S,format,Argument);
// cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)sprintf(S,Format,argument); (void)sprintf(S,Format,argument);
// no warning is expected for // no warning is expected for
// cppcheck-suppress redundantCopy
(void)sprintf(S,Format,Argument); (void)sprintf(S,Format,Argument);
} }
@ -3427,18 +3421,14 @@ void uninivar_snprintf(char *S, size_t N, char *Format, int Int)
(void)snprintf(s,n,format,i); (void)snprintf(s,n,format,i);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)snprintf(S,n,Format,Int); // n is uninitialized (void)snprintf(S,n,Format,Int); // n is uninitialized
// cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)snprintf(S,N,format,Int); // format is uninitialized (void)snprintf(S,N,format,Int); // format is uninitialized
// cppcheck-suppress redundantCopy
// 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 // TODO cppcheck-suppress uninitvar
// cppcheck-suppress uninitvar
(void)snprintf(s,N,Format,Int); (void)snprintf(s,N,Format,Int);
// no warning is expected for // no warning is expected for
// cppcheck-suppress redundantCopy
(void)snprintf(S,N,Format,Int); (void)snprintf(S,N,Format,Int);
} }
@ -3587,7 +3577,6 @@ void ignoredReturnValue_abs(int i)
{ {
// cppcheck-suppress ignoredReturnValue // cppcheck-suppress ignoredReturnValue
abs(i); abs(i);
// cppcheck-suppress constStatement
// cppcheck-suppress ignoredReturnValue // cppcheck-suppress ignoredReturnValue
abs(-100); abs(-100);
} }
@ -3691,7 +3680,7 @@ void invalidPrintfArgType_printf(void)
// #7016 // #7016
uint8_t n = 7; uint8_t n = 7;
// cppcheck-suppress invalidPrintfArgType_uint // TODO cppcheck-suppress invalidPrintfArgType_uint
printf("%"PRIi16"\n", n); printf("%"PRIi16"\n", n);
} }
@ -3707,41 +3696,41 @@ void valueFlow(void)
// When adding functions below, please sort alphabetically. // When adding functions below, please sort alphabetically.
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(strlen(abc) == 3); AssertAlwaysTrue(strlen(abc) == 3);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(abs(three) == 3); AssertAlwaysTrue(abs(three) == 3);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(abs(minusThree) == 3); AssertAlwaysTrue(abs(minusThree) == 3);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isblank(blank) == 1); AssertAlwaysTrue(isblank(blank) == 1);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isblank(tab) == 1); AssertAlwaysTrue(isblank(tab) == 1);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isblank(c0) == 0); AssertAlwaysTrue(isblank(c0) == 0);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isdigit(c0) == 1); AssertAlwaysTrue(isdigit(c0) == 1);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(isdigit(ca) == 0); AssertAlwaysTrue(isdigit(ca) == 0);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(iswblank(wblank) == 1); AssertAlwaysTrue(iswblank(wblank) == 1);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(iswblank(wtab) == 1); AssertAlwaysTrue(iswblank(wtab) == 1);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(iswblank(w0) == 0); AssertAlwaysTrue(iswblank(w0) == 0);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(iswdigit(w0) == 0); AssertAlwaysTrue(iswdigit(w0) == 0);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(iswdigit(wtab) == 1); AssertAlwaysTrue(iswdigit(wtab) == 1);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(labs(three) == 3); AssertAlwaysTrue(labs(three) == 3);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(labs(minusThree) == 3); AssertAlwaysTrue(labs(minusThree) == 3);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(llabs(three) == 3); AssertAlwaysTrue(llabs(three) == 3);
// cppcheck-suppress knownConditionTrueFalse // TODO cppcheck-suppress knownConditionTrueFalse
AssertAlwaysTrue(llabs(minusThree) == 3); AssertAlwaysTrue(llabs(minusThree) == 3);
} }

View File

@ -132,7 +132,7 @@ void uninitvar_proj(void)
{ {
double d; double d;
const std::complex<double> dc(d,d); const std::complex<double> dc(d,d);
// cppcheck-suppress uninitvar // TODO cppcheck-suppress uninitvar
(void)std::proj(dc); (void)std::proj(dc);
} }
@ -725,17 +725,14 @@ void uninitvar_floor(void)
void uninitvar_fma(void) void uninitvar_fma(void)
{ {
// cppcheck-suppress unassignedVariable
float f1,f2,f3; float f1,f2,f3;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::fmaf(f1,f2,f3); (void)std::fmaf(f1,f2,f3);
// cppcheck-suppress unassignedVariable
double d1,d2,d3; double d1,d2,d3;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::fma(d1,d2,d3); (void)std::fma(d1,d2,d3);
// cppcheck-suppress unassignedVariable
long double ld1,ld2,ld3; long double ld1,ld2,ld3;
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::fmal(ld1,ld2,ld3); (void)std::fmal(ld1,ld2,ld3);
@ -2842,18 +2839,14 @@ void uninivar_snprintf(char *S, size_t N, char *Format, int Int)
(void)std::snprintf(s,n,format,i); (void)std::snprintf(s,n,format,i);
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::snprintf(S,n,Format,Int); // n is uninitialized (void)std::snprintf(S,n,Format,Int); // n is uninitialized
// cppcheck-suppress redundantCopy
// cppcheck-suppress uninitvar // cppcheck-suppress uninitvar
(void)std::snprintf(S,N,format,Int); // format is uninitialized (void)std::snprintf(S,N,format,Int); // format is uninitialized
// cppcheck-suppress redundantCopy
// 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 // TODO cppcheck-suppress uninitvar
// cppcheck-suppress uninitvar
(void)std::snprintf(s,N,Format,Int); (void)std::snprintf(s,N,Format,Int);
// no warning is expected for // no warning is expected for
// cppcheck-suppress redundantCopy
(void)std::snprintf(S,N,Format,Int); (void)std::snprintf(S,N,Format,Int);
} }
@ -2939,14 +2932,14 @@ void uninitvar_setw(void)
void uninitvar_setiosflags(void) void uninitvar_setiosflags(void)
{ {
std::ios_base::fmtflags mask; std::ios_base::fmtflags mask;
// cppcheck-suppress uninitvar // TODO cppcheck-suppress uninitvar
std::cout << std::setiosflags(mask); // #6987 - false negative std::cout << std::setiosflags(mask); // #6987 - false negative
} }
void uninitvar_resetiosflags(void) void uninitvar_resetiosflags(void)
{ {
std::ios_base::fmtflags mask; std::ios_base::fmtflags mask;
// cppcheck-suppress uninitvar // TODO cppcheck-suppress uninitvar
std::cout << std::resetiosflags(mask); // #6987 - false negative std::cout << std::resetiosflags(mask); // #6987 - false negative
} }
@ -3040,20 +3033,19 @@ void ignoredReturnValue_abs(int i)
{ {
// cppcheck-suppress ignoredReturnValue // cppcheck-suppress ignoredReturnValue
std::abs(i); std::abs(i);
// cppcheck-suppress constStatement
// cppcheck-suppress ignoredReturnValue // cppcheck-suppress ignoredReturnValue
std::abs(-199); std::abs(-199);
} }
void nullPointer_ifstream_read(std::ifstream &f) void nullPointer_ifstream_read(std::ifstream &f)
{ {
// cppcheck-suppress nullPointer // TODO cppcheck-suppress nullPointer
f.read(NULL, 10); f.read(NULL, 10);
} }
void nullPointer_istream_read(std::istream &f) void nullPointer_istream_read(std::istream &f)
{ {
// cppcheck-suppress nullPointer // TODO cppcheck-suppress nullPointer
f.read(NULL, 10); f.read(NULL, 10);
} }