Re: [PATCH 02/32] lib/vsprintf: implement bitmap printing through '%*pb[l]'

From: Peter Zijlstra
Date: Mon Jan 26 2015 - 08:50:16 EST


On Sat, Jan 24, 2015 at 09:03:08AM -0500, Tejun Heo wrote:

> There have been a couple different attempts at making this easier.
>
> 1. Way back, PeterZ tried printk '%pb' extension with the precision
> for bit width - '%.*pb'. This was intuitive and made sense but
> unfortunately triggered a compile warning about using precision
> for a pointer.
>
> http://lkml.kernel.org/g/1336577562.2527.58.camel@twins

> So, this patch is another attempt at teaching printk and friends how
> to print bitmaps. It's almost identical to what PeterZ tried with
> precision but it uses the field width for the number of bits instead
> of precision. The format used is '%*pb[l]', with the optional
> trailing 'l' specifying list format instead of hex masks.

> This is a valid format string and doesn't trigger compiler warnings;
> however, it does make it impossible to specify output field width when
> printing bitmaps.

> I think this is an acceptable trade-off given how
> much easier it makes printing bitmaps and that we don't have any
> in-kernel user which is using the field width specification.

Yeah, I suppose this is indeed the best we can do; and loosing the width
thing (which is a rarely used feature for in kernel things) seems
acceptable indeed. We did mention the option back then, but didn't
pursue it.

I like the extra 'l' fmt option.

> Signed-off-by: Tejun Heo <tj@xxxxxxxxxx>

Acked-by: Peter Zijlstra (Intel) <peterz@xxxxxxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/