[VFS] Fix BlockToHashBlockOffset's level 2 case (blockStep0 -> blockStep1)

& changed code to switch statement instead.
This commit is contained in:
emoose 2020-01-11 09:31:31 +00:00 committed by illusion
parent deb9661852
commit c552a853e0
1 changed files with 20 additions and 16 deletions

View File

@ -654,24 +654,28 @@ size_t StfsContainerDevice::BlockToHashBlockOffset(uint64_t block,
} }
uint64_t backing_num = 0; uint64_t backing_num = 0;
if (hash_level == 0) { switch (hash_level) {
backing_num = (block / 0xAA) * blockStep0; case 0:
if (block / 0xAA == 0) { backing_num = (block / 0xAA) * blockStep0;
return BackingBlockToOffsetSTFS(backing_num); if (block / 0xAA == 0) {
} return BackingBlockToOffsetSTFS(backing_num);
}
backing_num = backing_num + ((block / 0x70E4) + 1) * numTables; backing_num += ((block / 0x70E4) + 1) * numTables;
if (block / 0x70E4 == 0) { if (block / 0x70E4 == 0) {
return BackingBlockToOffsetSTFS(backing_num); return BackingBlockToOffsetSTFS(backing_num);
} }
} else if (hash_level == 1) { break;
backing_num = (block / 0x70E4) * blockStep1; case 1:
if (block / 0x70E4 == 0) { backing_num = (block / 0x70E4) * blockStep1;
return BackingBlockToOffsetSTFS(backing_num + blockStep0); if (block / 0x70E4 == 0) {
} return BackingBlockToOffsetSTFS(backing_num + blockStep0);
} else { }
return BackingBlockToOffsetSTFS(blockStep0); break;
default:
return BackingBlockToOffsetSTFS(blockStep1);
} }
return BackingBlockToOffsetSTFS(backing_num + numTables); return BackingBlockToOffsetSTFS(backing_num + numTables);
} }