Skip to content

Commit 4a73c93

Browse files
author
Andrew C. Martin
committed
Fix compiler warnings and comment/string typos
- fix g++ warning: > lib/checkother.cpp:3779: warning: comparison between signed and unsigned integer expressions - fix suncc warning (see [everything2](http://everything2.com/title/C%252B%252B%253A+static+extern+%2522C%2522)): > "lib/checkmemoryleak.cpp", line 578: Warning (Anachronism): Formal argument __compar of type extern "C" int(*)(const void*,const void*) in call to bsearch(const void*, const void*, unsigned long, unsigned long, extern "C" int(*)(const void*,const void*)) is being passed int(*)(const void*,const void*). - prefer empty() / isEmpty() over "size() > 0" (cases not caught by stlSize) - fix word misspellings (mostly comments, a few output lines) - Parenthesis => Parentheses (both variations were used in the codebase) - fix typo and wording ("never alwayw") in gui/test/data/benchmark/simple.cpp's CheckOther::unsignedPositive(): ``` - "An unsigned variable will never alwayw be positive so it is either pointless or " + "An unsigned variable can't be negative so it is either pointless or " ```
1 parent 78f3c5f commit 4a73c93

32 files changed

Lines changed: 102 additions & 100 deletions

cli/cmdlineparser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ bool CmdLineParser::ParseFromArgs(int argc, const char* const argv[])
210210
}
211211

212212
// Filter errors
213-
// This is deprecated, see --supressions-list above
213+
// This is deprecated, see --suppressions-list above
214214
else if (std::strcmp(argv[i], "--suppressions") == 0) {
215215
++i;
216216

cli/threadexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ unsigned int ThreadExecutor::check()
186186
fileChecker.settings() = _settings;
187187
unsigned int resultOfCheck = 0;
188188

189-
if (_fileContents.size() > 0 && _fileContents.find(i->first) != _fileContents.end()) {
189+
if (!_fileContents.empty() && _fileContents.find(i->first) != _fileContents.end()) {
190190
// File content was given as a string
191191
resultOfCheck = fileChecker.check(i->first, _fileContents[ i->first ]);
192192
} else {

gui/scratchpad.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ ScratchPad::ScratchPad(MainWindow& mainWindow)
3232
void ScratchPad::CheckButtonClicked()
3333
{
3434
QString filename = mUI.lineEdit->text();
35-
if (filename.size() == 0)
35+
if (filename.isEmpty())
3636
filename = "test.cpp";
3737
mMainWindow.CheckCode(mUI.plainTextEdit->toPlainText(), filename);
3838
}

gui/settingsdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ void SettingsDialog::EditApplication()
242242
void SettingsDialog::DefaultApplication()
243243
{
244244
QList<QListWidgetItem *> selected = mUI.mListWidget->selectedItems();
245-
if (selected.size() > 0) {
245+
if (!selected.isEmpty()) {
246246
int index = mUI.mListWidget->row(selected[0]);
247247
mTempApplications->SetDefault(index);
248248
mUI.mListWidget->clear();

gui/test/data/benchmark/simple.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ void CheckOther::checkIncorrectLogicOperator()
532532
const Token *endTok = tok ? tok->next()->link() : NULL;
533533

534534
while (tok && endTok) {
535-
// Find a pair of OR'd terms, with or without parenthesis
535+
// Find a pair of OR'd terms, with or without parentheses
536536
// e.g. if (x != 3 || x != 4)
537537
const Token *logicTok = NULL, *term1Tok = NULL, *term2Tok = NULL;
538538
const Token *op1Tok = NULL, *op2Tok = NULL, *op3Tok = NULL, *nextTok = NULL;
@@ -2772,7 +2772,7 @@ void CheckOther::checkMathFunctions()
27722772
MathLib::toLongNumber(tok->tokAt(2)->str()) <= 0) {
27732773
mathfunctionCallError(tok);
27742774
}
2775-
// acos( x ), asin( x ) where x is defined for intervall [-1,+1], but not beyound
2775+
// acos( x ), asin( x ) where x is defined for interval [-1,+1], but not beyond
27762776
else if (tok->varId() == 0 &&
27772777
Token::Match(tok, "acos|asin ( %num% )") &&
27782778
std::fabs(MathLib::toDoubleNumber(tok->tokAt(2)->str())) > 1.0) {
@@ -3508,6 +3508,6 @@ void CheckOther::unsignedPositive(const Token *tok, const std::string &varname)
35083508
{
35093509
reportError(tok, Severity::style, "unsignedPositive",
35103510
"Checking if unsigned variable '" + varname + "' is positive is always true.\n"
3511-
"An unsigned variable will never alwayw be positive so it is either pointless or "
3511+
"An unsigned variable can't be negative so it is either pointless or "
35123512
"an error to check if it is.");
35133513
}

gui/threadhandler.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -175,10 +175,7 @@ void ThreadHandler::SaveSettings(QSettings &settings) const
175175

176176
bool ThreadHandler::HasPreviousFiles() const
177177
{
178-
if (mLastFiles.size() > 0)
179-
return true;
180-
181-
return false;
178+
return !mLastFiles.isEmpty();
182179
}
183180

184181
int ThreadHandler::GetPreviousFilesCount() const

gui/threadresult.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void ThreadResult::reportErr(const ErrorLogger::ErrorMessage &msg)
9191
QString ThreadResult::GetNextFile()
9292
{
9393
QMutexLocker locker(&mutex);
94-
if (mFiles.size() == 0) {
94+
if (mFiles.isEmpty()) {
9595
return "";
9696
}
9797

gui/txtreport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ void TxtReport::WriteError(const ErrorItem &error)
5959
for (int i = 0; i < error.lines.size(); i++) {
6060
const QString file = QDir::toNativeSeparators(error.files[i]);
6161
line += QString("[%1:%2]").arg(file).arg(error.lines[i]);
62-
if (i < error.lines.size() - 1 && error.lines.size() > 0) {
62+
if (i < error.lines.size() - 1 && !error.lines.isEmpty()) {
6363
line += " -> ";
6464
}
6565

gui/xmlreportv1.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ ErrorItem XmlReportV1::ReadError(QXmlStreamReader *reader)
162162
item.errorId = attribs.value("", IdAttribute).toString();
163163
item.severity = GuiSeverity::fromString(attribs.value("", SeverityAttribute).toString());
164164

165-
// NOTE: This dublicates the message to Summary-field. But since
165+
// NOTE: This duplicates the message to Summary-field. But since
166166
// old XML format doesn't have separate summary and verbose messages
167167
// we must add same message to both data so it shows up in GUI.
168168
// Check if there is full stop and cut the summary to it.

lib/check64bit.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ void Check64BitPortability::pointerassignment()
7575
}
7676
}
7777

78-
// Check assignements
78+
// Check assignments
7979
for (std::size_t i = 0; i < functions; ++i) {
8080
const Scope * scope = symbolDatabase->functionScopes[i];
8181
for (const Token *tok = scope->classStart; tok && tok != scope->classEnd; tok = tok->next()) {

0 commit comments

Comments
 (0)