From a01bfcb62d329457468f9053d93bf57d55755ef9 Mon Sep 17 00:00:00 2001 From: PKEuS Date: Fri, 28 Mar 2014 18:55:16 +0100 Subject: [PATCH] Fixed a few cppcheck messages --- lib/checkio.cpp | 4 ++-- lib/checknullpointer.cpp | 2 +- test/testlibrary.cpp | 12 ++++++------ test/testmathlib.cpp | 8 ++++---- test/testpreprocessor.cpp | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/checkio.cpp b/lib/checkio.cpp index 4bdd10c91..6c59d8381 100644 --- a/lib/checkio.cpp +++ b/lib/checkio.cpp @@ -182,7 +182,7 @@ void CheckIO::checkFileUsage() operation = Filepointer::OPEN; } else if ((tok->str() == "rewind" || tok->str() == "fseek" || tok->str() == "fsetpos" || tok->str() == "fflush") || (windows && tok->str() == "_fseeki64")) { - if (Token::simpleMatch(tok, "fflush ( stdin )")) + if (Token::simpleMatch(tok, "fflush ( stdin )") && !_settings->standards.posix) fflushOnInputStreamError(tok, tok->strAt(2)); else { fileTok = tok->tokAt(2); @@ -667,7 +667,7 @@ void CheckIO::checkWrongPrintfScanfArguments() invalidScanfFormatWidthError(tok, numFormat, numWidth, argInfo.variableInfo); } } - if (argListTok->type() != Token::eString && + if (argListTok && argListTok->type() != Token::eString && argInfo.isKnownType() && argInfo.isArrayOrPointer() && (!Token::Match(argInfo.typeToken, "char|wchar_t") || argInfo.typeToken->strAt(-1) == "const")) { diff --git a/lib/checknullpointer.cpp b/lib/checknullpointer.cpp index 010a2642e..21de12494 100644 --- a/lib/checknullpointer.cpp +++ b/lib/checknullpointer.cpp @@ -788,7 +788,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef() } // init function (global variables) - if (!var || !(var->isLocal() || var->isArgument())) + if (!(var->isLocal() || var->isArgument())) break; } diff --git a/test/testlibrary.cpp b/test/testlibrary.cpp index c0824e18a..0cd937f50 100644 --- a/test/testlibrary.cpp +++ b/test/testlibrary.cpp @@ -37,7 +37,7 @@ private: TEST_CASE(resource); } - void empty() { + void empty() const { const char xmldata[] = "\n"; tinyxml2::XMLDocument doc; doc.Parse(xmldata, sizeof(xmldata)); @@ -49,7 +49,7 @@ private: ASSERT(library.argumentChecks.empty()); } - void function() { + void function() const { const char xmldata[] = "\n" "\n" " \n" @@ -67,7 +67,7 @@ private: ASSERT(library.isnotnoreturn("foo")); } - void function_arg() { + void function_arg() const { const char xmldata[] = "\n" "\n" " \n" @@ -92,7 +92,7 @@ private: ASSERT_EQUALS(true, library.argumentChecks["foo"][6].notbool); } - void function_arg_any() { + void function_arg_any() const { const char xmldata[] = "\n" "\n" "\n" @@ -107,7 +107,7 @@ private: ASSERT_EQUALS(true, library.argumentChecks["foo"][-1].notuninit); } - void memory() { + void memory() const { const char xmldata[] = "\n" "\n" " \n" @@ -128,7 +128,7 @@ private: ASSERT_EQUALS(library.alloc("CreateX"), library.dealloc("DeleteX")); } - void resource() { + void resource() const { const char xmldata[] = "\n" "\n" " \n" diff --git a/test/testmathlib.cpp b/test/testmathlib.cpp index c61bdf380..75a5f4483 100644 --- a/test/testmathlib.cpp +++ b/test/testmathlib.cpp @@ -325,7 +325,7 @@ private: ASSERT_EQUALS(false, MathLib::isInt("")); } - void isbin() { + void isbin() const { // positive testing ASSERT_EQUALS(true, MathLib::isBin("0b0")); ASSERT_EQUALS(true, MathLib::isBin("0b1")); @@ -381,7 +381,7 @@ private: ASSERT_EQUALS(false, MathLib::isNegative("")); } - void isoct() { + void isoct() const { // octal number format: [+|-]0[0-7][suffix] // positive testing ASSERT_EQUALS(true, MathLib::isOct("010")); @@ -442,7 +442,7 @@ private: ASSERT_EQUALS(false, MathLib::isOct(" -042ULL ")); } - void ishex() { + void ishex() const { // hex number syntax: [sign]0x[hexnumbers][suffix] // positive testing @@ -592,7 +592,7 @@ private: ASSERT_EQUALS(true , MathLib::isFloat("-1.0E+1")); } - void naninf() { + void naninf() const { ASSERT_EQUALS("nan.0", MathLib::divide("0.0", "0.0")); // nan ASSERT_EQUALS("inf.0", MathLib::divide("3.0", "0.0")); // inf ASSERT_EQUALS("-inf.0", MathLib::divide("-3.0", "0.0")); // -inf (#5142) diff --git a/test/testpreprocessor.cpp b/test/testpreprocessor.cpp index fe03b02b8..ce58b62df 100644 --- a/test/testpreprocessor.cpp +++ b/test/testpreprocessor.cpp @@ -2622,7 +2622,7 @@ private: // expand macros.. errout.str(""); - const std::string actual(OurPreprocessor::expandMacros(filedata, this)); + OurPreprocessor::expandMacros(filedata, this); ASSERT_EQUALS("[file.cpp:7]: (error) No pair for character (\"). Can't process file. File is either invalid or unicode, which is currently not supported.\n", errout.str()); }