[caching tools] handle version 1 metadata where policy_hint_width is zero

This commit is contained in:
Joe Thornber
2013-10-14 12:40:13 +01:00
parent b177275816
commit 3b11749dcf
3 changed files with 19 additions and 6 deletions

View File

@ -234,14 +234,14 @@ missing_hints::visit(damage_visitor &v) const
//----------------------------------------------------------------
hint_array::hint_array(tm_ptr tm, unsigned width)
: width_(width),
: width_(check_width(width)),
impl_(mk_array(tm, width))
{
}
hint_array::hint_array(typename hint_array::tm_ptr tm, unsigned width,
block_address root, unsigned nr_entries)
: width_(width),
: width_(check_width(width)),
impl_(mk_array(tm, width, root, nr_entries))
{
}
@ -283,4 +283,16 @@ hint_array::check(hint_array_damage::damage_visitor &visitor)
walk(vv, visitor);
}
uint32_t
hint_array::check_width(uint32_t width)
{
if (width % 4 || width == 0 || width > 128) {
ostringstream msg;
msg << "invalid hint width: " << width;
throw runtime_error(msg.str());
}
return width;
}
//----------------------------------------------------------------