From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754448AbbI3PlG (ORCPT ); Wed, 30 Sep 2015 11:41:06 -0400 Received: from mga03.intel.com ([134.134.136.65]:34011 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754335AbbI3PlD (ORCPT ); Wed, 30 Sep 2015 11:41:03 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.17,613,1437462000"; d="scan'208";a="816320533" Message-ID: <1443627654.8361.315.camel@linux.intel.com> Subject: Re: [PATCH v2 3/4] lib/vsprintf.c: Remove SPECIAL handling in pointer() From: Andy Shevchenko To: Rasmus Villemoes , Andrew Morton Cc: Tejun Heo , linux-kernel@vger.kernel.org, Kees Cook , Joe Perches Date: Wed, 30 Sep 2015 18:40:54 +0300 In-Reply-To: <1443627051-14003-4-git-send-email-linux@rasmusvillemoes.dk> References: <1443202865-25533-1-git-send-email-linux@rasmusvillemoes.dk> <1443627051-14003-1-git-send-email-linux@rasmusvillemoes.dk> <1443627051-14003-4-git-send-email-linux@rasmusvillemoes.dk> Organization: Intel Finland Oy Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.16.3-1 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 Wed, 2015-09-30 at 17:30 +0200, Rasmus Villemoes wrote: > As a quick > > git grep -E '%[ +0#-]*#[ +0#-]*(\*|[0-9]+)?(\.(\*|[0-9]+)?)?p' > > shows, nobody uses the # flag with %p. Should one try to do so, one > will be met with > > warning: `#' flag used with ā€˜%p’ gnu_printf format [-Wformat] > > (POSIX and C99 both say "... For other conversion specifiers, the > behavior is undefined.". Obviously, the kernel can choose to define > the behaviour however it wants, but as long as gcc issues that > warning, users are unlikely to show up.) > > Since default_width is effectively always 2*sizeof(void*), we can > simplify the prologue of pointer() and save a few instructions. > Reviewed-by: Andy Shevchenko > Signed-off-by: Rasmus Villemoes > --- > v2: reword slightly, refer to POSIX/C99. > > lib/vsprintf.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/vsprintf.c b/lib/vsprintf.c > index 03fa10b4be96..98b0d7be3fb7 100644 > --- a/lib/vsprintf.c > +++ b/lib/vsprintf.c > @@ -1457,7 +1457,7 @@ static noinline_for_stack > char *pointer(const char *fmt, char *buf, char *end, void *ptr, > struct printf_spec spec) > { > - int default_width = 2 * sizeof(void *) + (spec.flags & > SPECIAL ? 2 : 0); > + const int default_width = 2 * sizeof(void *); > > if (!ptr && *fmt != 'K') { > /* -- Andy Shevchenko Intel Finland Oy