nvme-cli: cleanup patches
cover nvme-cli: cleanup patches
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(-)
Signature · 1 line
2.17.0
PATCH 1/4 nvme-cli: use uniform error message for open
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(-)
fabrics.c +8 -1
@@ -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;
nvme.c +25 -10
@@ -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 *plugisnprintf (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 pluginif (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 *pif (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; }
Signature · 1 line
2.17.0
PATCH 2/4 nvme-cli: fix indentation
In reply to Chaitanya KulkarniSigned-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
@@ -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" ); }
Signature · 1 line
2.17.0
PATCH 3/4 nvme-cli: make wdc plug-in functions static
In reply to Chaitanya KulkarniSigned-off-by Chaitanya Kulkarni <chaitanya.kulkarni at wdc.com>
--- wdc-nvme.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
wdc-nvme.c +8 -8
@@ -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 offsetInDwreturn 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 freturn 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 ;
Signature · 1 line
2.17.0
PATCH 4/4 nvme-cli: mark functions static
In reply to Chaitanya KulkarniMark 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(-)
nvme-ioctl.c +1 -1
@@ -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 = {
nvme.c +1 -1
@@ -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 ];
Signature · 1 line
2.17.0
cover nvme-cli: cleanup patches
In reply to Chaitanya KulkarniQuoted 3 lines · Chaitanya Kulkarni
Hi,
This patch series contains another round of nvme-cli cleanups.
Thanks, all applied.