Re: [PATCH v2] vsprintf: introduce %dE for error constants

From: Uwe Kleine-KÃnig
Date: Wed Aug 28 2019 - 12:22:49 EST


On 8/28/19 2:59 PM, Sergey Senozhatsky wrote:
> On (08/28/19 14:49), Rasmus Villemoes wrote:
>> On 28/08/2019 14.02, Sergey Senozhatsky wrote:
>>> On (08/28/19 14:54), Jani Nikula wrote:
>>> [..]
>>>>> I personally think that this feature is not worth the code, data,
>>>>> and bikeshedding.
>>>>
>>>> The obvious alternative, I think already mentioned, is to just add
>>>> strerror() or similar as a function. I doubt there'd be much opposition
>>>> to that. Folks could use %s and strerr(ret). And a follow-up could add
>>>> the special format specifier if needed.
>>>
>>> Yeah, I'd say that strerror() would be a better alternative
>>> to vsprintf() specifier. (if we decide to add such functionality).
>>
>> Please no. The .text footprint of the changes at the call sites to do
>> pr_err("...%s...", errcode(err)) instead of the current
>> pr_err("...%d...", err) would very soon dwarf whatever is necessary to
>> implement %pE or %dE.

Yeah, that's what I think, too. I cannot imagine a user of strerror()
who needs the string representation for something different than to feed
it to one of the family members of printk. That's also why I think that
the other already existing format specifier are a good idea.

It might not be the nicest part of the printk code, but this way it is
at least concentrated in one place only.

> New vsprintf() specifiers have some downsides as well. Should %dE
> accidentally (via backport) make it to the -stable kernel, which
> does not support %dE, and we are going to lose the actual error
> code value as well.

That is wrong. When you do

pr_err("There are no round tuits to give out: %dE\n", -ENOENT);

in a kernel that doesn't support %dE you get:

There are no round tuits to give out: -2E

That's a bit ugly but I can still work out what the original value was.

Best regards
Uwe

Attachment: signature.asc
Description: OpenPGP digital signature