All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gris Ge <fge@redhat.com>
To: Vaibhav Jain <vaibhav@linux.vnet.ibm.com>
Cc: Doug Gilbert <dgilbert@interlog.com>,
	linux-scsi@vger.kernel.org, Jon Grimm <jon.grimm@canonical.com>,
	Vipin K Parashar <vipin@linux.vnet.ibm.com>,
	Ping Tian Han <pthan@cn.ibm.com>
Subject: Re: [PATCH] lsscsi: Fix truncation of 128-bit wwn
Date: Fri, 17 Mar 2017 18:28:49 +0800	[thread overview]
Message-ID: <20170317102849.GA2719@redhat.com> (raw)
In-Reply-To: <20170317043840.26560-1-vaibhav@linux.vnet.ibm.com>

[-- Attachment #1: Type: text/plain, Size: 2156 bytes --]

On Fri, Mar 17, 2017 at 10:08:40AM +0530, Vaibhav Jain wrote:
> ---
>  src/lsscsi.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/src/lsscsi.c b/src/lsscsi.c
> index 974b3f1..f20adcf 100644
> --- a/src/lsscsi.c
> +++ b/src/lsscsi.c
> @@ -210,8 +210,8 @@ struct dev_node_list {
>  static struct dev_node_list* dev_node_listhead = NULL;
>  
>  struct disk_wwn_node_entry {
> -       char wwn[32];
> -       char disk_bname[12];
> +	char wwn[35]; /* '0x' + wwn<128-bit> + <null-terminator> */
Please consider to define a constant instead of using a magic number
everywhere. Like:
#define _DISK_WWN_MAX_LEN           35
/* ^ WWN here is extracted from /dev/disk/by-id/wwn-<WWN> which is
 *   created by udev 60-persistent-storage.rules using ID_WWN_WITH_EXTENSION.
 *   The udev ID_WWN_WITH_EXTENSION is the combination of char wwn[17] and
 *   char wwn_vendor_extension[17] from struct scsi_id_device.
 */
> +	char disk_bname[12];
Please use space instead of \t for indention.
>  };
>  
>  #define DISK_WWN_NODE_LIST_ENTRIES 16
> @@ -2939,14 +2939,14 @@ one_sdev_entry(const char * dir_name, const char * devname,
>                  }
>                  if (wd[0]) {
>                          char dev_node[LMAX_NAME] = "";
> -                        char wwn_str[34];
> +			char wwn_str[35];
Please use space instead of \t for indention.
>                          enum dev_type typ;
>  
>                          typ = (FT_BLOCK == non_sg.ft) ? BLK_DEV : CHR_DEV;
>                          if (get_wwn) {
>                                  if ((BLK_DEV == typ) &&
>                                      get_disk_wwn(wd, wwn_str, sizeof(wwn_str)))
> -                                        printf("%-30s  ", wwn_str);
> +					printf("%-34s  ", wwn_str);
Please use constant instead of magic number:
    printf("%-*s  ", _DISK_WWN_MAX_LEN - 1, wwn_str);
>                                  else
>                                          printf("                          "
>                                                 "      ");
> -- 
> 2.9.3
> 

-- 
Gris Ge

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2017-03-17 10:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-17  4:38 [PATCH] lsscsi: Fix truncation of 128-bit wwn Vaibhav Jain
2017-03-17 10:28 ` Gris Ge [this message]
2017-03-24  4:18   ` Vaibhav Jain

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=20170317102849.GA2719@redhat.com \
    --to=fge@redhat.com \
    --cc=dgilbert@interlog.com \
    --cc=jon.grimm@canonical.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=pthan@cn.ibm.com \
    --cc=vaibhav@linux.vnet.ibm.com \
    --cc=vipin@linux.vnet.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.