Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753125AbbLIVQc (ORCPT ); Wed, 9 Dec 2015 16:16:32 -0500 Received: from smtprelay0025.hostedemail.com ([216.40.44.25]:51135 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752612AbbLIVQb (ORCPT ); Wed, 9 Dec 2015 16:16:31 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::::::::::::,RULES_HIT:41:355:379:541:599:800:960:968:973:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2198:2199:2393:2553:2559:2562:2828:2911:3138:3139:3140:3141:3142:3353:3622:3865:3867:3868:3870:3871:3874:4321:4425:5007:6261:7903:7974:9040:10004:10400:10848:11026:11232:11658:11914:12517:12519:12740:13069:13311:13357:13894:14659:21080:30054:30064: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:2,LUA_SUMMARY:none X-HE-Tag: ball51_729f95a2aa937 X-Filterd-Recvd-Size: 2346 Message-ID: <1449695786.25389.67.camel@perches.com> Subject: Re: [PATCHv2] printf: Add format for 8-byte EUI-64 type From: Joe Perches To: Keith Busch , linux-nvme@lists.infradead.org, LKML Cc: Matthew Wilcox , Greg Kroah-Hartman , Jens Axboe , Christoph Hellwig , Dan Williams Date: Wed, 09 Dec 2015 13:16:26 -0800 In-Reply-To: <1449695357-22163-1-git-send-email-keith.busch@intel.com> References: <1449695357-22163-1-git-send-email-keith.busch@intel.com> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.18.2-0ubuntu2 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 Content-Length: 1525 Lines: 52 On Wed, 2015-12-09 at 14:09 -0700, Keith Busch wrote: > MAC addresses may be formed using rules based on EUI-64, which is 2 bytes > longer than a typical 6-byte MAC. This patch adds a long specifier to > the %pM format to support the extended unique identifier. > > Since there are now two cases that use the default ':' separator, this > initializes the separator during its declaration, and removes the switch > fall through case. > > Signed-off-by: Keith Busch > --- > Changed from previos version: > > ? Fixed checks for the 'l' specifier. This can be in fmt[1] or fmt[2], > ? pointed out by Joe Perches from original review (thanks!). [] > diff --git a/lib/vsprintf.c b/lib/vsprintf.c [] > @@ -902,20 +902,33 @@ char *mac_address_string(char *buf, char *end, u8 *addr, > ? > ? case 'R': > ? reversed = true; > - /* fall through */ > + break; > + > + case 'l': > + bytes = 8; > + break; > ? > ? default: > - separator = ':'; > ? break; > ? } > + if (separator == '-' || reversed) { > + /* 'F' and 'R' may take additional length specifier */ > + switch (fmt[2]) { > + case 'l': > + bytes = 8; > + break; > + default: > + break; > + } > + } > Using a while (isalpha(*++fmt)) loop like ip6_addr_string_sa would probably be simpler. -- 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/