summaryrefslogtreecommitdiffstats
path: root/plugins/solidigm/solidigm-smart.c
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/solidigm/solidigm-smart.c')
-rw-r--r--plugins/solidigm/solidigm-smart.c27
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;
}