From d5444d2255ced67cbc919489178e20d07058147a Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Mon, 10 Aug 2020 12:55:05 +0100 Subject: [PATCH] [thin_check (rust)] sm bitmap entries were being unpacked incorrectly. --- src/pdata/space_map.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/pdata/space_map.rs b/src/pdata/space_map.rs index 55c7457..9d46b32 100644 --- a/src/pdata/space_map.rs +++ b/src/pdata/space_map.rs @@ -134,11 +134,14 @@ impl Unpack for Bitmap { let val = word & 0x3; word >>= 2; - if val < 3 { - entries.push(BitmapEntry::Small(val as u8)); - } else { - entries.push(BitmapEntry::Overflow); - } + // The bits are stored with the high bit at b * 2 + 1, + // and low at b *2. So we have to interpret this val. + entries.push(match val { + 0 => BitmapEntry::Small(0), + 1 => BitmapEntry::Small(2), + 2 => BitmapEntry::Small(1), + _ => BitmapEntry::Overflow, + }); } i = tmp; @@ -173,7 +176,7 @@ where impl SpaceMap for CoreSpaceMap where V: Copy + Default + std::ops::AddAssign + From + Into, - { +{ fn get(&self, b: u64) -> Result { Ok(self.counts[b as usize].into()) }