lkml.org 
[lkml]   [2015]   [Dec]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCHv2] printf: Add format for 8-byte EUI-64 type
From
Date
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 <keith.busch@intel.com>
> ---
> 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.


\
 
 \ /
  Last update: 2015-12-09 22:41    [W:0.034 / U:1.668 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site