Skip to content

Commit b3016f0

Browse files
authored
fixed some CLion inspection warnings (#4688)
* fixed some CLion "Unused global declaration" warnings * fixed some CLion "Not implemented function" warnings * fixed some CLion "Unused struct" warnings * added TODO * removed unused parameter reported by CLion * fixed some CLion "Unused macro" warnings * fixed some CLion "Condition is always true" warnings and a CLion "The value is never used" warning
1 parent c249cc9 commit b3016f0

27 files changed

+21
-122
lines changed

cli/cppcheckexecutorsig.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,6 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
120120

121121
const Signalmap_t::const_iterator it=listofsignals.find(signo);
122122
const char * const signame = (it==listofsignals.end()) ? "unknown" : it->second.c_str();
123-
bool printCallstack=true; // try to print a callstack?
124123
bool lowMem=false; // was low-memory condition detected? Be careful then! Avoid allocating much more memory then.
125124
bool unexpectedSignal=true; // unexpected indicates program failure
126125
bool terminate=true; // exit process/thread
@@ -241,7 +240,6 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
241240
unexpectedSignal=false; // legal usage: interrupt application via CTRL-C
242241
fputs("cppcheck received signal ", output);
243242
fputs(signame, output);
244-
printCallstack=true;
245243
fputs(".\n", output);
246244
break;
247245
case SIGSEGV:
@@ -277,11 +275,9 @@ static void CppcheckSignalHandler(int signo, siginfo_t * info, void * context)
277275
fputs(".\n", output);
278276
break;
279277
}
280-
if (printCallstack) {
281278
#ifdef USE_UNIX_BACKTRACE_SUPPORT
282-
print_stacktrace(output, true, -1, lowMem);
279+
print_stacktrace(output, true, -1, lowMem);
283280
#endif
284-
}
285281
if (unexpectedSignal) {
286282
fputs("\nPlease report this to the cppcheck developers!\n", output);
287283
}

cli/processexecutor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ ProcessExecutor::~ProcessExecutor()
7171

7272
class PipeWriter : public ErrorLogger {
7373
public:
74-
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', REPORT_VERIFICATION='4', CHILD_END='5'};
74+
enum PipeSignal {REPORT_OUT='1',REPORT_ERROR='2', CHILD_END='5'};
7575

7676
explicit PipeWriter(int pipe) : mWpipe(pipe) {}
7777

gui/common.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@
3636
#define SETTINGS_WINDOW_MAXIMIZED "Window maximized"
3737
#define SETTINGS_WINDOW_WIDTH "Window width"
3838
#define SETTINGS_WINDOW_HEIGHT "Window height"
39-
#define SETTINGS_LOG_VIEW_WIDTH "Log/View width"
40-
#define SETTINGS_LOG_VIEW_HEIGHT "Log/View height"
4139
#define SETTINGS_MAINWND_SPLITTER_STATE "Mainwindow/Vertical splitter state"
4240
#define SETTINGS_CHECK_DIALOG_WIDTH "Check dialog width"
4341
#define SETTINGS_CHECK_DIALOG_HEIGHT "Check dialog height"
@@ -101,7 +99,6 @@
10199
#define SETTINGS_LAST_PROJECT_PATH "Last project path"
102100
#define SETTINGS_LAST_RESULT_PATH "Last result path"
103101
#define SETTINGS_LAST_SOURCE_PATH "Last source path"
104-
#define SETTINGS_LAST_INCLUDE_PATH "Last include path"
105102
#define SETTINGS_LAST_APP_PATH "Last application path"
106103

107104
#define SETTINGS_LAST_ANALYZE_FILES_FILTER "Last analyze files filter"

gui/mainwindow.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@
9292
#include <QVariant>
9393
#include <Qt>
9494

95-
static const QString OnlineHelpURL("https://cppcheck.sourceforge.io/manual.html");
9695
static const QString compile_commands_json("compile_commands.json");
9796

9897
static QString fromNativePath(const QString& p) {

gui/projectfile.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,9 +402,11 @@ class ProjectFile : public QObject {
402402
QStringList getCheckUnknownFunctionReturn() const {
403403
return mCheckUnknownFunctionReturn;
404404
}
405-
void setCheckUnknownFunctionReturn(const QStringList &s) {
405+
/*
406+
void setCheckUnknownFunctionReturn(const QStringList &s) {
406407
mCheckUnknownFunctionReturn = s;
407-
}
408+
}
409+
*/
408410

409411
/** Use Clang parser */
410412
bool clangParser;

gui/projectfiledialog.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ void ProjectFileDialog::loadFromProjectFile(const ProjectFile *projectFile)
347347
mUI->mComboBoxPlatform->setCurrentText(projectFile->getPlatform());
348348
setSuppressions(projectFile->getSuppressions());
349349

350+
// TODO
350351
// Human knowledge..
351352
/*
352353
mUI->mListUnknownFunctionReturn->clear();

gui/resultstree.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -346,14 +346,6 @@ protected slots:
346346
*/
347347
void startApplication(QStandardItem *target, int application = -1);
348348

349-
/**
350-
* @brief Helper function to copy filename/full path to the clipboard
351-
*
352-
* @param target Error tree item to open
353-
* @param fullPath Are we copying full path or only filename?
354-
*/
355-
void copyPathToClipboard(QStandardItem *target, bool fullPath);
356-
357349
/**
358350
* @brief Helper function returning the filename/full path of the error tree item \a target.
359351
*

gui/translationhandler.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ bool TranslationHandler::setLanguage(const QString &code)
9090
failure = true;
9191
} else {
9292
// Make sure there is a translator
93-
if (!mTranslator && !failure)
93+
if (!mTranslator)
9494
mTranslator = new QTranslator(this);
9595

9696
//Load the new language
@@ -108,18 +108,19 @@ bool TranslationHandler::setLanguage(const QString &code)
108108
else
109109
translationFile = appPath + "/" + mTranslations[index].mFilename + ".qm";
110110

111-
if (!mTranslator->load(translationFile) && !failure) {
111+
if (!mTranslator->load(translationFile)) {
112+
failure = true;
112113
//If it failed, lets check if the default file exists
113114
if (!QFile::exists(translationFile)) {
114115
error = QObject::tr("Language file %1 not found!");
115116
error = error.arg(translationFile);
116-
failure = true;
117117
}
118-
119-
//If file exists, there's something wrong with it
120-
error = QObject::tr("Failed to load translation for language %1 from file %2");
121-
error = error.arg(mTranslations[index].mName);
122-
error = error.arg(translationFile);
118+
else {
119+
//If file exists, there's something wrong with it
120+
error = QObject::tr("Failed to load translation for language %1 from file %2");
121+
error = error.arg(mTranslations[index].mName);
122+
error = error.arg(translationFile);
123+
}
123124
}
124125
}
125126

lib/checkother.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ static const struct CWE CWE571(571U); // Expression is Always True
6464
static const struct CWE CWE672(672U); // Operation on a Resource after Expiration or Release
6565
static const struct CWE CWE628(628U); // Function Call with Incorrectly Specified Arguments
6666
static const struct CWE CWE683(683U); // Function Call With Incorrect Order of Arguments
67-
static const struct CWE CWE686(686U); // Function Call With Incorrect Argument Type
6867
static const struct CWE CWE704(704U); // Incorrect Type Conversion or Cast
6968
static const struct CWE CWE758(758U); // Reliance on Undefined, Unspecified, or Implementation-Defined Behavior
7069
static const struct CWE CWE768(768U); // Incorrect Short Circuit Evaluation

lib/checkstl.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -451,11 +451,6 @@ static std::string getContainerName(const Token *containerToken)
451451
return ret;
452452
}
453453

454-
enum OperandPosition {
455-
Left,
456-
Right
457-
};
458-
459454
static bool isVector(const Token* tok)
460455
{
461456
if (!tok)

0 commit comments

Comments
 (0)