diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:30 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:30 +0000 |
commit | 4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7 (patch) | |
tree | 866986558761a9709a7af1940ba607128a45f775 /plugins/solidigm/solidigm-smart.c | |
parent | Releasing debian version 2.1.2-2. (diff) | |
download | nvme-cli-4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7.tar.xz nvme-cli-4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7.zip |
Merging upstream version 2.2.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/solidigm/solidigm-smart.c')
-rw-r--r-- | plugins/solidigm/solidigm-smart.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/plugins/solidigm/solidigm-smart.c b/plugins/solidigm/solidigm-smart.c index 77a2210..77c26ac 100644 --- a/plugins/solidigm/solidigm-smart.c +++ b/plugins/solidigm/solidigm-smart.c @@ -10,8 +10,6 @@ #include <stdio.h> #include <stdlib.h> #include <unistd.h> -#include <inttypes.h> -#include <endian.h> #include "common.h" #include "nvme.h" @@ -201,7 +199,8 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd const int solidigm_vu_smart_log_id = 0xCA; vu_smart_log_t smart_log_payload; enum nvme_print_flags flags; - int fd, err; + struct nvme_dev *dev; + int err; struct config { __u32 namespace_id; @@ -219,32 +218,36 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd OPT_END() }; - fd = parse_and_open(argc, argv, desc, opts); - if (fd < 0) { - return fd; - } + err = parse_and_open(&dev, argc, argv, desc, opts); + if (err) + return err; flags = validate_output_format(cfg.output_format); if (flags == -EINVAL) { fprintf(stderr, "Invalid output format '%s'\n", cfg.output_format); - close(fd); + dev_close(dev); return flags; } - err = nvme_get_log_simple(fd, solidigm_vu_smart_log_id, sizeof(smart_log_payload), &smart_log_payload); + err = nvme_get_log_simple(dev_fd(dev), solidigm_vu_smart_log_id, + sizeof(smart_log_payload), &smart_log_payload); if (!err) { if (flags & JSON) { - vu_smart_log_show_json(&smart_log_payload, cfg.namespace_id, devicename); + vu_smart_log_show_json(&smart_log_payload, + cfg.namespace_id, dev->name); } else if (flags & BINARY) { d_raw((unsigned char *)&smart_log_payload, sizeof(smart_log_payload)); } else { - vu_smart_log_show(&smart_log_payload, cfg.namespace_id, devicename); + vu_smart_log_show(&smart_log_payload, cfg.namespace_id, + dev->name); } } else if (err > 0) { nvme_show_status(err); } - close(fd); + /* Redundant close() to make static code analysis happy */ + close(dev->direct.fd); + dev_close(dev); return err; } |