From fd81ee98046ebcf544e84318729a511586772a46 Mon Sep 17 00:00:00 2001 From: orbitcowboy Date: Fri, 11 Sep 2015 16:50:59 +0200 Subject: [PATCH] test/cfg: Improved testing of std.cfg regarding uninitialized and nullPointer checks. --- cfg/std.cfg | 17 +++-------------- test/cfg/runtests.sh | 4 ++-- test/cfg/std.c | 40 ++++++++++++++++++++++++++++++++++++++++ test/cfg/std.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 16 deletions(-) diff --git a/cfg/std.cfg b/cfg/std.cfg index 033f595b3..16bbe802c 100644 --- a/cfg/std.cfg +++ b/cfg/std.cfg @@ -463,7 +463,7 @@ - + false @@ -471,22 +471,11 @@ - - - - - false - - - - - - - - + + false diff --git a/test/cfg/runtests.sh b/test/cfg/runtests.sh index bc7847e1e..37f22f27c 100755 --- a/test/cfg/runtests.sh +++ b/test/cfg/runtests.sh @@ -14,9 +14,9 @@ CPPCHECK_OPT='--check-library --enable=information --enable=style --error-exitco # Compiler settings CXX=g++ -CXX_OPT='-fsyntax-only -std=c++0x -Wno-format-security' +CXX_OPT='-fsyntax-only -std=c++0x -Wno-format-security -Wno-nonnull' CC=gcc -CC_OPT='-Wno-nonnull -Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-format-security -fsyntax-only' +CC_OPT='-Wno-nonnull -Wno-implicit-function-declaration -Wno-deprecated-declarations -Wno-format-security -Wno-nonnull -fsyntax-only' # posix.c ${CC} ${CC_OPT} ${DIR}posix.c diff --git a/test/cfg/std.c b/test/cfg/std.c index 810020c94..0be8f321a 100644 --- a/test/cfg/std.c +++ b/test/cfg/std.c @@ -789,6 +789,13 @@ void uninitvar_atan2(void) (void)atan2l(ld1,ld2); } +void uninitvar_atof(void) +{ + char * c; + // cppcheck-suppress uninitvar + (void)atof(c); +} + void uninitvar_atol(void) { char * c; @@ -3445,3 +3452,36 @@ void nullPointer_fesetenv(void) (void)fesetenv(0); } +void nullPointer_fesetexceptflag(int excepts) +{ + fexcept_t* flagp = 0; + // cppcheck-suppress nullPointer + (void)fesetexceptflag(flagp,excepts); + // cppcheck-suppress nullPointer + (void)fesetexceptflag(0,excepts); +} + +void nullPointer_feupdateenv(void) +{ + fenv_t* envp = 0; + // cppcheck-suppress nullPointer + (void)feupdateenv(envp); + // cppcheck-suppress nullPointer + (void)feupdateenv(0); +} + +void nullPointer_atexit(void) +{ + // cppcheck-suppress nullPointer + (void)atexit(0); +} + +void nullPointer_atof(void) +{ + char * c = 0; + // cppcheck-suppress nullPointer + (void)atof(c); + // cppcheck-suppress nullPointer + (void)atof(0); +} + diff --git a/test/cfg/std.cpp b/test/cfg/std.cpp index 677260b59..08fc7c81b 100644 --- a/test/cfg/std.cpp +++ b/test/cfg/std.cpp @@ -350,6 +350,13 @@ void uninitvar_atan2(void) (void)std::atan2(ld1,ld2); } +void uninitvar_atof(void) +{ + char * c; + // cppcheck-suppress uninitvar + (void)std::atof(c); +} + void uninitvar_atol(void) { char * c; @@ -2799,3 +2806,36 @@ void nullPointer_fesetenv(void) // cppcheck-suppress nullPointer (void)std::fesetenv(0); } + +void nullPointer_fesetexceptflag(int excepts) +{ + fexcept_t* flagp = 0; + // cppcheck-suppress nullPointer + (void)std::fesetexceptflag(flagp,excepts); + // cppcheck-suppress nullPointer + (void)std::fesetexceptflag(0,excepts); +} + +void nullPointer_feupdateenv(void) +{ + fenv_t* envp = 0; + // cppcheck-suppress nullPointer + (void)std::feupdateenv(envp); + // cppcheck-suppress nullPointer + (void)std::feupdateenv(0); +} + +void nullPointer_atexit(void) +{ + // cppcheck-suppress nullPointer + (void)std::atexit(0); +} + +void nullPointer_atof(void) +{ + char * c = 0; + // cppcheck-suppress nullPointer + (void)std::atof(c); + // cppcheck-suppress nullPointer + (void)std::atof(0); +}