Add a ret variable, saves a branch on return.
Signed-off-by: Jens Axboe <axboe@kernel.dk>
static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
uint64_t index)
{
static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
uint64_t index)
{
/*
* Start at the bottom, then converge towards first free bit at the top
/*
* Start at the bottom, then converge towards first free bit at the top
for (i = level; i >= 0; i--) {
struct axmap_level *al = &axmap->levels[i];
for (i = level; i >= 0; i--) {
struct axmap_level *al = &axmap->levels[i];
+ /*
+ * Clear 'ret', this is a bug condition.
+ */
if (index >= al->map_size) {
if (index >= al->map_size) {
* First free bit here is our index into the first
* free bit at the next higher level
*/
* First free bit here is our index into the first
* free bit at the next higher level
*/
- index = (j << UNIT_SHIFT) + ffz(al->map[j]);
- found = 1;
+ ret = index = (j << UNIT_SHIFT) + ffz(al->map[j]);
- return found ? index : (uint64_t) -1ULL;
}
uint64_t axmap_first_free(struct axmap *axmap)
}
uint64_t axmap_first_free(struct axmap *axmap)