Fix CID 712419, 712420, 712421, 712422: Unintentional sign extension to 64 bits.

This commit is contained in:
Alex Smith 2012-07-31 10:12:33 +01:00
parent 8ffd0477dd
commit caa1e8b742
3 changed files with 8 additions and 5 deletions

View File

@ -1990,8 +1990,9 @@ BlockAllocator::_CheckInodeBlocks(Inode* inode, const char* name)
if (status != B_OK)
return status;
int32 maxIndex = (indirect.Length() << fVolume->BlockShift())
/ sizeof(block_run);
int32 maxIndex =
((uint32)indirect.Length() << fVolume->BlockShift())
/ sizeof(block_run);
for (int32 index = 0; index < maxIndex; ) {
block_run* runs = (block_run*)cachedDirect.SetTo(

View File

@ -1517,7 +1517,8 @@ Inode::FindBlockRun(off_t pos, block_run& run, off_t& offset)
<< fVolume->BlockShift();
if (runBlockEnd > pos) {
run = data->direct[current];
offset = runBlockEnd - (run.Length() << fVolume->BlockShift());
offset = runBlockEnd
- ((uint32)run.Length() << fVolume->BlockShift());
return fVolume->ValidateBlockRun(run);
}
}
@ -1878,7 +1879,7 @@ Inode::_GrowStream(Transaction& transaction, off_t size)
data->max_indirect_range = HOST_ENDIAN_TO_BFS_INT64(
data->MaxIndirectRange()
+ (run.Length() << fVolume->BlockShift()));
+ ((uint32)run.Length() << fVolume->BlockShift()));
data->size = HOST_ENDIAN_TO_BFS_INT64(blocksNeeded > 0
? data->MaxIndirectRange() : size);
continue;

View File

@ -527,7 +527,8 @@ bfs_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset, size_t size,
return status;
vecs[index].offset = volume->ToOffset(run) + offset - fileOffset;
vecs[index].length = (run.Length() << blockShift) - offset + fileOffset;
vecs[index].length = ((uint32)run.Length() << blockShift)
- offset + fileOffset;
// are we already done?
if ((uint64)size <= (uint64)vecs[index].length