From: Curtis Dunham Date: Wed, 2 Sep 2015 20:19:43 +0000 (-0500) Subject: sim: make warning for absent optional parameters optional X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ad5b772291220d44b355d8d939d625db7dffc1a;p=gem5.git sim: make warning for absent optional parameters optional This is in support of tag-based checkpoint versioning. It should be possible to examine an optional parameter in a checkpoint during unserialization and not have it throw a warning. --- diff --git a/src/sim/serialize.cc b/src/sim/serialize.cc index 3127d9a04..0ecf45b6d 100644 --- a/src/sim/serialize.cc +++ b/src/sim/serialize.cc @@ -223,12 +223,13 @@ paramIn(CheckpointIn &cp, const string &name, T ¶m) template bool -optParamIn(CheckpointIn &cp, const string &name, T ¶m) +optParamIn(CheckpointIn &cp, const string &name, T ¶m, bool warn) { const string §ion(Serializable::currentSection()); string str; if (!cp.find(section, name, str) || !parseParam(str, param)) { - warn("optional parameter %s:%s not present\n", section, name); + if (warn) + warn("optional parameter %s:%s not present\n", section, name); return false; } else { return true; @@ -384,7 +385,8 @@ objParamIn(CheckpointIn &cp, const string &name, SimObject * ¶m) template void \ paramIn(CheckpointIn &cp, const string &name, type & param); \ template bool \ - optParamIn(CheckpointIn &cp, const string &name, type & param); \ + optParamIn(CheckpointIn &cp, const string &name, type & param, \ + bool warn); \ template void \ arrayParamOut(CheckpointOut &os, const string &name, \ type const *param, unsigned size); \ diff --git a/src/sim/serialize.hh b/src/sim/serialize.hh index 561cd5508..e3b761f10 100644 --- a/src/sim/serialize.hh +++ b/src/sim/serialize.hh @@ -100,13 +100,15 @@ void paramIn(CheckpointIn &cp, const std::string &name, } template -bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m); +bool optParamIn(CheckpointIn &cp, const std::string &name, T ¶m, + bool warn = true); template bool optParamIn(CheckpointIn &cp, const std::string &name, - BitfieldBackend::BitUnionOperators &p) + BitfieldBackend::BitUnionOperators &p, + bool warn = true) { - return optParamIn(cp, name, p.__data); + return optParamIn(cp, name, p.__data, warn); } template