nvme-cli: code cleanup, minor fixes
cover nvme-cli: code cleanup, minor fixes
This patch-series has minor fixes and code cleanups for nvme-cli.
Regards,
Chaitanya
Chaitanya Kulkarni (5):
nvme-cli: fix scaandir() return value
nvme-cli: remove always true condition for u8
nvme-cli: code cleanup for passthru() handlers
nvme-cli: don't use unsigned for fd in lnvm-nvme.c
nvme-cli: fix dead-code nvmf log page discovery
fabrics.c | 2 +- lnvm-nvme.c | 3 ++- nvme.c | 14 ++++++++------ 3 files changed, 11 insertions(+), 8 deletions(-)
Signature · 1 line
2.14.1
PATCH 1/5 nvme-cli: fix scaandir() return value
Don't use unsigned int for scandir() return value as it can return -1.
--- nvme.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
nvme.c +2 -2
@@ -1618,8 +1618,8 @@ static int list(int argc, char **argv, struct command *cmd, struct plugin *plugichar path[264 ];struct dirent **devices;struct list_item *list_items; -unsigned int i, n, list_cnt =0 ; -int fmt, ret, fd; +unsigned int list_cnt =0 ; +int fmt, ret, fd, i, n;const char *desc ="Retrieve basic information for the given device" ;struct config {char *output_format;
Signature · 1 line
2.14.1
PATCH 2/5 nvme-cli: remove always true condition for u8
In reply to Chaitanya KulkarniGet rid of the always true condition of (cfg.owpass >= 0) since cfg.owpass is defined as __u8.
--- nvme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
nvme.c +1 -1
@@ -2585,7 +2585,7 @@ static int sanitize(int argc, char **argv, struct command *cmd, struct plugin *p }if (cfg.sanact ==NVME_SANITIZE_ACT_OVERWRITE ) { -if (!(cfg.owpass >=0 && cfg.owpass <=16 )) { +if (cfg.owpass >16 ) {fprintf (stderr,"OWPASS out of range [0-16]\n" ); ret =EINVAL ; goto close_fd;
Signature · 1 line
2.14.1
PATCH 3/5 nvme-cli: code cleanup for passthru() handlers
In reply to Chaitanya KulkarniGet rid of the duplicate free of the metadata pointer in case memory allocation fails for the data pointer.
Close wfd file in case of any resource allocation failure if applicable.
--- nvme.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
nvme.c +5 -3
@@ -4451,13 +4451,11 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, struif (!metadata) {fprintf (stderr,"can not allocate metadata payload\n" ); err =ENOMEM ; - goto close_fd; + goto close_wfd; } }if (cfg.data_len) {if (posix_memalign (&data,getpagesize (), cfg.data_len)) { -if (metadata) -free (metadata);fprintf (stderr,"can not allocate data payload\n" ); err =ENOMEM ; goto free_metadata;
@@ -4524,6 +4522,10 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, stru free_metadata:if (cfg.metadata_len)free (metadata); + + close_wfd: +if (strlen (cfg.input_file)) +close (wfd); close_fd:close (fd);return err;
Signature · 1 line
2.14.1
PATCH 4/5 nvme-cli: don't use unsigned for fd in lnvm-nvme.c
In reply to Chaitanya KulkarniChange the data type of the fd from unsigned int -> int.
--- lnvm-nvme.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
lnvm-nvme.c +2 -1
@@ -95,7 +95,8 @@ static int lnvm_id_ns(int argc, char **argv, struct command *cmd, struct pluginconst char *raw_binary ="show infos in binary format" ;const char *human_readable ="show infos in readable format" ;const char *namespace_id ="identifier of desired namespace. default: 1" ; -unsigned int fd, flags =0 ; +unsigned int flags =0 ; +int fd;struct config {__u32 namespace_id;
Signature · 1 line
2.14.1
PATCH 5/5 nvme-cli: fix dead-code nvmf log page discovery
In reply to Chaitanya Kulkarni--- fabrics.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
fabrics.c +1 -1
@@ -353,9 +353,9 @@ static int nvmf_get_log_page_discovery(const char *dev_path,/* needs to be freed by the caller */ *logp = log; + error =DISC_OK ; goto out_close; - error =DISC_OK ; out_free_log:free (log); out_close:
Signature · 1 line
2.14.1
cover nvme-cli: code cleanup, minor fixes
In reply to Chaitanya KulkarniQuoted 1 line · Chaitanya Kulkarni
This patch-series has minor fixes and code cleanups for nvme-cli.
Thanks, all of your patches have been applied.