[caching tools] handle version 1 metadata where policy_hint_width is zero
This commit is contained in:
@ -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;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------
|
||||
|
Reference in New Issue
Block a user