Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751617AbaGFOcq (ORCPT ); Sun, 6 Jul 2014 10:32:46 -0400 Received: from smtprelay0191.hostedemail.com ([216.40.44.191]:33686 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751492AbaGFOco (ORCPT ); Sun, 6 Jul 2014 10:32:44 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:960:968:973:988:989:1260:1261:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1542:1593:1594:1711:1730:1747:1777:1792:1981:2110:2194:2198:2199:2200:2393:2553:2559:2562:2693:2828:3138:3139:3140:3141:3142:3354:3622:3865:3866:3867:3868:3870:3871:3872:3873:3874:4250:4321:4605:5007:6119:7652:7903:8603:10004:10400:10848:11232:11658:11914:12296:12517:12519:12663:12679:12740:13141:13161:13229:13230:14096:14097:21080,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 X-HE-Tag: pin15_179044525991b X-Filterd-Recvd-Size: 3965 Message-ID: <1404657160.27043.29.camel@joe-AO725> Subject: Re: [PATCH] vsprintf: Remove SPECIAL from pointer types From: Joe Perches To: "Maciej W. Rozycki" Cc: Andrew Morton , Grant Likely , David Miller , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Date: Sun, 06 Jul 2014 07:32:40 -0700 In-Reply-To: References: <20140702.182807.1245632778216212860.davem@davemloft.net> <1404356734.14741.18.camel@joe-AO725> <1404364565.14741.26.camel@joe-AO725> <1404368746.14741.36.camel@joe-AO725> <1404576420.6384.41.camel@joe-AO725> <1404583739.6384.51.camel@joe-AO725> <1404585099.6384.53.camel@joe-AO725> <1404593114.6384.72.camel@joe-AO725> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.10.4-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sun, 2014-07-06 at 12:44 +0100, Maciej W. Rozycki wrote: > On Sat, 5 Jul 2014, Joe Perches wrote: > > > Because gcc issues a complaint about any pointer format with %#p, > > remove the use of SPECIAL to prefix 0x to various pointer types. [] > Conceptually good, thanks for your effort, but you still need to clear > SPECIAL in `pointer' and maybe elsewhere, as that'll have been set for the > case concerned in `format_decode' by this code: > > case '#': spec->flags |= SPECIAL; break; > > (that doesn't check what follows) and then respected once `number' is > reached. E.g.: > > char *pointer(const char *fmt, char *buf, char *end, void *ptr, > struct printf_spec spec) > { > int default_width = 2 * sizeof(void *); > > spec.flags &= ~SPECIAL; > > or suchlike. Sorry to have been unclear about it. I think you're not right here. The patch shouldn't remove the capability to prefix. But neither am I right with the commit log actually. It should say something like "remove the default extra width for the 0x prefix from %#p". Actually, I'm not sure that removing "SPECIAL adds the pointer prefix length" to width is that good. I think it doesn't matter much. I do like removing the prefix it from %pa though. linux's printf like capability is not exactly like gcc's. It doesn't have to be. linux's implementation already does not prefix 0x to pointers when gcc does. gcc uses '(nil)', linux '(null)', etc. And linux's variant does a bunch of extended outputs for %p variants where it overrides any size and prefixing specified. The only difference introduced by the proposed patch here is that a generic pointer type will now have a variable output width if %#p is used depending on the high two bytes of the pointer value if a size is not specified. fyi: gcc will output a prefix 0x with %#p just as it does for %p. The major difference is that linux uses a default of sizeof(void *) * 2 for the width and zero fills without prefix, gcc defaults to the minimum # of chars required and prefixes. cheers, Joe -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/