Fix cppcheck warnings. No functional change intended.

This commit is contained in:
Wilson Snyder 2018-06-14 18:59:24 -04:00
parent 5d26bca55c
commit 0eb1d0a84e
14 changed files with 34 additions and 18 deletions

View File

@ -569,7 +569,7 @@ void VerilatedVcd::declare (vluint32_t code, const char* name, const char* wirep
sprintf(buf, " %2d ", bits);
decl += buf;
if (m_evcd) {
sprintf(buf, "<%d", code);
sprintf(buf, "<%u", code);
decl += buf;
} else {
decl += stringCode(code);

View File

@ -166,7 +166,7 @@ private:
}
UINFO(8,"Simple case statement: "<<nodep<<endl);
// Zero list of items for each value
for (uint32_t i=0; i<(1UL<<m_caseWidth); i++) m_valueItem[i] = NULL;
for (uint32_t i=0; i<(1UL<<m_caseWidth); ++i) m_valueItem[i] = NULL;
// Now pick up the values for each assignment
// We can cheat and use uint32_t's because we only support narrow case's
bool bitched = false;
@ -184,7 +184,7 @@ private:
V3Number numval (itemp->fileline(), iconstp->width());
numval.opBitsOne(iconstp->num());
uint32_t val = numval.toUInt();
for (uint32_t i=0; i<(1UL<<m_caseWidth); i++) {
for (uint32_t i=0; i<(1UL<<m_caseWidth); ++i) {
if ((i & mask) == val) {
if (!m_valueItem[i]) {
m_valueItem[i] = itemp;
@ -199,12 +199,12 @@ private:
}
// Defaults were moved to last in the caseitem list by V3LinkDot
if (itemp->isDefault()) { // Case statement's default... Fill the table
for (uint32_t i=0; i<(1UL<<m_caseWidth); i++) {
for (uint32_t i=0; i<(1UL<<m_caseWidth); ++i) {
if (!m_valueItem[i]) m_valueItem[i] = itemp;
}
}
}
for (uint32_t i=0; i<(1UL<<m_caseWidth); i++) {
for (uint32_t i=0; i<(1UL<<m_caseWidth); ++i) {
if (!m_valueItem[i]) {
nodep->v3warn(CASEINCOMPLETE,"Case values incompletely covered (example pattern 0x"<<hex<<i<<")");
m_caseNoOverlapsAllCovered = false;
@ -278,7 +278,7 @@ private:
AstNode* cexprp = nodep->exprp()->unlinkFrBack();
if (debug()>=9) {
for (uint32_t i=0; i<(1UL<<m_caseWidth); i++) {
for (uint32_t i=0; i<(1UL<<m_caseWidth); ++i) {
if (AstNode* itemp = m_valueItem[i]) {
UINFO(9,"Value "<<hex<<i<<" "<<itemp<<endl);
}

View File

@ -386,10 +386,13 @@ private:
public:
// CONSTUCTORS
explicit ClockVisitor(AstNetlist* nodep) {
m_modp=NULL;
m_modp = NULL;
m_evalFuncp = NULL;
m_topScopep=NULL;
m_lastSenp=NULL;
m_initFuncp = NULL;
m_finalFuncp = NULL;
m_settleFuncp = NULL;
m_topScopep = NULL;
m_lastSenp = NULL;
m_lastIfp = NULL;
m_scopep = NULL;
//

View File

@ -402,6 +402,7 @@ private:
UINFO(4," MOD "<<nodep<<endl);
m_modp = nodep;
m_modNFuncs = 0;
m_walkLast2p = NULL;
m_hashed.clear();
// Compute hash of all statement trees in the function
m_state = STATE_HASH;

View File

@ -382,6 +382,7 @@ public:
explicit CoverageVisitor(AstNetlist* rootp) {
// Operate on all modules
m_checkBlock = true;
m_modp = NULL;
m_beginHier = "";
m_inToggleOff = false;
m_inModOff = true;

View File

@ -119,7 +119,8 @@ private:
<<nodep->varp()->prettyName());
}
}
AstVarScope* createVarSc(AstVarScope* oldvarscp, string name, int width/*0==fromoldvar*/, AstNodeDType* newdtypep) {
AstVarScope* createVarSc(AstVarScope* oldvarscp, const string& name,
int width/*0==fromoldvar*/, AstNodeDType* newdtypep) {
// Because we've already scoped it, we may need to add both the AstVar and the AstVarScope
if (!oldvarscp->scopep()) oldvarscp->v3fatalSrc("Var unscoped");
AstVar* varp;

View File

@ -126,8 +126,10 @@ private:
public:
// CONSTUCTORS
explicit DepthBlockVisitor(AstNetlist* nodep) {
m_modp=NULL;
m_depth=0;
m_modp = NULL;
m_funcp = NULL;
m_depth = 0;
m_deepNum = 0;
//
nodep->accept(*this);
}

View File

@ -993,7 +993,7 @@ class EmitCImp : EmitCStmts {
// High level
void emitImp(AstNodeModule* modp);
void emitStaticDecl(AstNodeModule* modp);
void emitSettleLoop(std::string eval_call, bool initial);
void emitSettleLoop(const std::string& eval_call, bool initial);
void emitWrapEval(AstNodeModule* modp);
void emitInt(AstNodeModule* modp);
void maybeSplit(AstNodeModule* modp);
@ -1752,7 +1752,7 @@ void EmitCImp::emitSensitives() {
}
}
void EmitCImp::emitSettleLoop(std::string eval_call, bool initial) {
void EmitCImp::emitSettleLoop(const std::string& eval_call, bool initial) {
putsDecoration("// Evaluate till stable\n");
puts("int __VclockLoop = 0;\n");
puts("QData __Vchange = 1;\n");

View File

@ -829,6 +829,8 @@ private:
// Rather than doing a (slowish) ==##, we OR in the bits that aren't part of the mask
eqp = new AstOr (nodep->fileline(),
new AstConst (nodep->fileline(), notWideMask(nodep->lhsp())),
// Bug in cppcheck
// cppcheck-suppress memleak
eqp);
}
newp = (newp==NULL) ? eqp : (new AstAnd (nodep->fileline(), newp, eqp));

View File

@ -1612,7 +1612,7 @@ void OrderVisitor::process() {
UINFO(2," Process Circulars...\n");
processCircular(); // must be before processDomains
// Assign logic verticesto new domains
// Assign logic vertices to new domains
UINFO(2," Domains...\n");
processDomains();
m_graph.dumpDotFilePrefixed("orderg_domain");

View File

@ -211,9 +211,9 @@ uint64_t V3Os::memUsageBytes() {
if (!fp) {
return 0;
}
uint64_t size, resident, share, text, lib, data, dt; // All in pages
if (7 != fscanf(fp, "%" VL_PRI64 "d %" VL_PRI64 "d %" VL_PRI64 "d %"
VL_PRI64 "d %" VL_PRI64 "d %" VL_PRI64 "d %" VL_PRI64 "d",
vluint64_t size, resident, share, text, lib, data, dt; // All in pages
if (7 != fscanf(fp, "%" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %"
VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u %" VL_PRI64 "u",
&size, &resident, &share, &text, &lib, &data, &dt)) {
fclose(fp);
return 0;

View File

@ -1258,7 +1258,9 @@ public:
m_modp = NULL;
m_topScopep = NULL;
m_scopep = NULL;
m_insMode = IM_BEFORE;
m_insStmtp = NULL;
m_modNCalls = 0;
AstNode::user1ClearTree();
nodep->accept(*this);
}

View File

@ -700,6 +700,8 @@ public:
m_chgSubFuncp = NULL;
m_chgSubParentp = NULL;
m_chgSubStmts = 0;
m_code = 0;
m_finding = false;
m_funcNum = 0;
nodep->accept(*this);
}

View File

@ -461,9 +461,11 @@ public:
UnrollVisitor(AstNode* nodep, bool generate, const string& beginName) {
m_forVarp = NULL;
m_forVscp = NULL;
m_varValuep = NULL;
m_ignoreIncp = NULL;
m_varModeCheck = false;
m_varModeReplace = false;
m_varAssignHit = false;
m_generate = generate;
m_beginName = beginName;
//