From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756527AbcBCXFd (ORCPT ); Wed, 3 Feb 2016 18:05:33 -0500 Received: from smtprelay0002.hostedemail.com ([216.40.44.2]:52323 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753171AbcBCXFZ (ORCPT ); Wed, 3 Feb 2016 18:05:25 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::,RULES_HIT:41:355:379:541:599:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1381:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2693:2828:3138:3139:3140:3141:3142:3353:3622:3865:3866:3867:3868:3871:3874:4321:5007:6261:10004:10400:10848:11026:11232:11473:11658:11783:11914:12048:12050:12517:12519:12740:13069:13161:13229:13311:13357:13894:14659: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,LFtime:2,LUA_SUMMARY:none X-HE-Tag: smoke12_6938599372d5e X-Filterd-Recvd-Size: 2133 Message-ID: <1454540721.7291.141.camel@perches.com> Subject: Re: [PATCH] vsprintf: automatic parameters for %pIS via 'a' From: Joe Perches To: "Jason A. Donenfeld" , Daniel Borkmann , Andrew Morton , linux@rasmusvillemoes.dk, andriy.shevchenko@linux.intel.com, LKML Date: Wed, 03 Feb 2016 15:05:21 -0800 In-Reply-To: <1454539981-15495-1-git-send-email-Jason@zx2c4.com> References: <1454536072.7291.133.camel@perches.com> <1454539981-15495-1-git-send-email-Jason@zx2c4.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 Wed, 2016-02-03 at 23:53 +0100, Jason A. Donenfeld wrote: > This patch adds a variable 'a' which indicates that the 'p', > 'f', and 's' options should be toggled on or off depending on > whether or not those parameters are actually valid inside the > passed sockaddr. OK > This is something that probably most users of > the %pIS family of functions will prefer to use. More doubtful. There isn't a single user of flowinfo or scope today. These are the current uses of %pIS       8 %pIS      11 %pISc       5 %pIScp       2 %pISp      23 %pISpc > diff --git a/lib/vsprintf.c b/lib/vsprintf.c [] > @@ -1169,9 +1169,18 @@ char *ip6_addr_string_sa(char *buf, char *end, const struct sockaddr_in6 *sa, >   case 'c': >   have_c = true; >   break; > + case 'a': > + have_a = true; > + break; >   } >   } >   > + if (have_a) { > + have_p = sa->sin6_port != 0; > + have_s = sa->sin6_scope_id != 0; > + have_f = sa->sin6_flowinfo != 0; Doesn't this needs the mask tested? sa->sin6_flowinfo & IPV6_FLOWINFO_MASK given the use of bool, the != 0 are unnecessary. Other than that, looks good to me.