Linux-NVME Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: joe@perches.com (Joe Perches)
Subject: [PATCHv2] printf: Add format for 8-byte EUI-64 type
Date: Wed, 09 Dec 2015 13:16:26 -0800	[thread overview]
Message-ID: <1449695786.25389.67.camel@perches.com> (raw)
In-Reply-To: <1449695357-22163-1-git-send-email-keith.busch@intel.com>

On Wed, 2015-12-09@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 at 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.

      reply	other threads:[~2015-12-09 21:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-09 21:09 [PATCHv2] printf: Add format for 8-byte EUI-64 type Keith Busch
2015-12-09 21:16 ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1449695786.25389.67.camel@perches.com \
    --to=joe@perches.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox