From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752890AbbL2ASg (ORCPT ); Mon, 28 Dec 2015 19:18:36 -0500 Received: from smtprelay0238.hostedemail.com ([216.40.44.238]:50374 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752650AbbL2ASd (ORCPT ); Mon, 28 Dec 2015 19:18:33 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::,RULES_HIT:41:69:334:355:368:369:379:541:560:599:800:960:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1431:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4321:5007:6119:6261:7807:8603:10004:10400:10848:11026:11232:11658:11783:11914:12043:12296:12517:12519:12555:12683:12740:13138:13231:13894:14659:21080:30003:30012:30029:30034:30051:30054:30089:30090:30091,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:1,LUA_SUMMARY:none X-HE-Tag: guide80_2d5b58ff2813c X-Filterd-Recvd-Size: 3183 Message-ID: <1451348310.3219.16.camel@perches.com> Subject: Re: [PATCH v1 1/1] lib/vsprintf: refactor duplicate code to xnumber() From: Joe Perches To: Andy Shevchenko Cc: Andy Shevchenko , Andrew Morton , Rasmus Villemoes , "linux-kernel@vger.kernel.org" Date: Mon, 28 Dec 2015 16:18:30 -0800 In-Reply-To: References: <1451326703-122826-1-git-send-email-andriy.shevchenko@linux.intel.com> <1451327112.3219.14.camel@perches.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.3-1ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, 2015-12-28 at 21:02 +0200, Andy Shevchenko wrote: > On Mon, Dec 28, 2015 at 8:25 PM, Joe Perches 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 > > > --- > > >  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