Fix core_tb c++ build warnings

* Remove unused variables
* Fix print format specifiers
* Fix constructor initialization order
* Fix wrong argument
* Update .blazerc to include the commonly disabled warnings

Change-Id: I1189e90b5aa5aff507c144cc353a2261c348db36
diff --git a/.bazelrc b/.bazelrc
index 5b3d13f..7ff5627 100644
--- a/.bazelrc
+++ b/.bazelrc
@@ -1 +1,4 @@
 build --cxxopt=-std=c++17
+
+# Disable the low signal-to-noise ratio warnings
+build --copt=-Wno-unused-function
diff --git a/tests/verilator_sim/BUILD b/tests/verilator_sim/BUILD
index 59b6710..0476a57 100644
--- a/tests/verilator_sim/BUILD
+++ b/tests/verilator_sim/BUILD
@@ -128,9 +128,6 @@
     srcs = [
         "kelvin/vconvctrl_tb.cc",
     ],
-    copts = [
-        "-Wno-unused-function",
-    ],
     deps = [
         ":kelvin_if",
         ":sim_libs",
diff --git a/tests/verilator_sim/kelvin/core_tb.cc b/tests/verilator_sim/kelvin/core_tb.cc
index e2a6e10..c449816 100644
--- a/tests/verilator_sim/kelvin/core_tb.cc
+++ b/tests/verilator_sim/kelvin/core_tb.cc
@@ -1,3 +1,5 @@
+// Copyright 2023 Google LLC
+
 #include "tests/verilator_sim/sysc_tb.h"
 
 #include "VCore.h"
@@ -21,7 +23,7 @@
 
 static void Core_run(const char* name, const char* bin, const bool trace) {
   VCore core(name);
-  Core_tb tb("Core_tb", 100000000, random);
+  Core_tb tb("Core_tb", 100000000, /* random= */ false);
   Core_if mif("Core_if", bin);
   Debug_if dbg("Debug_if", &mif);
 
diff --git a/tests/verilator_sim/kelvin/debug_if.h b/tests/verilator_sim/kelvin/debug_if.h
index e35a27a..370501d 100644
--- a/tests/verilator_sim/kelvin/debug_if.h
+++ b/tests/verilator_sim/kelvin/debug_if.h
@@ -1,3 +1,5 @@
+// Copyright 2023 Google LLC
+
 #ifndef TESTS_VERILATOR_SIM_KELVIN_DEBUG_IF_H_
 #define TESTS_VERILATOR_SIM_KELVIN_DEBUG_IF_H_
 
@@ -46,7 +48,7 @@
     }
   }
 
-private:
+ private:
 #ifndef TIME_DISABLE
   const char* KNRM = "\x1B[0m";
   const char* KRED = "\x1B[31m";
@@ -83,13 +85,12 @@
       char buf[BUFFERLIMIT];
       char sbuf[ARGMAX * BUFFERLIMIT];
 
-      mm_->Read(data, BUFFERLIMIT, (uint8_t*) buf);
+      mm_->Read(data, BUFFERLIMIT, reinterpret_cast<uint8_t*>(buf));
       buf[sizeof(buf) - 1] = '\0';
 
-      sprintf(sbuf, buf, arg_[0], arg_[1], arg_[2], arg_[3],
-              arg_[4], arg_[5], arg_[6], arg_[7],
-              arg_[8], arg_[9], arg_[10], arg_[11],
-              arg_[12], arg_[13], arg_[14], arg_[15]);  // ARGMAX
+      snprintf(sbuf, sizeof(sbuf), buf, arg_[0], arg_[1], arg_[2], arg_[3],
+               arg_[4], arg_[5], arg_[6], arg_[7], arg_[8], arg_[9], arg_[10],
+               arg_[11], arg_[12], arg_[13], arg_[14], arg_[15]);  // ARGMAX
 
       int len = strlen(sbuf);
 #ifndef TIME_DISABLE
@@ -140,9 +141,7 @@
       }
     } else if (cmd == KLOG) {
       arg_[argpos_] = (uint64_t) str_[argpos_];
-      uint8_t *buf = str_[argpos_];
-      char c = 0;
-      int pos = 0;
+      uint8_t* buf = str_[argpos_];
       mm_->Read(data, BUFFERLIMIT, buf);
       argpos_++;
     } else {
diff --git a/tests/verilator_sim/kelvin/memory_if.h b/tests/verilator_sim/kelvin/memory_if.h
index ebe7fc1..733bd33 100644
--- a/tests/verilator_sim/kelvin/memory_if.h
+++ b/tests/verilator_sim/kelvin/memory_if.h
@@ -1,9 +1,14 @@
+// Copyright 2023 Google LLC
+
 #ifndef TESTS_VERILATOR_SIM_KELVIN_MEMORY_IF_H_
 #define TESTS_VERILATOR_SIM_KELVIN_MEMORY_IF_H_
 
 #include <stdint.h>
 #include <stdio.h>
 
+#include <algorithm>
+#include <map>
+
 #include "tests/verilator_sim/sysc_module.h"
 
 // A memory model base class
@@ -29,7 +34,7 @@
     fclose(f);
 
     if (limit > 0 && fsize > limit) {
-      printf("***ERROR Memory_if limit exceeded [%d > %d]\n", fsize, limit);
+      printf("***ERROR Memory_if limit exceeded [%ld > %d]\n", fsize, limit);
       exit(-1);
     }
 
@@ -68,7 +73,7 @@
       addr += len;
       data += len;
       bytes -= len;
-      assert (bytes >= 0);
+      assert(bytes >= 0);
     }
   }
 
@@ -99,11 +104,11 @@
       addr += len;
       data += len;
       bytes -= len;
-      assert (bytes >= 0);
+      assert(bytes >= 0);
     }
   }
 
-protected:
+ protected:
   void ReadSwizzle(const uint32_t addr, const int bytes, uint8_t* data) {
     const int mask = bytes - 1;
     const int alignment = (bytes - (addr & mask)) & mask;  // left shuffle
@@ -136,7 +141,7 @@
     }
   }
 
-private:
+ private:
   std::map<uint32_t, memory_page_t> page_;
 
   bool HasPage(const uint32_t addr) {
diff --git a/tests/verilator_sim/sysc_tb.h b/tests/verilator_sim/sysc_tb.h
index 9fb2aed..b097a7d 100644
--- a/tests/verilator_sim/sysc_tb.h
+++ b/tests/verilator_sim/sysc_tb.h
@@ -1,15 +1,20 @@
+// Copyright 2023 Google LLC
+
 #ifndef TESTS_VERILATOR_SIM_SYSC_TB_H_
 #define TESTS_VERILATOR_SIM_SYSC_TB_H_
 
 // A SystemC baseclass for constrained random testing of Verilated RTL.
+#include <systemc.h>
 
-#include <systemc>
-using namespace sc_core;
-using sc_dt::sc_bv;
 #include <iostream>
+#include <string>
 
-#include "fifo.h"
-#include "verilated_vcd_c.h"
+#include "tests/verilator_sim/fifo.h"
+// sc_core needs to be included before verilator header
+using namespace sc_core;      // NOLINT(build/namespaces)
+#include "verilated_vcd_c.h"  // NOLINT(build/include_subdir): From verilator.
+
+using sc_dt::sc_bv;
 
 const char *vcd_path_ = "/tmp/kelvin/vcd";
 
@@ -97,8 +102,8 @@
         clock("clock", 1, SC_NS),
         reset("reset"),
         resetn("resetn"),
-        loops_(loops),
-        random_(random) {
+        random_(random),
+        loops_(loops) {
     loop_ = 0;
     error_ = false;
 
@@ -168,9 +173,9 @@
   }
 
  protected:
-  virtual void init(){};
-  virtual void posedge(){};
-  virtual void negedge(){};
+  virtual void init() {}
+  virtual void posedge() {}
+  virtual void negedge() {}
 
   bool check(bool v, const char *s = "") {
     const char *KRED = "\x1B[31m";
@@ -191,15 +196,17 @@
 
   bool rand_bool() {
     // Do not allow any 'io_in_valid' controls to be set during reset.
-    return !reset && (!random_ || (rand() & 1));
+    return !reset &&
+           (!random_ || (rand() & 1));  // NOLINT(runtime/threadsafe_fn)
   }
 
   int rand_int(int min = 0, int max = (1 << 31)) {
-    return (rand() % (max - min + 1)) + min;
+    return (rand() % (max - min + 1)) + min;  // NOLINT(runtime/threadsafe_fn)
   }
 
   uint32_t rand_uint32(uint32_t min = 0, uint32_t max = 0xffffffffu) {
-    uint32_t r = (rand() & 0xffff) | (rand() << 16);
+    uint32_t r = (rand() & 0xffff) |  // NOLINT(runtime/threadsafe_fn)
+                 (rand() << 16);      // NOLINT(runtime/threadsafe_fn)
     if (min == 0 && max == 0xffffffff) return r;
     return (r % (max - min + 1)) + min;
   }