sim-power: Fix the way the power model accesses stats
[gem5.git] / src / sim / serialize.hh
index 543477726c83f13e72cea47e02d4add2e776b296..92b14a9ffff5d09d7ceafb428aab7d1451283cc6 100644 (file)
  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- *
- * Authors: Nathan Binkert
- *          Erik Hallnor
- *          Steve Reinhardt
- *          Andreas Sandberg
  */
 
 /* @file
@@ -289,7 +284,8 @@ template <class T>
 bool
 parseParam(const std::string &s, BitUnionType<T> &value)
 {
-    auto storage = static_cast<BitUnionBaseType<T>>(value);
+    // Zero initialize storage to avoid leaking an uninitialized value
+    BitUnionBaseType<T> storage = BitUnionBaseType<T>();
     auto res = to_number(s, storage);
     value = storage;
     return res;
@@ -473,7 +469,15 @@ arrayParamOut(CheckpointOut &os, const std::string &name,
     os << "\n";
 }
 
-
+/**
+ * Extract values stored in the checkpoint, and assign them to the provided
+ * array container.
+ *
+ * @param cp The checkpoint to be parsed.
+ * @param name Name of the container.
+ * @param param The array container.
+ * @param size The expected number of entries to be extracted.
+ */
 template <class T>
 void
 arrayParamIn(CheckpointIn &cp, const std::string &name,
@@ -495,9 +499,9 @@ arrayParamIn(CheckpointIn &cp, const std::string &name,
     // Need this if we were doing a vector
     // value.resize(tokens.size());
 
-    if (tokens.size() != size) {
-        fatal("Array size mismatch on %s:%s'\n", section, name);
-    }
+    fatal_if(tokens.size() != size,
+             "Array size mismatch on %s:%s (Got %u, expected %u)'\n",
+             section, name, tokens.size(), size);
 
     for (std::vector<std::string>::size_type i = 0; i < tokens.size(); i++) {
         // need to parse into local variable to handle vector<bool>,