From 4ed089396bc7f14bcb94e80f0f9f4757fd8c48b7 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 5 Nov 2022 19:23:30 +0100 Subject: Merging upstream version 2.2.1. Signed-off-by: Daniel Baumann --- plugins/solidigm/solidigm-smart.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'plugins/solidigm/solidigm-smart.c') 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 #include #include -#include -#include #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; } -- cgit v1.2.3