From b488666c1ee7438f4d494ce0da1f42553b70efc0 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 4 Feb 2016 18:30:21 -0500 Subject: [PATCH] Fix cppcheck 1.71 issues. No functional change intended. --- include/verilated.cpp | 1 + src/V3Ast.cpp | 5 +++-- src/V3EmitXml.cpp | 2 +- src/V3Simulate.h | 3 +-- src/V3Slice.cpp | 4 ++-- src/V3Unknown.cpp | 2 +- src/cppcheck_filtered | 11 +++++++++-- 7 files changed, 18 insertions(+), 10 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index 98054260b..b44df52f0 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -650,6 +650,7 @@ IData _vl_vsscanf(FILE* fp, // If a fscanf _vl_vsss_skipspace(fp,floc,fromp,fstr); _vl_vsss_read(fp,floc,fromp,fstr, tmp, "+-.0123456789eE"); if (!tmp[0]) goto done; + // cppcheck-suppress unusedStructMember // It's used union { double r; vlsint64_t ld; } u; u.r = strtod(tmp, NULL); VL_SET_WQ(owp,u.ld); diff --git a/src/V3Ast.cpp b/src/V3Ast.cpp index 3c0198db4..8ce029816 100644 --- a/src/V3Ast.cpp +++ b/src/V3Ast.cpp @@ -102,7 +102,8 @@ string AstNode::encodeName(const string& namein) { } else if (pos[0]=='_') { if (pos[1]=='_') { out += "_"; out += "__05F"; // hex(_) = 0x5F - pos++; + ++pos; + if (pos==namein.end()) break; } else { out += pos[0]; } @@ -198,7 +199,7 @@ string AstNode::prettyName(const string& namein) { } else { pretty += pos[0]; - pos++; + ++pos; } } if (pretty.substr(0,4) == "TOP.") pretty.replace(0,4,""); diff --git a/src/V3EmitXml.cpp b/src/V3EmitXml.cpp index 333587dc5..2519edd78 100644 --- a/src/V3EmitXml.cpp +++ b/src/V3EmitXml.cpp @@ -36,7 +36,7 @@ //###################################################################### // Emit statements and math operators -class EmitXmlFileVisitor : public EmitCBaseVisitor { +class EmitXmlFileVisitor : public AstNVisitor { // MEMBERS V3OutFile* m_ofp; diff --git a/src/V3Simulate.h b/src/V3Simulate.h index 603eb8226..d4003e7f2 100644 --- a/src/V3Simulate.h +++ b/src/V3Simulate.h @@ -473,9 +473,8 @@ private: nodep->rhsp()->iterateAndNext(*this); if (optimizable()) { - AstNode* vscp; if (varrefp) { - vscp = varOrScope(varrefp); + AstNode* vscp = varOrScope(varrefp); V3Number outnum = V3Number(nodep->fileline()); if (V3Number* vscpnump = fetchOutNumberNull(vscp)) { outnum = *vscpnump; diff --git a/src/V3Slice.cpp b/src/V3Slice.cpp index e1085231a..a61bdfefd 100644 --- a/src/V3Slice.cpp +++ b/src/V3Slice.cpp @@ -275,8 +275,8 @@ class SliceVisitor : public AstNVisitor { } UINFO(9," ArraySel-child: "<fileline(), topp, - // "lsb-lsb": Arrays are zero-based so index 0 is always lsb - new AstConst(nodep->fileline(), lsb-lsb)); + // Arrays are zero-based so index 0 is always lsb (e.g. lsb-lsb -> 0) + new AstConst(nodep->fileline(), 0)); if (!newp->dtypep()) { newp->v3fatalSrc("ArraySel dtyping failed when resolving slice"); // see ArraySel constructor } diff --git a/src/V3Unknown.cpp b/src/V3Unknown.cpp index 5c5b5740c..8257cea7d 100644 --- a/src/V3Unknown.cpp +++ b/src/V3Unknown.cpp @@ -325,7 +325,7 @@ private: } } - void visit(AstSel* nodep, AstNUser*) { + virtual void visit(AstSel* nodep, AstNUser*) { nodep->iterateChildren(*this); if (!nodep->user1SetOnce()) { // Guard against reading/writing past end of bit vector array diff --git a/src/cppcheck_filtered b/src/cppcheck_filtered index 471743796..6fbde32fe 100755 --- a/src/cppcheck_filtered +++ b/src/cppcheck_filtered @@ -9,7 +9,12 @@ use Pod::Usage; use strict; use vars qw ($Debug $VERSION); -$VERSION = '3.857'; +$VERSION = '3.881'; + +our %SuppressMap = ( + # New cpp check error Can suppress with old error + 'nullPointerRedundantCheck' => 'nullPointer', + ); #====================================================================== # main @@ -44,6 +49,7 @@ sub process { my $cmd = join(' ',@Opt_Args); print "\t$cmd\n" if $Debug; my $fh = IO::File->new("$cmd 2>&1 |"); + $fh or die "%Error: '$cmd' failed: $!\n"; my %uniq; my %errs; while (defined(my $line = $fh->getline())) { @@ -115,7 +121,8 @@ sub _suppress { if ($line =~ /cppcheck-suppress((\s+\S+)+)/) { my $supids = $1; foreach my $supid (split /\s+/, $supids) { - if ($supid eq $id) { + if ($supid eq $id + || $supid eq $SuppressMap{$id}) { return 1; } }