Re: [PATCH v2] vsprintf: automatic parameters for %pIS via 'a'

From: Jason A. Donenfeld
Date: Fri Feb 05 2016 - 08:06:54 EST


On Fri, Feb 5, 2016 at 1:06 AM, Rasmus Villemoes
<linux@xxxxxxxxxxxxxxxxxx> wrote:
> First of all I don't think vsprintf.c should be extended with yet
> another piece of unused code, so I hope there's an actual user coming.

There is. Don't worry.

>
> Second, please add tests to lib/test_printf.c.

Sure, no problem. I'll add this in the next version.

>
> Third, wouldn't it be more convenient/flexible if a meant "print those
> that are present _and_ requested"; that is, the above would be
>
>> + have_p = have_p && sa->sin6_port;
>> + have_s = have_s && sa->sin6_scope_id;
>> + have_f = have_f && sa->sin6_flowinfo & IPV6_FLOWINFO_MASK;
>
> that way one could say %pISaf and have the flowinfo if and only if it's
> present, without also unintentionally turning on port or scope_id.

That's a great idea. I'll make this change too for the next version.