nvme-cli: code cleanup
cover nvme-cli: code cleanup
Hi,
This is a small code cleanup patch-series for nvme-cli.
Regards,
Chaitanya
Chaitanya Kulkarni (6):
nvme-cli: cmbloc code cleanup
nvme-cli: code cleanup adjust if statement
nvme-cli: remove trailing space
nvme-cli: use uniform if .. else format
nvme-cli: use uniform if .. else format
nvme-cli: use uniform if .. else format
nvme-ioctl.c | 2 +- nvme-lightnvm.c | 3 +-- nvme-models.c | 3 +-- nvme-print.c | 7 +++---- nvme.c | 6 ++---- 5 files changed, 8 insertions(+), 13 deletions(-)
Signature · 1 line
2.17.0
PATCH 1/6 nvme-cli: cmbloc code cleanup
This patch removes the unnecessary else condition which is out of format anyway.
--- nvme-print.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
nvme-print.c +3 -4
@@ -3031,12 +3031,11 @@ static void show_registers_cmbloc(__u32 cmbloc, __u32 cmbsz) {if (cmbsz ==0 ) {printf ("\tController Memory Buffer feature is not supported\n\n" ); +return ; } -else { -printf ("\tOffset (OFST): %x (See cmbsz.szu for granularity)\n" , +printf ("\tOffset (OFST): %x (See cmbsz.szu for granularity)\n" , (cmbloc &0xfffff000 ) >>12 ); -printf ("\tBase Indicator Register (BIR): %x\n\n" , cmbloc &0x00000007 ); - } +printf ("\tBase Indicator Register (BIR): %x\n\n" , cmbloc &0x00000007 ); }static const char *nvme_register_szu_to_string (__u8 szu)
Signature · 1 line
2.17.0
PATCH 2/6 nvme-cli: code cleanup adjust if statement
In reply to Chaitanya Kulkarni--- nvme-ioctl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-ioctl.c +1 -1
@@ -563,7 +563,7 @@ static int nvme_property(int fd, __u8 fctype, __le32 off, __le64 *value, __u8 atif (fctype == nvme_fabrics_type_property_get){ cmd.nsid = nvme_fabrics_type_property_get; - }else if (fctype == nvme_fabrics_type_property_set) { + }else if (fctype == nvme_fabrics_type_property_set) { cmd.nsid = nvme_fabrics_type_property_set; cmd.cdw12 = *value; }else {
Signature · 1 line
2.17.0
PATCH 3/6 nvme-cli: remove trailing space
In reply to Chaitanya Kulkarni--- nvme-print.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-print.c +1 -1
@@ -3035,7 +3035,7 @@ static void show_registers_cmbloc(__u32 cmbloc, __u32 cmbsz) }printf ("\tOffset (OFST): %x (See cmbsz.szu for granularity)\n" , (cmbloc &0xfffff000 ) >>12 ); -printf ("\tBase Indicator Register (BIR): %x\n\n" , cmbloc &0x00000007 ); +printf ("\tBase Indicator Register (BIR): %x\n\n" , cmbloc &0x00000007 ); }static const char *nvme_register_szu_to_string (__u8 szu)
Signature · 1 line
2.17.0
PATCH 4/6 nvme-cli: use uniform if .. else format
In reply to Chaitanya Kulkarni--- nvme.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-)
nvme.c +2 -4
@@ -212,8 +212,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plugjson_smart_log (&smart_log, cfg.namespace_id, devicename); else show_smart_log(&smart_log, cfg.namespace_id, devicename); - } -else if (err >0 ) + }else if (err >0 )show_nvme_status (err);else perror ("smart log" );
@@ -2244,8 +2243,7 @@ static int virtual_mgmt(int argc, char **argv, struct command *cmd, struct plugi err =nvme_virtual_mgmt (fd, cfg.cdw10, cfg.cdw11, &result);if (!err) {printf ("success, Number of Resources allocated:%#x\n" , result); - } -else if (err >0 ) { + }else if (err >0 ) {show_nvme_status (err); }else perror ("virt-mgmt" );
Signature · 1 line
2.17.0
PATCH 5/6 nvme-cli: use uniform if .. else format
In reply to Chaitanya Kulkarni--- nvme-models.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
nvme-models.c +1 -2
@@ -259,8 +259,7 @@ static FILE *open_pci_ids(void)if ((pci_ids_path =getenv ("PCI_IDS_PATH" )) !=NULL ) {if ((fp =fopen (pci_ids_path,"r" )) !=NULL ) {return fp; - } -else { + }else {/* fail if user provided environment variable but could not open */ perror (pci_ids_path);return NULL ;
Signature · 1 line
2.17.0
PATCH 6/6 nvme-cli: use uniform if .. else format
In reply to Chaitanya Kulkarni--- nvme-lightnvm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
nvme-lightnvm.c +1 -2
@@ -459,8 +459,7 @@ int lnvm_do_id_ns(int fd, int nsid, unsigned int flags)d_raw ((unsigned char *)&nvm_id,sizeof (nvm_id)); else show_lnvm_id_ns(&nvm_id, flags); - } -else if (err >0 ) + }else if (err >0 )fprintf (stderr,"NVMe Status:%s(%x) NSID:%d\n" ,nvme_status_to_string (err), err, nsid);return err;
Signature · 1 line
2.17.0
Keith Busch
maintainercover nvme-cli: code cleanup
In reply to Chaitanya KulkarniQuoted 3 lines · Chaitanya Kulkarni
Hi,
This is a small code cleanup patch-series for nvme-cli.
Thanks, I've appied all of these.