A computation for when a block group overruns the end of an image
was consistently storing a negative number in an unsigned var,
and then checking for >0, which is always true for negative numbers.
So first check if the number will be positive before computing it.
Change-Id: Ic8cff8f9ab9f4ea8c5a4dc42143c2430fa87ba12
if (reserve_blocks(bg, bg->first_free_block, bg->header_blocks) < 0)
error("failed to reserve %u blocks in block group %u\n", bg->header_blocks, i);
- u32 overrun = bg->first_block + info.blocks_per_group - aux_info.len_blocks;
- if (overrun > 0)
+ if (bg->first_block + info.blocks_per_group > aux_info.len_blocks) {
+ u32 overrun = bg->first_block + info.blocks_per_group - aux_info.len_blocks;
reserve_blocks(bg, info.blocks_per_group - overrun, overrun);
+ }
}
void block_allocator_init()