Skip to content

Commit

Permalink
changed bool_to_string() return const char* instead
Browse files Browse the repository at this point in the history
  • Loading branch information
firewave committed Sep 5, 2023
1 parent 4857b54 commit 4df01ca
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions gui/cppchecklibrarydata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -617,7 +617,7 @@ static void writeFunction(QXmlStreamWriter &xmlWriter, const CppcheckLibraryData
xmlWriter.writeEndElement();
}
if (function.noreturn != CppcheckLibraryData::Function::Unknown)
xmlWriter.writeTextElement("noreturn", QString::fromStdString(bool_to_string(function.noreturn == CppcheckLibraryData::Function::True)));
xmlWriter.writeTextElement("noreturn", bool_to_string(function.noreturn == CppcheckLibraryData::Function::True));
if (function.leakignore)
xmlWriter.writeEmptyElement("leak-ignore");
// Argument info..
Expand Down Expand Up @@ -721,7 +721,7 @@ static void writeMemoryResource(QXmlStreamWriter &xmlWriter, const CppcheckLibra
} else {
xmlWriter.writeStartElement("alloc");
}
xmlWriter.writeAttribute("init", QString::fromStdString(bool_to_string(alloc.init)));
xmlWriter.writeAttribute("init", bool_to_string(alloc.init));
if (alloc.arg != -1) {
xmlWriter.writeAttribute("arg", QString("%1").arg(alloc.arg));
}
Expand Down
10 changes: 5 additions & 5 deletions gui/librarydialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,11 @@ QString LibraryDialog::getArgText(const CppcheckLibraryData::Function::Arg &arg)
if (arg.nr != CppcheckLibraryData::Function::Arg::ANY)
s += QString::number(arg.nr);

s += "\n not bool: " + QString::fromStdString(bool_to_string(arg.notbool));
s += "\n not null: " + QString::fromStdString(bool_to_string(arg.notnull));
s += "\n not uninit: " + QString::fromStdString(bool_to_string(arg.notuninit));
s += "\n format string: " + QString::fromStdString(bool_to_string(arg.formatstr));
s += "\n strz: " + QString::fromStdString(bool_to_string(arg.strz));
s += "\n not bool: " + QString(bool_to_string(arg.notbool));
s += "\n not null: " + QString(bool_to_string(arg.notnull));
s += "\n not uninit: " + QString(bool_to_string(arg.notuninit));
s += "\n format string: " + QString(bool_to_string(arg.formatstr));
s += "\n strz: " + QString(bool_to_string(arg.strz));
s += "\n valid: " + QString(arg.valid.isEmpty() ? "any" : arg.valid);
for (const CppcheckLibraryData::Function::Arg::MinSize &minsize : arg.minsizes) {
s += "\n minsize: " + minsize.type + " " + minsize.arg + " " + minsize.arg2;
Expand Down
6 changes: 3 additions & 3 deletions gui/projectfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ bool ProjectFile::write(const QString &filename)
}

xmlWriter.writeStartElement(CppcheckXml::AnalyzeAllVsConfigsElementName);
xmlWriter.writeCharacters(QString::fromStdString(bool_to_string(mAnalyzeAllVsConfigs)));
xmlWriter.writeCharacters(bool_to_string(mAnalyzeAllVsConfigs));
xmlWriter.writeEndElement();

if (clangParser) {
Expand All @@ -858,11 +858,11 @@ bool ProjectFile::write(const QString &filename)
}

xmlWriter.writeStartElement(CppcheckXml::CheckHeadersElementName);
xmlWriter.writeCharacters(QString::fromStdString(bool_to_string(mCheckHeaders)));
xmlWriter.writeCharacters(bool_to_string(mCheckHeaders));
xmlWriter.writeEndElement();

xmlWriter.writeStartElement(CppcheckXml::CheckUnusedTemplatesElementName);
xmlWriter.writeCharacters(QString::fromStdString(bool_to_string(mCheckUnusedTemplates)));
xmlWriter.writeCharacters(bool_to_string(mCheckUnusedTemplates));
xmlWriter.writeEndElement();

xmlWriter.writeStartElement(CppcheckXml::MaxCtuDepthElementName);
Expand Down
2 changes: 1 addition & 1 deletion lib/checkcondition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ void CheckCondition::assignIfError(const Token *tok1, const Token *tok2, const s
reportError(locations,
Severity::style,
"assignIfError",
"Mismatching assignment and comparison, comparison '" + condition + "' is always " + bool_to_string(result) + ".", CWE398, Certainty::normal);
"Mismatching assignment and comparison, comparison '" + condition + "' is always " + std::string(bool_to_string(result)) + ".", CWE398, Certainty::normal);
}


Expand Down
2 changes: 1 addition & 1 deletion lib/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ static inline std::string id_string(const void* p)
return id_string_i(reinterpret_cast<uintptr_t>(p));
}

static inline std::string bool_to_string(bool b)
static inline const char* bool_to_string(bool b)
{
return b ? "true" : "false";
}
Expand Down

0 comments on commit 4df01ca

Please sign in to comment.