mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Enrico Weigelt, metux IT consult" <enrico.weigelt@gr13.net>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] lib: vsprintf: add printf format conversion %M for errno strings
Date: Sun, 25 Jun 2017 13:10:49 -0700	[thread overview]
Message-ID: <1498421449.24295.39.camel@perches.com> (raw)
In-Reply-To: <6a12988d-bbcc-54e7-be16-eeeb94f88d57@gr13.net>

On Sun, 2017-06-25 at 21:53 +0200, Enrico Weigelt, metux IT consult
wrote:
> On 25.06.2017 19:27, Joe Perches wrote:
> 
> > Every use of %M is going to cause gcc when using __printf to emit
> > a warning like:
> > 
> > unknown conversion type character ‘M’ in format [-Wformat=]
> 
> Yeah, that's still an open problem. Actually, I still haven't found out,
> how it's done w/ all the other kernel-internal conversions.

Everything else uses "%p<foo>", <object reference>

> I was under
> the impression, there was some magic to tell the compiler which letters
> correspond to which types - unfortunately, didn't find anything like
> that. Is that really hardcoded in gcc ?
> 
> > Beyond that, why is this useful?
> 
> Use that instead of %d where errno values are printed/logged.
> > There can't possibly be any fast-path use.
> 
> I'm using it eg. for driver development - always having to look up the
> numbers is quite ugly and time consuming.
> 
> > Why not just create a function that does errno/string conversions?
> 
> Already was about to do so. Shall I call it strerror() ?

I presume kstrerror

So use something like
	"%d: (%s)", errno, kstrerror(errno)

  reply	other threads:[~2017-06-25 20:10 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-25 17:12 Enrico Weigelt, metux IT consult
2017-06-25 17:24 ` Randy Dunlap
2017-06-25 17:27 ` Joe Perches
2017-06-25 19:53   ` Enrico Weigelt, metux IT consult
2017-06-25 20:10     ` Joe Perches [this message]
2017-06-25 21:18       ` Enrico Weigelt, metux IT consult
2017-06-25 22:47         ` Randy Dunlap
2017-06-26  0:42           ` Enrico Weigelt, metux IT consult
2017-06-27 11:02           ` Bernd Petrovitsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1498421449.24295.39.camel@perches.com \
    --to=joe@perches.com \
    --cc=enrico.weigelt@gr13.net \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®