diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:26 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2022-11-05 18:23:26 +0000 |
commit | fab3f41b7b3f080c215157a026ee6bc7efbfe968 (patch) | |
tree | f0fafb0805c3eb11eb2a278f9f8058376c8f0f2b /plugins/solidigm/solidigm-garbage-collection.c | |
parent | Adding upstream version 2.1.2. (diff) | |
download | nvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.tar.xz nvme-cli-fab3f41b7b3f080c215157a026ee6bc7efbfe968.zip |
Adding upstream version 2.2.1.upstream/2.2.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'plugins/solidigm/solidigm-garbage-collection.c')
-rw-r--r-- | plugins/solidigm/solidigm-garbage-collection.c | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/plugins/solidigm/solidigm-garbage-collection.c b/plugins/solidigm/solidigm-garbage-collection.c index 415722b..8e2eccc 100644 --- a/plugins/solidigm/solidigm-garbage-collection.c +++ b/plugins/solidigm/solidigm-garbage-collection.c @@ -56,13 +56,15 @@ static void vu_gc_log_show(garbage_control_collection_log_t *payload, const char for (int i = 0; i < VU_GC_MAX_ITEMS; i++) { gc_item_t item = payload->item[i]; - printf("%-13lu %d\n",le64_to_cpu(item.timestamp), le32_to_cpu(item.timer_type)); + printf("%-13" PRIu64 " %d\n", le64_to_cpu(item.timestamp), le32_to_cpu(item.timer_type)); } } int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *cmd, struct plugin *plugin) { const char *desc = "Get and parse Solidigm vendor specific garbage collection event log."; + struct nvme_dev *dev; + int err; struct config { char *output_format; @@ -77,35 +79,37 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *c OPT_END() }; - int 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; enum nvme_print_flags flags = validate_output_format(cfg.output_format); if (flags == -EINVAL) { fprintf(stderr, "Invalid output format '%s'\n", cfg.output_format); - close(fd); - return flags; + dev_close(dev); + return EINVAL; } garbage_control_collection_log_t gc_log; const int solidigm_vu_gc_log_id = 0xfd; - int err = nvme_get_log_simple(fd, solidigm_vu_gc_log_id, sizeof(gc_log), &gc_log); + err = nvme_get_log_simple(dev_fd(dev), solidigm_vu_gc_log_id, + sizeof(gc_log), &gc_log); if (!err) { if (flags & BINARY) { d_raw((unsigned char *)&gc_log, sizeof(gc_log)); } else if (flags & JSON) { - vu_gc_log_show_json(&gc_log, devicename); + vu_gc_log_show_json(&gc_log, dev->name); } else { - vu_gc_log_show(&gc_log, devicename); + vu_gc_log_show(&gc_log, 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; } |