From: Joe Perches <joe@perches.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
Andrew Morton <akpm@linux-foundation.org>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v1 1/1] lib/vsprintf: refactor duplicate code to xnumber()
Date: Mon, 28 Dec 2015 16:18:30 -0800 [thread overview]
Message-ID: <1451348310.3219.16.camel@perches.com> (raw)
In-Reply-To: <CAHp75Vdx2x8K0_LaJDY1nN0c+M9RUwAyHyoQ2jXz1FEGVOanRQ@mail.gmail.com>
On Mon, 2015-12-28 at 21:02 +0200, Andy Shevchenko wrote:
> On Mon, Dec 28, 2015 at 8:25 PM, Joe Perches <joe@perches.com> wrote:
> > On Mon, 2015-12-28 at 20:18 +0200, Andy Shevchenko wrote:
> > > xnumber() is a special helper to print a fixed size type in a hex format with
> > > '0x' prefix with padding and reduced size. In the module we have already
> > > several copies of such code. Consolidate them under xnumber() helper.
> > >
> > > There are couple of differences though.
> > >
> > > It seems nobody cared about the output in case of CONFIG_KALLSYMS=n when
> > > printing symbol address because the asked width is not enough to care either
> > > prefix or last byte. Fixed here.
> > >
> > > The %pNF specifier used to be allowed with a specific field width, though there
> > > is neither any user of it nor mention in the documentation.
> > >
> > > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > > ---
> > > lib/vsprintf.c | 43 +++++++++++++++----------------------------
> > > 1 file changed, 15 insertions(+), 28 deletions(-)
> > >
> > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> > > index dcf5646..e971549 100644
> > > --- a/lib/vsprintf.c
> > > +++ b/lib/vsprintf.c
> > > @@ -514,6 +514,16 @@ char *number(char *buf, char *end, unsigned long long num,
> > > return buf;
> > > }
> > >
> > > +static noinline_for_stack
> > > +char *xnumber(char *buf, char *end, unsigned long long value, unsigned int type,
> > > + struct printf_spec spec)
> >
> > xnumber isn't a great name.
>
> I rather agree, however had nothing yet to replace. Any ideas?
prefixed_hex_number?
> > unsigned int type should probably be size_t size
>
> Used to be :-), though I decided to move it to unsigned int since the
> resulting field is anyway 8 bits of unsigned int.
> If you think it's better to do all conversion inside xnumber (or
> whatever name it would be), I redo this.
It's going to get cast to that field size anyway
as either size_t or unsigned int
next prev parent reply other threads:[~2015-12-29 0:18 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-28 18:18 [PATCH v1 1/1] lib/vsprintf: refactor duplicate code to xnumber() Andy Shevchenko
2015-12-28 18:25 ` Joe Perches
2015-12-28 19:02 ` Andy Shevchenko
2015-12-29 0:18 ` Joe Perches [this message]
2015-12-28 21:42 ` Rasmus Villemoes
2015-12-28 22:20 ` Andy Shevchenko
2015-12-28 23:01 ` Rasmus Villemoes
2015-12-29 15:07 ` Andy Shevchenko
2015-12-28 22:20 ` Rasmus Villemoes
2015-12-28 22:29 ` Andy Shevchenko
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=1451348310.3219.16.camel@perches.com \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=andy.shevchenko@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
/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