bcachefs: Fix bch2_prt_bitflags()
authorKent Overstreet <kent.overstreet@linux.dev>
Sun, 22 Oct 2023 21:22:53 +0000 (17:22 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 31 Oct 2023 16:18:37 +0000 (12:18 -0400)
This fixes an infinite loop when there's a set bit at position >= 32.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/printbuf.c

index de41f9a144920b83fb816182a4c97fecc1df87bf..5e653eb81d54f8fdfcca37038eeaf5a1febdb8e7 100644 (file)
@@ -415,11 +415,11 @@ void bch2_prt_bitflags(struct printbuf *out,
        while (list[nr])
                nr++;
 
-       while (flags && (bit = __ffs(flags)) < nr) {
+       while (flags && (bit = __ffs64(flags)) < nr) {
                if (!first)
                        bch2_prt_printf(out, ",");
                first = false;
                bch2_prt_printf(out, "%s", list[bit]);
-               flags ^= 1 << bit;
+               flags ^= BIT_ULL(bit);
        }
 }