Improved const correcntess of local variables.
This commit is contained in:
parent
b94e5ab9cb
commit
33777c5b72
|
@ -434,7 +434,7 @@ static std::string noMemberErrorMessage(const Scope *scope, const char function[
|
|||
{
|
||||
const std::string &classname = scope ? scope->className : "class";
|
||||
const std::string type = (scope && scope->type == Scope::eStruct) ? "Struct" : "Class";
|
||||
bool isDestructor = (function[0] == 'd');
|
||||
const bool isDestructor = (function[0] == 'd');
|
||||
std::string errmsg = "$symbol:" + classname + '\n';
|
||||
|
||||
if (isdefault) {
|
||||
|
@ -1300,7 +1300,7 @@ void CheckClass::operatorEq()
|
|||
returnSelfRef = true;
|
||||
} else {
|
||||
// We might have "Self<template_parameters>&""
|
||||
Token *tok = func->retDef->next();
|
||||
const Token * const tok = func->retDef->next();
|
||||
if (tok && tok->str() == "<" && tok->link() && tok->link()->next() && tok->link()->next()->str() == "&")
|
||||
returnSelfRef = true;
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ void CheckIO::checkFileUsage()
|
|||
if (fileTok->str() == "stdin")
|
||||
fflushOnInputStreamError(tok, fileTok->str());
|
||||
else {
|
||||
Filepointer& f = filepointers[fileTok->varId()];
|
||||
const Filepointer& f = filepointers[fileTok->varId()];
|
||||
if (f.mode == READ_MODE)
|
||||
fflushOnInputStreamError(tok, fileTok->str());
|
||||
}
|
||||
|
|
|
@ -602,7 +602,7 @@ void CheckLeakAutoVar::checkScope(const Token * const startToken,
|
|||
|
||||
tok = typeEndTok->linkAt(2);
|
||||
|
||||
unsigned varid = typeEndTok->next()->varId();
|
||||
const unsigned varid = typeEndTok->next()->varId();
|
||||
if (isPointerReleased(typeEndTok->tokAt(2), endToken, varid))
|
||||
continue;
|
||||
|
||||
|
|
|
@ -1441,7 +1441,7 @@ void CheckOther::checkPassByReference()
|
|||
if (inconclusive && !_settings->inconclusive)
|
||||
continue;
|
||||
|
||||
bool isConst = var->isConst();
|
||||
const bool isConst = var->isConst();
|
||||
if (isConst) {
|
||||
passedByValueError(tok, var->name(), inconclusive);
|
||||
continue;
|
||||
|
|
|
@ -187,7 +187,7 @@ void CheckString::checkSuspiciousStringCompare()
|
|||
|
||||
// Pointer addition?
|
||||
if (varTok->str() == "+" && _tokenizer->isC()) {
|
||||
const Token *tokens[2] = { varTok->astOperand1(), varTok->astOperand2() };
|
||||
const Token * const tokens[2] = { varTok->astOperand1(), varTok->astOperand2() };
|
||||
for (int nr = 0; nr < 2; nr++) {
|
||||
const Token *t = tokens[nr];
|
||||
while (t && (t->str() == "." || t->str() == "::"))
|
||||
|
|
|
@ -857,7 +857,7 @@ void CppCheck::analyseWholeProgram(const std::string &buildDir, const std::map<s
|
|||
//const std::string sourcefile = filesTxtLine.substr(lastColon+1);
|
||||
|
||||
tinyxml2::XMLDocument doc;
|
||||
tinyxml2::XMLError error = doc.LoadFile(xmlfile.c_str());
|
||||
const tinyxml2::XMLError error = doc.LoadFile(xmlfile.c_str());
|
||||
if (error != tinyxml2::XML_SUCCESS)
|
||||
continue;
|
||||
|
||||
|
|
|
@ -268,7 +268,7 @@ bool ErrorLogger::ErrorMessage::deserialize(const std::string &data)
|
|||
iss.get();
|
||||
std::string temp;
|
||||
for (unsigned int i = 0; i < len && iss.good(); ++i) {
|
||||
char c = static_cast<char>(iss.get());
|
||||
const char c = static_cast<char>(iss.get());
|
||||
temp.append(1, c);
|
||||
}
|
||||
|
||||
|
@ -620,7 +620,7 @@ std::string ErrorLogger::toxml(const std::string &str)
|
|||
{
|
||||
std::ostringstream xml;
|
||||
for (std::size_t i = 0U; i < str.length(); i++) {
|
||||
unsigned char c = str[i];
|
||||
const unsigned char c = str[i];
|
||||
switch (c) {
|
||||
case '<':
|
||||
xml << "<";
|
||||
|
|
|
@ -1048,7 +1048,7 @@ std::string MathLib::getSuffix(const std::string& value)
|
|||
bool isUnsigned = false;
|
||||
unsigned int longState = 0;
|
||||
for (std::size_t i = 1U; i < value.size(); ++i) {
|
||||
char c = value[value.size() - i];
|
||||
const char c = value[value.size() - i];
|
||||
if (c == 'u' || c == 'U')
|
||||
isUnsigned = true;
|
||||
else if (c == 'L' || c == 'l')
|
||||
|
|
|
@ -77,7 +77,7 @@ std::string Suppressions::parseFile(std::istream &istr)
|
|||
std::string Suppressions::parseXmlFile(const char *filename)
|
||||
{
|
||||
tinyxml2::XMLDocument doc;
|
||||
tinyxml2::XMLError error = doc.LoadFile(filename);
|
||||
const tinyxml2::XMLError error = doc.LoadFile(filename);
|
||||
if (error == tinyxml2::XML_ERROR_FILE_NOT_FOUND)
|
||||
return "File not found";
|
||||
if (error != tinyxml2::XML_SUCCESS)
|
||||
|
|
|
@ -910,7 +910,7 @@ void SymbolDatabase::createSymbolDatabaseVariableSymbolTable()
|
|||
|
||||
// add all variables
|
||||
for (std::list<Variable>::iterator var = scope->varlist.begin(); var != scope->varlist.end(); ++var) {
|
||||
unsigned int varId = var->declarationId();
|
||||
const unsigned int varId = var->declarationId();
|
||||
if (varId)
|
||||
_variableList[varId] = &(*var);
|
||||
// fix up variables without type
|
||||
|
|
Loading…
Reference in New Issue