Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1287866

Re: [PATCHv2] printf: Add format for 8-byte EUI-64 type

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCHv2] printf: Add format for 8-byte EUI-64 type
Date 2015-12-09 22:20 +0100
Message-ID <qDUjw-5eV-9@gated-at.bofh.it> (permalink)
References <qDU9P-5bQ-1@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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.
--
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/

Back to linux.kernel | Previous | NextPrevious in thread | Find similar | Unroll thread


Thread

[PATCHv2] printf: Add format for 8-byte EUI-64 type Keith Busch <keith.busch@intel.com> - 2015-12-09 22:10 +0100
  Re: [PATCHv2] printf: Add format for 8-byte EUI-64 type Joe Perches <joe@perches.com> - 2015-12-09 22:20 +0100

csiph-web