axmap: a few more cleanups
[fio.git] / lib / axmap.c
index 4dbef31c22738651efae5805fabeeff015e71635..e4e40bf063fcd5297716d490a1f24d8269b71642 100644 (file)
@@ -173,10 +173,8 @@ static bool axmap_handler(struct axmap *axmap, uint64_t bit_nr,
 }
 
 static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
-       bool (*func)(struct axmap_level *, unsigned long, unsigned int, void *),
-       void *data)
+       bool (*func)(struct axmap_level *, unsigned long, unsigned int, void *))
 {
-       struct axmap_level *al;
        int i;
 
        for (i = axmap->nr_levels - 1; i >= 0; i--) {
@@ -184,9 +182,7 @@ static bool axmap_handler_topdown(struct axmap *axmap, uint64_t bit_nr,
                unsigned long offset = index >> UNIT_SHIFT;
                unsigned int bit = index & BLOCKS_PER_UNIT_MASK;
 
-               al = &axmap->levels[i];
-
-               if (func(al, offset, bit, data))
+               if (func(&axmap->levels[i], offset, bit, NULL))
                        return true;
        }
 
@@ -329,7 +325,7 @@ static bool axmap_isset_fn(struct axmap_level *al, unsigned long offset,
 bool axmap_isset(struct axmap *axmap, uint64_t bit_nr)
 {
        if (bit_nr <= axmap->nr_bits)
-               return axmap_handler_topdown(axmap, bit_nr, axmap_isset_fn, NULL);
+               return axmap_handler_topdown(axmap, bit_nr, axmap_isset_fn);
 
        return false;
 }
@@ -347,13 +343,8 @@ static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
        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) {
-                       ret = -1ULL;
-                       break;
-               }
+               if (index >= al->map_size)
+                       goto err;
 
                for (j = index; j < al->map_size; j++) {
                        if (al->map[j] == -1UL)
@@ -371,6 +362,7 @@ static uint64_t axmap_find_first_free(struct axmap *axmap, unsigned int level,
        if (ret < axmap->nr_bits)
                return ret;
 
+err:
        return (uint64_t) -1ULL;
 }