Skip to content

Commit 0f7071a

Browse files
committed
Fix clang and coverity warnings
1 parent 86ef5f8 commit 0f7071a

3 files changed

Lines changed: 12 additions & 13 deletions

File tree

cli/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ void CheckOther::checkZeroDivision()
9797

9898
#ifdef _WIN32
9999
#include <windows.h>
100+
static char exename[1024] = {0};
100101
#endif
101102

102103
/**
@@ -115,7 +116,6 @@ int main(int argc, char* argv[])
115116

116117
CppCheckExecutor exec;
117118
#ifdef _WIN32
118-
char exename[1024] = {0};
119119
GetModuleFileNameA(NULL, exename, sizeof(exename)/sizeof(exename[0])-1);
120120
argv[0] = exename;
121121
#endif

lib/checkmemoryleak.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -425,14 +425,12 @@ CheckMemoryLeak::AllocType CheckMemoryLeak::functionReturnType(const Function* f
425425
if (varid == 0)
426426
return No;
427427

428-
if (this != nullptr) {
429-
// If variable is not local then alloctype shall be "No"
430-
// Todo: there can be false negatives about mismatching allocation/deallocation.
431-
// => Generate "alloc ; use ;" if variable is not local?
432-
const Variable *var = tokenizer->getSymbolDatabase()->getVariableFromVarId(varid);
433-
if (!var || !var->isLocal() || var->isStatic())
434-
return No;
435-
}
428+
// If variable is not local then alloctype shall be "No"
429+
// Todo: there can be false negatives about mismatching allocation/deallocation.
430+
// => Generate "alloc ; use ;" if variable is not local?
431+
const Variable *var = tokenizer->getSymbolDatabase()->getVariableFromVarId(varid);
432+
if (!var || !var->isLocal() || var->isStatic())
433+
return No;
436434

437435
// Check if return pointer is allocated..
438436
AllocType allocType = No;

lib/library.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -289,10 +289,11 @@ Library::Error Library::load(const tinyxml2::XMLDocument &doc)
289289

290290
else if (strcmp(markupnode->Name(), "codeblocks") == 0) {
291291
for (const tinyxml2::XMLElement *blocknode = markupnode->FirstChildElement(); blocknode; blocknode = blocknode->NextSiblingElement()) {
292-
if (strcmp(blocknode->Name(), "block") == 0)
293-
_executableblocks[extension].addBlock(blocknode->Attribute("name"));
294-
295-
else if (strcmp(blocknode->Name(), "structure") == 0) {
292+
if (strcmp(blocknode->Name(), "block") == 0) {
293+
const char * name = blocknode->Attribute("name");
294+
if (name)
295+
_executableblocks[extension].addBlock(blocknode->Attribute("name"));
296+
} else if (strcmp(blocknode->Name(), "structure") == 0) {
296297
const char * start = blocknode->Attribute("start");
297298
if (start)
298299
_executableblocks[extension].setStart(start);

0 commit comments

Comments
 (0)