linux-nvme.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] nvme-cli: cleanup patches
@ 2018-08-27 22:31 Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 1/4] nvme-cli: use uniform error message for open Chaitanya Kulkarni
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2018-08-27 22:31 UTC (permalink / raw)


Hi,

This patch series contains another round of nvme-cli cleanups.

Regards,
Chaitanya

Chaitanya Kulkarni (4):
  nvme-cli: use uniform error message for open
  nvme-cli: fix indentation
  nvme-cli: make wdc plug-in functions static
  nvme-cli: mark functions static

 fabrics.c    |  9 ++++++++-
 nvme-ioctl.c |  2 +-
 nvme-print.c |  2 +-
 nvme.c       | 37 ++++++++++++++++++++++++++-----------
 wdc-nvme.c   | 16 ++++++++--------
 5 files changed, 44 insertions(+), 22 deletions(-)

-- 
2.17.0

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/4] nvme-cli: use uniform error message for open
  2018-08-27 22:31 [PATCH 0/4] nvme-cli: cleanup patches Chaitanya Kulkarni
@ 2018-08-27 22:31 ` Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 2/4] nvme-cli: fix indentation Chaitanya Kulkarni
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2018-08-27 22:31 UTC (permalink / raw)


This patch adds errno based error message after open() system call
when open() system call fails.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 fabrics.c |  9 ++++++++-
 nvme.c    | 35 +++++++++++++++++++++++++----------
 2 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/fabrics.c b/fabrics.c
index 514082e..af4d746 100644
--- a/fabrics.c
+++ b/fabrics.c
@@ -235,6 +235,8 @@ static int remove_ctrl_by_path(char *sysfs_path)
 	fd = open(sysfs_path, O_WRONLY);
 	if (fd < 0) {
 		ret = errno;
+		fprintf(stderr, "Failed to open %s: %s\n", sysfs_path,
+				strerror(errno));
 		goto out;
 	}
 
@@ -286,6 +288,8 @@ static int nvmf_get_log_page_discovery(const char *dev_path,
 	fd = open(dev_path, O_RDWR);
 	if (fd < 0) {
 		error = -errno;
+		fprintf(stderr, "Failed to open %s: %s\n",
+				dev_path, strerror(errno));
 		goto out;
 	}
 
@@ -921,8 +925,11 @@ static int disconnect_subsys(char *nqn, char *ctrl)
 		goto free;
 
 	fd = open(sysfs_nqn_path, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		fprintf(stderr, "Failed to open %s: %s\n",
+				sysfs_nqn_path, strerror(errno));
 		goto free;
+	}
 
 	if (read(fd, subsysnqn, NVMF_NQN_SIZE) < 0)
 		goto close;
diff --git a/nvme.c b/nvme.c
index f149bab..1981444 100644
--- a/nvme.c
+++ b/nvme.c
@@ -346,7 +346,8 @@ static int get_telemetry_log(int argc, char **argv, struct command *cmd, struct
 
 	output = open(cfg.file_name, O_WRONLY | O_CREAT | O_TRUNC, 0666);
 	if (output < 0) {
-		fprintf(stderr, "Failed to open output file!\n");
+		fprintf(stderr, "Failed to open output file %s: %s!\n",
+				cfg.file_name, strerror(errno));
 		err = output;
 		goto close_fd;
 	}
@@ -1225,7 +1226,8 @@ static void *get_registers(void)
 		fd = open(path, O_RDONLY);
 	}
 	if (fd < 0) {
-		fprintf(stderr, "%s did not find a pci resource\n", base);
+		fprintf(stderr, "%s did not find a pci resource, open failed %s\n",
+				base, strerror(errno));
 		return NULL;
 	}
 
@@ -1251,8 +1253,11 @@ static char *get_nvme_subsnqn(char *path)
 	snprintf(sspath, sizeof(sspath), "%s/subsysnqn", path);
 
 	fd = open(sspath, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		fprintf(stderr, "Failed to open %s: %s\n",
+				sspath, strerror(errno));
 		return NULL;
+	}
 
 	subsysnqn = calloc(1, 256);
 	if (!subsysnqn)
@@ -1289,8 +1294,11 @@ static char *get_nvme_ctrl_transport(char *path)
 		goto err_free_trpath;
 
 	fd = open(trpath, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		fprintf(stderr, "Failed to open %s: %s\n",
+				trpath, strerror(errno));
 		goto err_free_tr;
+	}
 
 	ret = read(fd, transport, 1024);
 	if (ret < 0)
@@ -1331,8 +1339,11 @@ static char *get_nvme_ctrl_address(char *path)
 		goto err_free_addrpath;
 
 	fd = open(addrpath, O_RDONLY);
-	if (fd < 0)
+	if (fd < 0) {
+		fprintf(stderr, "Failed to open %s: %s\n",
+				addrpath, strerror(errno));
 		goto err_free_addr;
+	}
 
 	ret = read(fd, address, 1024);
 	if (ret < 0)
@@ -1659,7 +1670,7 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugi
 		snprintf(path, sizeof(path), "%s%s", dev, devices[i]->d_name);
 		fd = open(path, O_RDONLY);
 		if (fd < 0) {
-			fprintf(stderr, "can not open %s: %s\n", path,
+			fprintf(stderr, "Failed to open %s: %s\n", path,
 					strerror(errno));
 			return errno;
 		}
@@ -2293,7 +2304,8 @@ static int fw_download(int argc, char **argv, struct command *cmd, struct plugin
 	fw_fd = open(cfg.fw, O_RDONLY);
 	cfg.offset <<= 2;
 	if (fw_fd < 0) {
-		fprintf(stderr, "no firmware file provided\n");
+		fprintf(stderr, "Failed to open firmware file %s: %s\n",
+				cfg.fw, strerror(errno));
 		err = EINVAL;
 		goto close_fd;
 	}
@@ -2968,7 +2980,8 @@ static int set_feature(int argc, char **argv, struct command *cmd, struct plugin
 		if (strlen(cfg.file)) {
 			ffd = open(cfg.file, O_RDONLY);
 			if (ffd <= 0) {
-				fprintf(stderr, "no firmware file provided\n");
+				fprintf(stderr, "Failed to open file %s: %s\n",
+						cfg.file, strerror(errno));
 				err = EINVAL;
 				goto free;
 			}
@@ -3059,7 +3072,8 @@ static int sec_send(int argc, char **argv, struct command *cmd, struct plugin *p
 
 	sec_fd = open(cfg.file, O_RDONLY);
 	if (sec_fd < 0) {
-		fprintf(stderr, "no firmware file provided\n");
+		fprintf(stderr, "Failed to open %s: %s\n",
+				cfg.file, strerror(errno));
 		err = EINVAL;
 		goto close_fd;
 	}
@@ -3209,7 +3223,8 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p
                 if (strlen(cfg.file)) {
                         ffd = open(cfg.file, O_RDONLY);
                         if (ffd <= 0) {
-                                fprintf(stderr, "no firmware file provided\n");
+				fprintf(stderr, "Failed to open file %s: %s\n",
+						cfg.file, strerror(errno));
 				err = EINVAL;
 				goto free;
                         }
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] nvme-cli: fix indentation
  2018-08-27 22:31 [PATCH 0/4] nvme-cli: cleanup patches Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 1/4] nvme-cli: use uniform error message for open Chaitanya Kulkarni
@ 2018-08-27 22:31 ` Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 3/4] nvme-cli: make wdc plug-in functions static Chaitanya Kulkarni
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2018-08-27 22:31 UTC (permalink / raw)


Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-print.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nvme-print.c b/nvme-print.c
index 3589c19..17b5eaf 100644
--- a/nvme-print.c
+++ b/nvme-print.c
@@ -643,7 +643,7 @@ static void show_nvme_id_ns_fpi(__u8 fpi)
 	printf("  [7:7] : %#x\tFormat Progress Indicator %sSupported\n",
 		fpis, fpis ? "" : "Not ");
 	if (fpis || (!fpis && fpii))
-	printf("  [6:0] : %#x\tFormat Progress Indicator (Remaining %d%%)\n",
+		printf("  [6:0] : %#x\tFormat Progress Indicator (Remaining %d%%)\n",
 		fpii, fpii);
 	printf("\n");
 }
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] nvme-cli: make wdc plug-in functions static
  2018-08-27 22:31 [PATCH 0/4] nvme-cli: cleanup patches Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 1/4] nvme-cli: use uniform error message for open Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 2/4] nvme-cli: fix indentation Chaitanya Kulkarni
@ 2018-08-27 22:31 ` Chaitanya Kulkarni
  2018-08-27 22:31 ` [PATCH 4/4] nvme-cli: mark " Chaitanya Kulkarni
  2018-08-29 16:07 ` [PATCH 0/4] nvme-cli: cleanup patches Keith Busch
  4 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2018-08-27 22:31 UTC (permalink / raw)


Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 wdc-nvme.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/wdc-nvme.c b/wdc-nvme.c
index 4e691e7..5dd1d9d 100644
--- a/wdc-nvme.c
+++ b/wdc-nvme.c
@@ -274,7 +274,7 @@ typedef struct _WDC_NVME_DE_VU_LOGPAGES
     __u32 numOfVULogPages;
 } WDC_NVME_DE_VU_LOGPAGES, *PWDC_NVME_DE_VU_LOGPAGES;
 
-NVME_VU_DE_LOGPAGE_LIST deVULogPagesList[] =
+static NVME_VU_DE_LOGPAGE_LIST deVULogPagesList[] =
 {
     { NVME_DE_LOGPAGE_E3, 0xE3, 1072, "0xe3"},
     { NVME_DE_LOGPAGE_C0, 0xC0, 512, "0xc0"}
@@ -1580,7 +1580,7 @@ static int wdc_get_max_transfer_len(int fd, __u32 *maxTransferLen)
 	return ret;
 }
 
-int wdc_de_VU_read_size(int fd, __u32 fileId, __u16 spiDestn, __u32* logSize)
+static int wdc_de_VU_read_size(int fd, __u32 fileId, __u16 spiDestn, __u32* logSize)
 {
 	int ret = WDC_STATUS_FAILURE;
 	struct nvme_admin_cmd cmd;
@@ -1608,7 +1608,7 @@ int wdc_de_VU_read_size(int fd, __u32 fileId, __u16 spiDestn, __u32* logSize)
 	return ret;
 }
 
-int wdc_de_VU_read_buffer(int fd, __u32 fileId, __u16 spiDestn, __u32 offsetInDwords, __u8* dataBuffer, __u32* bufferSize)
+static int wdc_de_VU_read_buffer(int fd, __u32 fileId, __u16 spiDestn, __u32 offsetInDwords, __u8* dataBuffer, __u32* bufferSize)
 {
 	int ret = WDC_STATUS_FAILURE;
 	struct nvme_admin_cmd cmd;
@@ -1641,7 +1641,7 @@ int wdc_de_VU_read_buffer(int fd, __u32 fileId, __u16 spiDestn, __u32 offsetInDw
 	return ret;
 }
 
-int wdc_get_log_dir_max_entries(int fd, __u32* maxNumOfEntries)
+static int wdc_get_log_dir_max_entries(int fd, __u32* maxNumOfEntries)
 {
 	int     		ret = WDC_STATUS_FAILURE;
 	__u32           headerPayloadSize = 0;
@@ -1689,7 +1689,7 @@ int wdc_get_log_dir_max_entries(int fd, __u32* maxNumOfEntries)
 	return ret;
 }
 
-WDC_DRIVE_ESSENTIAL_TYPE wdc_get_essential_type(__u8 fileName[])
+static WDC_DRIVE_ESSENTIAL_TYPE wdc_get_essential_type(__u8 fileName[])
 {
 	WDC_DRIVE_ESSENTIAL_TYPE essentialType = WDC_DE_TYPE_NONE;
 
@@ -1709,7 +1709,7 @@ WDC_DRIVE_ESSENTIAL_TYPE wdc_get_essential_type(__u8 fileName[])
 	return essentialType;
 }
 
-int wdc_fetch_log_directory(int fd, PWDC_DE_VU_LOG_DIRECTORY directory)
+static int wdc_fetch_log_directory(int fd, PWDC_DE_VU_LOG_DIRECTORY directory)
 {
 	int             ret = WDC_STATUS_FAILURE;
 	__u8            *fileOffset = NULL;
@@ -1786,7 +1786,7 @@ int wdc_fetch_log_directory(int fd, PWDC_DE_VU_LOG_DIRECTORY directory)
 	return ret;
 }
 
-int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, __u64 fileSize, __u8* dataBuffer)
+static int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, __u64 fileSize, __u8* dataBuffer)
 {
 	int ret = WDC_STATUS_FAILURE;
 	__u32                     chunckSize = WDC_DE_VU_READ_BUFFER_STANDARD_OFFSET;
@@ -1839,7 +1839,7 @@ int wdc_fetch_log_file_from_device(int fd, __u32 fileId, __u16 spiDestn, __u64 f
 	return ret;
 }
 
-int wdc_de_get_dump_trace(int fd, char * filePath, __u16 binFileNameLen, char *binFileName)
+static int wdc_de_get_dump_trace(int fd, char * filePath, __u16 binFileNameLen, char *binFileName)
 {
 	int                     ret = WDC_STATUS_FAILURE;
 	__u8                    *readBuffer = NULL;
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] nvme-cli: mark functions static
  2018-08-27 22:31 [PATCH 0/4] nvme-cli: cleanup patches Chaitanya Kulkarni
                   ` (2 preceding siblings ...)
  2018-08-27 22:31 ` [PATCH 3/4] nvme-cli: make wdc plug-in functions static Chaitanya Kulkarni
@ 2018-08-27 22:31 ` Chaitanya Kulkarni
  2018-08-29 16:07 ` [PATCH 0/4] nvme-cli: cleanup patches Keith Busch
  4 siblings, 0 replies; 6+ messages in thread
From: Chaitanya Kulkarni @ 2018-08-27 22:31 UTC (permalink / raw)


Mark nvme_property() and get_nvme_subsystem_info() static.

Signed-off-by: Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
---
 nvme-ioctl.c | 2 +-
 nvme.c       | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/nvme-ioctl.c b/nvme-ioctl.c
index d63c863..f75728d 100644
--- a/nvme-ioctl.c
+++ b/nvme-ioctl.c
@@ -525,7 +525,7 @@ int nvme_set_feature(int fd, __u32 nsid, __u8 fid, __u32 value, __u32 cdw12,
 			    cdw12, data_len, data, result);
 }
 
-int nvme_property(int fd, __u8 fctype, __le32 off, __le64 *value, __u8 attrib)
+static int nvme_property(int fd, __u8 fctype, __le32 off, __le64 *value, __u8 attrib)
 {
 	int err;
 	struct nvme_admin_cmd cmd = {
diff --git a/nvme.c b/nvme.c
index 1981444..770e5a1 100644
--- a/nvme.c
+++ b/nvme.c
@@ -1394,7 +1394,7 @@ static void free_ctrl_list_item(struct ctrl_list_item *ctrls)
 	free(ctrls->address);
 }
 
-int get_nvme_subsystem_info(char *name, char *path,
+static int get_nvme_subsystem_info(char *name, char *path,
 				struct subsys_list_item *item)
 {
 	char ctrl_path[512];
-- 
2.17.0

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 0/4] nvme-cli: cleanup patches
  2018-08-27 22:31 [PATCH 0/4] nvme-cli: cleanup patches Chaitanya Kulkarni
                   ` (3 preceding siblings ...)
  2018-08-27 22:31 ` [PATCH 4/4] nvme-cli: mark " Chaitanya Kulkarni
@ 2018-08-29 16:07 ` Keith Busch
  4 siblings, 0 replies; 6+ messages in thread
From: Keith Busch @ 2018-08-29 16:07 UTC (permalink / raw)


On Mon, Aug 27, 2018@03:31:25PM -0700, Chaitanya Kulkarni wrote:
> Hi,
> 
> This patch series contains another round of nvme-cli cleanups.

Thanks, all applied.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-08-29 16:07 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-08-27 22:31 [PATCH 0/4] nvme-cli: cleanup patches Chaitanya Kulkarni
2018-08-27 22:31 ` [PATCH 1/4] nvme-cli: use uniform error message for open Chaitanya Kulkarni
2018-08-27 22:31 ` [PATCH 2/4] nvme-cli: fix indentation Chaitanya Kulkarni
2018-08-27 22:31 ` [PATCH 3/4] nvme-cli: make wdc plug-in functions static Chaitanya Kulkarni
2018-08-27 22:31 ` [PATCH 4/4] nvme-cli: mark " Chaitanya Kulkarni
2018-08-29 16:07 ` [PATCH 0/4] nvme-cli: cleanup patches Keith Busch

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).