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


Groups > linux.kernel > #1693052

Re: [PATCH v2 3/3] nvme: wwid_show: strip trailing 0-bytes

From Joe Perches <joe@perches.com>
Newsgroups linux.kernel
Subject Re: [PATCH v2 3/3] nvme: wwid_show: strip trailing 0-bytes
Date 2017-07-20 18:00 +0200
Message-ID <u5m1Q-11d-19@gated-at.bofh.it> (permalink)
References <u5lyN-QM-1@gated-at.bofh.it> <u5lyO-QM-21@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Thu, 2017-07-20 at 17:27 +0200, Martin Wilck wrote:
> Some broken targets (such as the current Linux target) pad
> model or serial fields with 0-bytes rather than spaces. The
> NVME spec disallows 0 bytes in "ASCII" fields.
> Thus strip trailing 0-bytes, too.
> 
> Signed-off-by: Martin Wilck <mwilck@suse.com>
> Reviewed-by: Hannes Reinecke <hare@suse.de>
> Acked-by: Christoph Hellwig <hch@lst.de>
> 
> ---
>  drivers/nvme/host/core.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
[]
> @@ -2001,9 +2001,11 @@ static ssize_t wwid_show(struct device *dev, struct device_attribute *attr,
>  	if (memchr_inv(ns->eui, 0, sizeof(ns->eui)))
>  		return sprintf(buf, "eui.%8phN\n", ns->eui);
>  
> -	while (ctrl->serial[serial_len - 1] == ' ')
> +	while (ctrl->serial[serial_len - 1] == ' ' ||
> +	       ctrl->serial[serial_len - 1] == '\0')
>  		serial_len--;
> -	while (ctrl->model[model_len - 1] == ' ')
> +	while (ctrl->model[model_len - 1] == ' ' ||
> +	       ctrl->model[model_len - 1] == '\0')
>  		model_len--;

Please add a <foo>_len > 0 to the while loops too

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


Thread

[PATCH v2 0/3] Improve readbility of NVME "wwid" attribute Martin Wilck <mwilck@suse.com> - 2017-07-20 17:30 +0200
  [PATCH v2 1/3] string.h: add memcpy_and_pad() Martin Wilck <mwilck@suse.com> - 2017-07-20 17:30 +0200
  [PATCH v2 3/3] nvme: wwid_show: strip trailing 0-bytes Martin Wilck <mwilck@suse.com> - 2017-07-20 17:30 +0200
    Re: [PATCH v2 3/3] nvme: wwid_show: strip trailing 0-bytes Joe Perches <joe@perches.com> - 2017-07-20 18:00 +0200
  [PATCH v2 2/3] nvmet: identify controller: improve standard compliance Martin Wilck <mwilck@suse.com> - 2017-07-20 17:30 +0200

csiph-web