]> git.sesse.net Git - bcachefs-tools-debian/blobdiff - libbcachefs/printbuf.c
Disable pristine-tar option in gbp.conf, since there is no pristine-tar branch.
[bcachefs-tools-debian] / libbcachefs / printbuf.c
index 5e653eb81d54f8fdfcca37038eeaf5a1febdb8e7..b27d22925929a6554079fb8731f82dfb3dd0421c 100644 (file)
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: LGPL-2.1+
 /* Copyright (C) 2022 Kent Overstreet */
 
+#include <linux/bitmap.h>
 #include <linux/err.h>
 #include <linux/export.h>
 #include <linux/kernel.h>
@@ -55,6 +56,7 @@ void bch2_prt_vprintf(struct printbuf *out, const char *fmt, va_list args)
 
                va_copy(args2, args);
                len = vsnprintf(out->buf + out->pos, printbuf_remaining(out), fmt, args2);
+               va_end(args2);
        } while (len + 1 >= printbuf_remaining(out) &&
                 !bch2_printbuf_make_room(out, len + 1));
 
@@ -423,3 +425,24 @@ void bch2_prt_bitflags(struct printbuf *out,
                flags ^= BIT_ULL(bit);
        }
 }
+
+void bch2_prt_bitflags_vector(struct printbuf *out,
+                             const char * const list[],
+                             unsigned long *v, unsigned nr)
+{
+       bool first = true;
+       unsigned i;
+
+       for (i = 0; i < nr; i++)
+               if (!list[i]) {
+                       nr = i - 1;
+                       break;
+               }
+
+       for_each_set_bit(i, v, nr) {
+               if (!first)
+                       bch2_prt_printf(out, ",");
+               first = false;
+               bch2_prt_printf(out, "%s", list[i]);
+       }
+}