* HTree::_PrepareBlocksForHash() now uses arithmetic sum instead of bitwise, this should help to fix #7084.

* cleanup


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@40202 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Jérôme Duval 2011-01-11 17:39:51 +00:00
parent 2cc2a34c10
commit 776354b0f1

View File

@ -89,10 +89,7 @@ HTree::PrepareForHash()
return status;
CachedBlock cached(fDirectory->GetVolume());
const uint8* block = cached.SetTo(blockNum);
HTreeRoot* root = (HTreeRoot*)block;
HTreeRoot* root = (HTreeRoot*)cached.SetTo(blockNum);
if (root == NULL)
return B_IO_ERROR;
if (!root->IsValid())
@ -120,10 +117,7 @@ HTree::Lookup(const char* name, DirectoryIterator** iterator)
return _FallbackToLinearIteration(iterator);
CachedBlock cached(fDirectory->GetVolume());
const uint8* block = cached.SetTo(blockNum);
HTreeRoot* root = (HTreeRoot*)block;
HTreeRoot* root = (HTreeRoot*)cached.SetTo(blockNum);
if (root == NULL || !root->IsValid())
return _FallbackToLinearIteration(iterator);
@ -248,7 +242,6 @@ void
HTree::_HalfMD4Transform(uint32 buffer[4], uint32 blocks[8])
{
uint32 a, b, c, d;
a = buffer[0];
b = buffer[1];
c = buffer[2];
@ -311,7 +304,7 @@ HTree::_HashHalfMD4(const char* name, uint8 _length)
{
TRACE("HTree::_HashHalfMD4()\n");
uint32 buffer[4];
int32 length = (uint32)_length;
int32 length = _length;
buffer[0] = fHashSeed[0];
buffer[1] = fHashSeed[1];
@ -387,9 +380,9 @@ void
HTree::_PrepareBlocksForHash(const char* string, uint32 length, uint32* blocks,
uint32 numBlocks)
{
uint32 padding = (uint32)length;
padding = (padding << 8) | padding;
padding = (padding << 16) | padding;
uint32 padding = length;
padding |= padding << 8;
padding |= padding << 16;
uint32 numBytes = numBlocks * 4;
if (length > numBytes)
@ -398,10 +391,10 @@ HTree::_PrepareBlocksForHash(const char* string, uint32 length, uint32* blocks,
uint32 completeIterations = length / 4;
for (uint32 i = 0; i < completeIterations; ++i) {
uint32 value = (padding << 8) | *(string++);
value = (value << 8) | *(string++);
value = (value << 8) | *(string++);
value = (value << 8) | *(string++);
uint32 value = (padding << 8) + *(string++);
value = (value << 8) + *(string++);
value = (value << 8) + *(string++);
value = (value << 8) + *(string++);
blocks[i] = value;
}
@ -427,3 +420,4 @@ HTree::_FallbackToLinearIteration(DirectoryIterator** iterator)
return *iterator == NULL ? B_NO_MEMORY : B_OK;
}