From ebda8f866c21da662bc938f846b564c5b2ff12e4 Mon Sep 17 00:00:00 2001 From: Wilson Snyder Date: Thu, 28 May 2020 21:04:36 -0400 Subject: [PATCH] Cleanup codacity and missing consts. --- include/verilated.cpp | 79 ++++++++++++++++++++++--------------------- src/V3Error.h | 2 +- src/V3Options.h | 5 +-- src/V3PreProc.cpp | 2 +- 4 files changed, 45 insertions(+), 43 deletions(-) diff --git a/include/verilated.cpp b/include/verilated.cpp index dd8fc03ef..3ead38546 100644 --- a/include/verilated.cpp +++ b/include/verilated.cpp @@ -216,7 +216,7 @@ void VL_DBG_MSGF(const char* formatp, ...) VL_MT_SAFE { // Using VL_PRINTF not VL_PRINTF_MT so that we can call VL_DBG_MSGF // from within the guts of the thread execution machinery (and it goes // to the screen and not into the queues we're debugging) - VL_PRINTF("-V{t%d,%" VL_PRI64 "u}%s", VL_THREAD_ID(), _vl_dbg_sequence_number(), out.c_str()); + VL_PRINTF("-V{t%u,%" VL_PRI64 "u}%s", VL_THREAD_ID(), _vl_dbg_sequence_number(), out.c_str()); } #ifdef VL_THREADED @@ -2053,47 +2053,47 @@ static const char* vl_time_str(int scale) { double vl_time_multiplier(int scale) { // Return timescale multipler -18 to +18 // For speed, this does not check for illegal values - static double pow10[] = {1.0, - 10.0, - 100.0, - 1000.0, - 10000.0, - 100000.0, - 1000000.0, - 10000000.0, - 100000000.0, - 1000000000.0, - 10000000000.0, - 100000000000.0, - 1000000000000.0, - 10000000000000.0, - 100000000000000.0, - 1000000000000000.0, - 10000000000000000.0, - 100000000000000000.0, - 1000000000000000000.0}; - static double neg10[] = {1.0, - 0.1, - 0.01, - 0.001, - 0.0001, - 0.00001, - 0.000001, - 0.0000001, - 0.00000001, - 0.000000001, - 0.0000000001, - 0.00000000001, - 0.000000000001, - 0.0000000000001, - 0.00000000000001, - 0.000000000000001, - 0.0000000000000001, - 0.00000000000000001, - 0.000000000000000001}; if (scale < 0) { + static const double neg10[] = {1.0, + 0.1, + 0.01, + 0.001, + 0.0001, + 0.00001, + 0.000001, + 0.0000001, + 0.00000001, + 0.000000001, + 0.0000000001, + 0.00000000001, + 0.000000000001, + 0.0000000000001, + 0.00000000000001, + 0.000000000000001, + 0.0000000000000001, + 0.00000000000000001, + 0.000000000000000001}; return neg10[-scale]; } else { + static const double pow10[] = {1.0, + 10.0, + 100.0, + 1000.0, + 10000.0, + 100000.0, + 1000000.0, + 10000000.0, + 100000000.0, + 1000000000.0, + 10000000000.0, + 100000000000.0, + 1000000000000.0, + 10000000000000.0, + 100000000000000.0, + 1000000000000000.0, + 10000000000000000.0, + 100000000000000000.0, + 1000000000000000000.0}; return pow10[scale]; } } @@ -2514,6 +2514,7 @@ VerilatedScope::VerilatedScope() { m_funcnumMax = 0; m_symsp = NULL; m_varsp = NULL; + m_timeunit = 0; m_type = SCOPE_OTHER; } diff --git a/src/V3Error.h b/src/V3Error.h index 87d2afd7a..a5f5d7135 100644 --- a/src/V3Error.h +++ b/src/V3Error.h @@ -136,7 +136,7 @@ public: operator en() const { return m_e; } const char* ascii() const { // clang-format off - const char* names[] = { + static const char* const names[] = { // Leading spaces indicate it can't be disabled. " MIN", " INFO", " FATAL", " FATALEXIT", " FATALSRC", " ERROR", // Boolean diff --git a/src/V3Options.h b/src/V3Options.h index 2d9e42608..4dee0ed98 100644 --- a/src/V3Options.h +++ b/src/V3Options.h @@ -134,8 +134,9 @@ public: } int powerOfTen() { return 2 - static_cast(m_e); } double multiplier() const { - static double values[] = {100, 10, 1, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, - 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 0}; + static const double values[] + = {100, 10, 1, 1e-1, 1e-2, 1e-3, 1e-4, 1e-5, 1e-6, 1e-7, + 1e-8, 1e-9, 1e-10, 1e-11, 1e-12, 1e-13, 1e-14, 1e-15, 0}; return values[m_e]; } }; diff --git a/src/V3PreProc.cpp b/src/V3PreProc.cpp index 3c616fccd..9c2cbe651 100644 --- a/src/V3PreProc.cpp +++ b/src/V3PreProc.cpp @@ -141,7 +141,7 @@ public: ps_STRIFY }; static const char* procStateName(ProcState s) { - static const char* states[] + static const char* const states[] = {"ps_TOP", "ps_DEFNAME_UNDEF", "ps_DEFNAME_DEFINE", "ps_DEFNAME_IFDEF", "ps_DEFNAME_IFNDEF", "ps_DEFNAME_ELSIF", "ps_DEFFORM", "ps_DEFVALUE", "ps_DEFPAREN",