Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion trunk/cli/tscexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ static void print_stacktrace(FILE* f, bool demangling, int maxdepth)
#endif
}

static const size_t MYSTACKSIZE = 16 * 1024 + SIGSTKSZ; // wild guess about a reasonable buffer
// static const size_t MYSTACKSIZE = 16 * 1024 + SIGSTKSZ; // wild guess about a reasonable buffer
static const size_t MYSTACKSIZE = 16 * 1024 + 131072; // wild guess about a reasonable buffer
static char mytstack[MYSTACKSIZE]; // alternative stack for signal handler
static bool bStackBelowHeap = false; // lame attempt to locate heap vs. stack address space

Expand Down
41 changes: 20 additions & 21 deletions trunk/cli/tscthreadexecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "path.h"
#include "globalmacros.h"
#include "checktscinvalidvarargs.h"
#include <cstdint>

#define MAXERRORCNT 30
#define AUTOFILTER_SUBID "FuncPossibleRetNULL|FuncRetNULL|dereferenceAfterCheck|dereferenceBeforeCheck|possibleNullDereferenced|nullpointerarg|nullpointerclass"
Expand Down Expand Up @@ -197,12 +198,10 @@ unsigned TscThreadExecutor::init()
unsigned int __stdcall TscThreadExecutor::threadProc(void *args)
#else
void* TscThreadExecutor::threadProc(void *args)
#endif
{
unsigned int result = 0;

TscThreadExecutor *threadExecutor = static_cast<TscThreadExecutor*>(args);
TSC_LOCK_ENTER(&threadExecutor->_fileSync);
#endif
{
TscThreadExecutor *threadExecutor = static_cast<TscThreadExecutor*>(args);
TSC_LOCK_ENTER(&threadExecutor->_fileSync);

int threadIndex = threadExecutor->_threadIndex;
++threadExecutor->_threadIndex;
Expand Down Expand Up @@ -235,21 +234,21 @@ void* TscThreadExecutor::threadProc(void *args)
pGlobalData->RecoredExportClass(true);
fileChecker.analyze(file, fileContent->second);
}
else {
pGlobalData->RecoredExportClass(false);
result += fileChecker.check(file, fileContent->second);
}
}
else {
if (threadExecutor->_analyzeFile) {
pGlobalData->RecoredExportClass(true);
fileChecker.analyze(file);
}
else {
pGlobalData->RecoredExportClass(false);
result += fileChecker.check(file);
}
}
else {
pGlobalData->RecoredExportClass(false);
fileChecker.check(file, fileContent->second);
}
}
else {
if (threadExecutor->_analyzeFile) {
pGlobalData->RecoredExportClass(true);
fileChecker.analyze(file);
}
else {
pGlobalData->RecoredExportClass(false);
fileChecker.check(file);
}
}

TSC_LOCK_ENTER(&threadExecutor->_fileSync);

Expand Down
24 changes: 11 additions & 13 deletions trunk/lib/checktscinvalidvarargs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,8 @@ void CheckTSCInvalidVarArgs::CheckVarArgs_new()

void CheckTSCInvalidVarArgs::ReportErrorParamDismatch(const Token *tok, const string& funcName/*, bool inconclusive*/ /*= false*/)
{
char szMsg[0x100] = {0};
sprintf(szMsg, "The count of parameters mismatches the format string in %s", funcName.c_str());
char szMsg[0x100] = {0};
snprintf(szMsg, sizeof(szMsg), "The count of parameters mismatches the format string in %s", funcName.c_str());

reportError(tok, Severity::error, ErrorType::Logic, "InvalidVarArgs", szMsg, ErrorLogger::GenWebIdentity((funcName)));
}
Expand All @@ -242,7 +242,7 @@ void CheckTSCInvalidVarArgs::CheckScope(const Token *tokBegin, const Token *tokE

Token *tok = GetCode(tokBegin, tokEnd, assignStack, varid);

std::stack<std::string> useStack;
std::stack<std::string> useStack;

for (const Token* tok2 = tok; tok2 ; tok2 = tok2->next())
{
Expand All @@ -252,10 +252,9 @@ void CheckTSCInvalidVarArgs::CheckScope(const Token *tokBegin, const Token *tokE
}
}

bool bUsed = false;
bool bBlankStr = false;
while(!useStack.empty())
{
bool bUsed = false;
while(!useStack.empty())
{
std::string useType = useStack.top();
useStack.pop();
if (useType == "use")
Expand All @@ -267,12 +266,11 @@ void CheckTSCInvalidVarArgs::CheckScope(const Token *tokBegin, const Token *tokE
const Token* pTokBack = assignStack.top();
assignStack.pop();

if (pTokBack && pTokBack->tokType() == Token::eString)
{
bBlankStr = true;
strFormatted = pTokBack->str();
break;
}
if (pTokBack && pTokBack->tokType() == Token::eString)
{
strFormatted = pTokBack->str();
break;
}
}
}
inconclusive = bUsed;
Expand Down
30 changes: 12 additions & 18 deletions trunk/lib/checktscnullpointer2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3892,12 +3892,11 @@ const Token* CheckTSCNullPointer2::HandleFuncParam(const Token* tok)

if (tokFunc->tokType() != Token::eVariable)
{
if (tokFunc->isName())
{
bool bDefFound = false;
const gt::CFunction *gtFunc = CGlobalTokenizer::Instance()->FindFunctionData(tokFunc);
if (gtFunc)
{
if (tokFunc->isName())
{
const gt::CFunction *gtFunc = CGlobalTokenizer::Instance()->FindFunctionData(tokFunc);
if (gtFunc)
{
const std::set<gt::SOutScopeVarState> &osv = gtFunc->GetFuncData().GetOutScopeVarState();
for (std::set<gt::SOutScopeVarState>::const_iterator iter = osv.begin(), end = osv.end(); iter != end; ++iter)
{
Expand Down Expand Up @@ -3930,8 +3929,7 @@ const Token* CheckTSCNullPointer2::HandleFuncParam(const Token* tok)
{
return tok;
}
bDefFound = true;
}
}

std::set<gt::SVarEntry> derefedVar;
std::set<int> derefArgIndex;
Expand Down Expand Up @@ -4250,8 +4248,7 @@ bool CheckTSCNullPointer2::ExtractCondFromToken(const Token* tok, CCompoundExpr*
if (tok1 && tok2)
{
const ValueFlow::Value* value = nullptr;
const Token* tokValue = nullptr;
const Token* tokExpr = nullptr;
const Token* tokExpr = nullptr;

if (tok1->values.size() == 1)
{
Expand All @@ -4260,10 +4257,8 @@ bool CheckTSCNullPointer2::ExtractCondFromToken(const Token* tok, CCompoundExpr*
if (value->isKnown() && !value->tokvalue)
{
tokExpr = tok2;
tokValue = tok1;

if (sComp == "<")
{
if (sComp == "<")
{
sComp = ">";
}
else if (sComp == "<=")
Expand All @@ -4289,10 +4284,9 @@ bool CheckTSCNullPointer2::ExtractCondFromToken(const Token* tok, CCompoundExpr*
if (value->isKnown() && !value->tokvalue)
{
tokExpr = tok1;
tokValue = tok2;
}
}
}
}
}
}

if (tokExpr)
{
Expand Down
15 changes: 6 additions & 9 deletions trunk/lib/checktscoverrun.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,8 +300,7 @@ void CheckTSCOverrun::checkIndexCheckDefect()
continue;
}

bool bOK = false;
bool bRet = false;
bool bOK = false;
if (tokCond->str() == "if" && layer1 == 0 && layer2 > 0)
{
if (tokOp->str() == ">")
Expand Down Expand Up @@ -336,10 +335,10 @@ void CheckTSCOverrun::checkIndexCheckDefect()
continue;
}

if (bOK)
{
bRet = IsScopeReturn(tokCond);
}
if (bOK)
{
IsScopeReturn(tokCond);
}
}
else if ((tokCond->str() == "if" && layer1 > 0) || (tokCond->str() == "for" && layer1 > 0))
{
Expand Down Expand Up @@ -371,9 +370,7 @@ void CheckTSCOverrun::checkIndexCheckDefect()
}
}

bRet = bOK;

}
}

if (bOK)
{
Expand Down
4 changes: 2 additions & 2 deletions trunk/lib/checkuninitvar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1286,7 +1286,7 @@ void CheckUninitVar::ReportUninitStructError(const std::string& str, const Token
{
if (!tokCaller->isExpandedMacro())
{
sprintf(szBuf, "%u", iterErr->second.begin()->second->linenr());
snprintf(szBuf, eBufLen, "%u", iterErr->second.begin()->second->linenr());
reportError(tokCaller,
Severity::error, ErrorType::Uninit,
(bPossible ? "PossibleUninitStruct" : "UninitStruct"),
Expand Down Expand Up @@ -1974,4 +1974,4 @@ bool CheckUninitVar::CheckMemUseInFun(const Variable &var, const Function* fc, A
bool ret = checkScopeForVariable(fc->functionScope->classStart, var, nullptr, nullptr, &alloc, emptyString, var.isPointer());
bGoInner = true;
return ret;
}
}
6 changes: 3 additions & 3 deletions trunk/lib/errorlogger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,9 +337,9 @@ std::string ErrorLogger::ErrorMessage::toXML_codetrace(bool verbose, int version
startline = fline - 10;
else
startline = 1;
endline = 10 + fline;
char sline[20];
sprintf(sline, "%d", i);
endline = 10 + fline;
char sline[20];
snprintf(sline, sizeof(sline), "%d", i);
if (i >= startline && i <= endline)
{
content += string(sline) + ": " + strTextLine + "\n";
Expand Down
2 changes: 1 addition & 1 deletion trunk/lib/executionpath.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ void ExecutionPath::checkScope(const Token *tok, std::list<ExecutionPath *> &che
if (!tok || tok->str() == "}" || checks.empty())
return;

const std::auto_ptr<ExecutionPath> check(checks.front()->copy());
std::unique_ptr<ExecutionPath> check(checks.front()->copy());

for (; tok; tok = tok->next()) {
// might be a noreturn function..
Expand Down
5 changes: 2 additions & 3 deletions trunk/lib/globalsymboldatabase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2410,9 +2410,8 @@ namespace gt
bool bReturnUnknown;
bool bHasError;
bool bIfThenRet;
bool bUnderIf;
bool bUnknownIf;
bool bStrictIf;
bool bUnderIf;
bool bStrictIf;
bool bStrictElse;
};

Expand Down
12 changes: 6 additions & 6 deletions trunk/lib/globalsymboldatabase.h
Original file line number Diff line number Diff line change
Expand Up @@ -678,11 +678,11 @@ namespace gt
}
};
public:
CField(const std::string& name, unsigned flags, AccessControl ac, Type::NeedInitialization init)
: m_name(name), m_access(ac), m_flags(flags), m_gtType(nullptr), m_needInit(init)
{
}
CField(const std::string& name, unsigned flags, AccessControl ac, Type::NeedInitialization init)
: m_name(name), m_access(ac), m_flags(flags), m_gtType(nullptr), m_needInit(init)
{
(void)m_access;
}
const std::string& GetName() const
{
return m_name;
Expand Down Expand Up @@ -777,4 +777,4 @@ namespace gt



#endif /* globalsymboldatabase_h */
#endif /* globalsymboldatabase_h */
8 changes: 1 addition & 7 deletions trunk/lib/preprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1919,13 +1919,7 @@ std::string Preprocessor::getcode(const std::string &filedata, const std::string
if (_settings.terminated())
return "";

if (line.compare(0, 7, "#pragma") == 0)
{
int i = 0;
++i;
}

if (line.compare(0, 11, "#pragma asm") == 0) {
if (line.compare(0, 11, "#pragma asm") == 0) {
ret << "\n";
bool found_end = false;
while (getline(istr, line)) {
Expand Down
Loading