Skip to contentSkip to conversation

nvme-cli: code cleanup

PATCH New Chaitanya Kulkarni 2 participants 8 messages May 12, 2019 – May 14, 2019 NVMe

lore
Share & tools
lore
#0 lore raw

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
#1 lore raw

PATCH 1/6 nvme-cli: cmbloc code cleanup

This patch removes the unnecessary else condition which is out of format anyway.

Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-print.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)
nvme-print.c +3 -4
index c038355..d9512c8 100644
@@ -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
#2 lore raw

PATCH 2/6 nvme-cli: code cleanup adjust if statement

In reply to Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-ioctl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-ioctl.c +1 -1
index 242a01f..f3a56dc 100644
@@ -563,7 +563,7 @@ static int nvme_property(int fd, __u8 fctype, __le32 off, __le64 *value, __u8 at
 
 	if (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
#3 lore raw

PATCH 3/6 nvme-cli: remove trailing space

In reply to Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
nvme-print.c +1 -1
index d9512c8..ae22a5b 100644
@@ -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
#4 lore raw

PATCH 4/6 nvme-cli: use uniform if .. else format

In reply to Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
nvme.c +2 -4
index 220fb18..971a926 100644
@@ -212,8 +212,7 @@ static int get_smart_log(int argc, char **argv, struct command *cmd, struct plug
 			json_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
#5 lore raw

PATCH 5/6 nvme-cli: use uniform if .. else format

In reply to Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-models.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
nvme-models.c +1 -2
index 5006f7a..f90ab95 100644
@@ -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
#6 lore raw

PATCH 6/6 nvme-cli: use uniform if .. else format

In reply to Chaitanya Kulkarni
Signed-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-lightnvm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
nvme-lightnvm.c +1 -2
index 37bd24b..ee21d6b 100644
@@ -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