Re: [RFC][PATCH] printk: Add %pb to print bitmaps

Ingo Molnar
2012-05-09T13:36:13Z

* Peter Zijlstra <peterz@infradead.org> wrote:

> @@ -857,15 +860,19 @@ int kptr_restrict __read_mostly;
> * correctness of the format string and va_list arguments.
> * - 'K' For a kernel pointer that should be hidden from unprivileged users
> * - 'NF' For a netdev_features_t
> + * - 'b' For a bitmap, consumes 2 args, second is int

hm, won't the second arg confuse gcc's printf format checker?

> + case 'b':
> + {
> + int bits, len;
> +
> + switch (fmt[1]) {
> + case 'c':
> + bits = nr_cpumask_bits;
> + break;
> + case 'n':
> + bits = MAX_NUMNODES;
> + break;
> + default:
> + bits = va_arg(args, int);
> + break;
> + }
> +
> + len = bitmap_scnlistprintf(buf, end - buf, ptr, bits);

also, if the second argument is not provided, could va_arg()
return noise or even NULL?

Thanks,

Ingo