From 58034dee869677cb0c612b61f4e0e7c620bc6b08 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Wed, 10 Jan 2018 15:52:06 +0100 Subject: [PATCH] Fixed #8076 (unmatched suppression when calling ./runtests.sh (test/cfg)) --- test/cfg/posix.c | 5 ++--- test/cfg/qt.cpp | 1 - test/cfg/runtests.sh | 2 +- test/cfg/std.c | 53 ++++++++++++++++++-------------------------- test/cfg/std.cpp | 20 +++++------------ 5 files changed, 30 insertions(+), 51 deletions(-) diff --git a/test/cfg/posix.c b/test/cfg/posix.c index 5c5c21e89..40c8c9001 100644 --- a/test/cfg/posix.c +++ b/test/cfg/posix.c @@ -163,7 +163,7 @@ void uninitvar(int fd) void *p; // cppcheck-suppress uninitvar write(x,"ab",2); - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar write(fd,buf,2); // #6325 // cppcheck-suppress uninitvar write(fd,"ab",x); @@ -232,10 +232,9 @@ void timet_h(struct timespec* ptp1) clock_settime(clk_id, ptp1); struct timespec tp; - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar clock_settime(CLOCK_REALTIME, &tp); // #6577 - false negative // cppcheck-suppress uninitvar - // cppcheck-suppress clock_settimeCalled clock_settime(clk_id, &tp); time_t clock = time(0); diff --git a/test/cfg/qt.cpp b/test/cfg/qt.cpp index b75d8f507..f1b0693db 100644 --- a/test/cfg/qt.cpp +++ b/test/cfg/qt.cpp @@ -24,7 +24,6 @@ void QString1(QString s) int QString2() { QString s; - // cppcheck-suppress ignoredReturnValue // cppcheck-suppress reademptycontainer return s.size(); } diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index f5ebf5e08..3e97d3200 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -7,7 +7,7 @@ if [[ $(pwd) == */test/cfg ]] ; then # we are in test/cfg DIR="" else # assume we are in repo root CPPCHECK="./cppcheck" - DIR=./test/cfg/ + DIR=test/cfg/ fi # Cppcheck options diff --git a/test/cfg/std.c b/test/cfg/std.c index c02adf49e..7673b3ace 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -162,7 +162,7 @@ void nullpointer(int value) // #6100 False positive nullPointer - calling mbstowcs(NULL,) res += mbstowcs(0,"",0); - // cppcheck-suppress unreadVariable + // TODO cppcheck-suppress unreadVariable res += wcstombs(0,L"",0); strtok(NULL,"xyz"); @@ -441,7 +441,7 @@ void uninitvar_asctime(void) void uninitvar_assert(void) { int i; - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar assert(i); } #endif @@ -1206,17 +1206,14 @@ void uninitvar_floor(void) void uninitvar_fma(void) { - // cppcheck-suppress unassignedVariable float f1,f2,f3; // cppcheck-suppress uninitvar (void)fmaf(f1,f2,f3); - // cppcheck-suppress unassignedVariable double d1,d2,d3; // cppcheck-suppress uninitvar (void)fma(d1,d2,d3); - // cppcheck-suppress unassignedVariable long double ld1,ld2,ld3; // cppcheck-suppress uninitvar (void)fmal(ld1,ld2,ld3); @@ -3364,17 +3361,14 @@ void uninitvar_sprintf(char *S, char *Format, int Argument) int argument; // cppcheck-suppress uninitvar (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); } @@ -3427,18 +3421,14 @@ void uninivar_snprintf(char *S, size_t N, char *Format, int Int) (void)snprintf(s,n,format,i); // cppcheck-suppress uninitvar (void)snprintf(S,n,Format,Int); // n is uninitialized - // cppcheck-suppress redundantCopy // cppcheck-suppress uninitvar (void)snprintf(S,N,format,Int); // format is uninitialized - // cppcheck-suppress redundantCopy // cppcheck-suppress uninitvar (void)snprintf(S,N,Format,i); // i is uninitialized - // cppcheck-suppress redundantCopy - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar (void)snprintf(s,N,Format,Int); // no warning is expected for - // cppcheck-suppress redundantCopy (void)snprintf(S,N,Format,Int); } @@ -3587,7 +3577,6 @@ void ignoredReturnValue_abs(int i) { // cppcheck-suppress ignoredReturnValue abs(i); - // cppcheck-suppress constStatement // cppcheck-suppress ignoredReturnValue abs(-100); } @@ -3691,7 +3680,7 @@ void invalidPrintfArgType_printf(void) // #7016 uint8_t n = 7; - // cppcheck-suppress invalidPrintfArgType_uint + // TODO cppcheck-suppress invalidPrintfArgType_uint printf("%"PRIi16"\n", n); } @@ -3707,41 +3696,41 @@ void valueFlow(void) // When adding functions below, please sort alphabetically. - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(strlen(abc) == 3); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(abs(three) == 3); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(abs(minusThree) == 3); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(isblank(blank) == 1); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(isblank(tab) == 1); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(isblank(c0) == 0); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(isdigit(c0) == 1); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(isdigit(ca) == 0); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(iswblank(wblank) == 1); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(iswblank(wtab) == 1); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(iswblank(w0) == 0); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(iswdigit(w0) == 0); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(iswdigit(wtab) == 1); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(labs(three) == 3); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(labs(minusThree) == 3); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(llabs(three) == 3); - // cppcheck-suppress knownConditionTrueFalse + // TODO cppcheck-suppress knownConditionTrueFalse AssertAlwaysTrue(llabs(minusThree) == 3); } diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 61e43bcfe..3a0671f10 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -132,7 +132,7 @@ void uninitvar_proj(void) { double d; const std::complex dc(d,d); - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar (void)std::proj(dc); } @@ -725,17 +725,14 @@ void uninitvar_floor(void) void uninitvar_fma(void) { - // cppcheck-suppress unassignedVariable float f1,f2,f3; // cppcheck-suppress uninitvar (void)std::fmaf(f1,f2,f3); - // cppcheck-suppress unassignedVariable double d1,d2,d3; // cppcheck-suppress uninitvar (void)std::fma(d1,d2,d3); - // cppcheck-suppress unassignedVariable long double ld1,ld2,ld3; // cppcheck-suppress uninitvar (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); // cppcheck-suppress uninitvar (void)std::snprintf(S,n,Format,Int); // n is uninitialized - // cppcheck-suppress redundantCopy // cppcheck-suppress uninitvar (void)std::snprintf(S,N,format,Int); // format is uninitialized - // cppcheck-suppress redundantCopy // cppcheck-suppress uninitvar (void)std::snprintf(S,N,Format,i); // i is uninitialized - // cppcheck-suppress redundantCopy - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar (void)std::snprintf(s,N,Format,Int); // no warning is expected for - // cppcheck-suppress redundantCopy (void)std::snprintf(S,N,Format,Int); } @@ -2939,14 +2932,14 @@ void uninitvar_setw(void) void uninitvar_setiosflags(void) { std::ios_base::fmtflags mask; - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar std::cout << std::setiosflags(mask); // #6987 - false negative } void uninitvar_resetiosflags(void) { std::ios_base::fmtflags mask; - // cppcheck-suppress uninitvar + // TODO cppcheck-suppress uninitvar std::cout << std::resetiosflags(mask); // #6987 - false negative } @@ -3040,20 +3033,19 @@ void ignoredReturnValue_abs(int i) { // cppcheck-suppress ignoredReturnValue std::abs(i); - // cppcheck-suppress constStatement // cppcheck-suppress ignoredReturnValue std::abs(-199); } void nullPointer_ifstream_read(std::ifstream &f) { - // cppcheck-suppress nullPointer + // TODO cppcheck-suppress nullPointer f.read(NULL, 10); } void nullPointer_istream_read(std::istream &f) { - // cppcheck-suppress nullPointer + // TODO cppcheck-suppress nullPointer f.read(NULL, 10); }