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 02dd3236d2
commit 3cd66dda5e
3 changed files with 8 additions and 5 deletions
@@ -1990,8 +1990,9 @@ BlockAllocator::_CheckInodeBlocks(Inode* inode, const char* name)
if (status != B_OK) if (status != B_OK)
return status; return status;
int32 maxIndex = (indirect.Length() << fVolume->BlockShift()) int32 maxIndex =
/ sizeof(block_run); ((uint32)indirect.Length() << fVolume->BlockShift())
/ sizeof(block_run);
for (int32 index = 0; index < maxIndex; ) { for (int32 index = 0; index < maxIndex; ) {
block_run* runs = (block_run*)cachedDirect.SetTo( block_run* runs = (block_run*)cachedDirect.SetTo(
@@ -1517,7 +1517,8 @@ Inode::FindBlockRun(off_t pos, block_run& run, off_t& offset)
<< fVolume->BlockShift(); << fVolume->BlockShift();
if (runBlockEnd > pos) { if (runBlockEnd > pos) {
run = data->direct[current]; run = data->direct[current];
offset = runBlockEnd - (run.Length() << fVolume->BlockShift()); offset = runBlockEnd
- ((uint32)run.Length() << fVolume->BlockShift());
return fVolume->ValidateBlockRun(run); 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->max_indirect_range = HOST_ENDIAN_TO_BFS_INT64(
data->MaxIndirectRange() data->MaxIndirectRange()
+ (run.Length() << fVolume->BlockShift())); + ((uint32)run.Length() << fVolume->BlockShift()));
data->size = HOST_ENDIAN_TO_BFS_INT64(blocksNeeded > 0 data->size = HOST_ENDIAN_TO_BFS_INT64(blocksNeeded > 0
? data->MaxIndirectRange() : size); ? data->MaxIndirectRange() : size);
continue; continue;
@@ -527,7 +527,8 @@ bfs_get_file_map(fs_volume* _volume, fs_vnode* _node, off_t offset, size_t size,
return status; return status;
vecs[index].offset = volume->ToOffset(run) + offset - fileOffset; 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? // are we already done?
if ((uint64)size <= (uint64)vecs[index].length if ((uint64)size <= (uint64)vecs[index].length