Fixed a few cppcheck messages
This commit is contained in:
parent
4e19645d62
commit
a01bfcb62d
|
@ -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")) {
|
||||
|
|
|
@ -788,7 +788,7 @@ void CheckNullPointer::nullPointerByCheckAndDeRef()
|
|||
}
|
||||
|
||||
// init function (global variables)
|
||||
if (!var || !(var->isLocal() || var->isArgument()))
|
||||
if (!(var->isLocal() || var->isArgument()))
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -37,7 +37,7 @@ private:
|
|||
TEST_CASE(resource);
|
||||
}
|
||||
|
||||
void empty() {
|
||||
void empty() const {
|
||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n<def/>";
|
||||
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[] = "<?xml version=\"1.0\"?>\n"
|
||||
"<def>\n"
|
||||
" <function name=\"foo\">\n"
|
||||
|
@ -67,7 +67,7 @@ private:
|
|||
ASSERT(library.isnotnoreturn("foo"));
|
||||
}
|
||||
|
||||
void function_arg() {
|
||||
void function_arg() const {
|
||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||
"<def>\n"
|
||||
" <function name=\"foo\">\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[] = "<?xml version=\"1.0\"?>\n"
|
||||
"<def>\n"
|
||||
"<function name=\"foo\">\n"
|
||||
|
@ -107,7 +107,7 @@ private:
|
|||
ASSERT_EQUALS(true, library.argumentChecks["foo"][-1].notuninit);
|
||||
}
|
||||
|
||||
void memory() {
|
||||
void memory() const {
|
||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||
"<def>\n"
|
||||
" <memory>\n"
|
||||
|
@ -128,7 +128,7 @@ private:
|
|||
ASSERT_EQUALS(library.alloc("CreateX"), library.dealloc("DeleteX"));
|
||||
}
|
||||
|
||||
void resource() {
|
||||
void resource() const {
|
||||
const char xmldata[] = "<?xml version=\"1.0\"?>\n"
|
||||
"<def>\n"
|
||||
" <resource>\n"
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue