Re: [PATCHv2] printf: Add format for 8-byte EUI-64 type
From: Joe Perches
Date: Wed Dec 09 2015 - 16:16:35 EST
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@xxxxxxxxx>
> ---
> 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@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/