]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
tree: Change nvme_dev from global to static
authorJeremy Kerr <jk@codeconstruct.com.au>
Tue, 12 Jul 2022 09:20:25 +0000 (17:20 +0800)
committerDaniel Wagner <dwagner@suse.de>
Fri, 12 Aug 2022 06:51:06 +0000 (08:51 +0200)
We're currently exposing the global struct nvme_dev, to allow the old
users access to the name and statbuf data. Now that users have their
local reference (along with the fd) through parse_and_open instead, we
can drop the public definition, and declare it static to nvme.c.

We still keep the static declaration; this will be removed in an
upcoming change.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
nvme.c
nvme.h
plugins/innogrit/innogrit-nvme.c
plugins/intel/intel-nvme.c
plugins/memblaze/memblaze-nvme.c
plugins/scaleflux/sfx-nvme.c
plugins/seagate/seagate-nvme.c
plugins/shannon/shannon-nvme.c
plugins/solidigm/solidigm-garbage-collection.c
plugins/solidigm/solidigm-smart.c
plugins/wdc/wdc-nvme.c

diff --git a/nvme.c b/nvme.c
index 86d624de13fd1c0bbeaa0b8057b826b1011a4727..3c11aea8c205a99b0cd58a0c55b1ce9b41e98359 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -79,8 +79,8 @@ struct feat_cfg {
        bool  human_readable;
 };
 
-struct nvme_dev _nvme_dev;
-struct nvme_dev *nvme_dev = &_nvme_dev;
+static struct nvme_dev _nvme_dev;
+static struct nvme_dev *nvme_dev = &_nvme_dev;
 
 static const char nvme_version_string[] = NVME_VERSION;
 
diff --git a/nvme.h b/nvme.h
index c149ed352931dd05269383f76d128f9021142437..25b9c2a76e0660754033d63bda38bc44ce7cd9e3 100644 (file)
--- a/nvme.h
+++ b/nvme.h
@@ -53,7 +53,6 @@ int parse_and_open(struct nvme_dev **dev, int argc, char **argv, const char *des
 
 void dev_close(struct nvme_dev *dev);
 
-extern struct nvme_dev *nvme_dev;
 extern const char *output_format;
 
 enum nvme_print_flags validate_output_format(const char *format);
index 2e720a923c2fe3ef1b2f81ca8b398e39f75267ed..3769a260b896f120ac2ddc1d84418f8827cc6159 100644 (file)
@@ -44,8 +44,7 @@ static int innogrit_smart_log_additional(int argc, char **argv,
                return err;
 
        nvme_get_log_smart(dev->fd, cfg.namespace_id, false, &smart_log);
-       nvme_show_smart_log(&smart_log, cfg.namespace_id,
-                           nvme_dev->name, NORMAL);
+       nvme_show_smart_log(&smart_log, cfg.namespace_id, dev->name, NORMAL);
 
        printf("DW0[0-1]  Defect Cnt                    : %u\n", pvsc_smart->defect_cnt);
        printf("DW0[2-3]  Slc Spb Cnt                   : %u\n", pvsc_smart->slc_spb_cnt);
index 6bde99999ed403e48fad949b411d53ac63842ef3..3425a22c9be97fd1004d15f3a9c8502f979fd226 100644 (file)
@@ -372,10 +372,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
        if (!err) {
                if (cfg.json)
                        show_intel_smart_log_jsn(&smart_log, cfg.namespace_id,
-                                                nvme_dev->name);
+                                                dev->name);
                else if (!cfg.raw_binary)
                        show_intel_smart_log(&smart_log, cfg.namespace_id,
-                                            nvme_dev->name);
+                                            dev->name);
                else
                        d_raw((unsigned char *)&smart_log, sizeof(smart_log));
        }
index 856a579091cdecbcd6b469b6374b0ba32af817b1..921ecb9beafc834abd34e33c3c68b53dd9b96a23 100644 (file)
@@ -483,8 +483,7 @@ static int mb_get_additional_smart_log(int argc, char **argv, struct command *cm
        if (!err) {
                if (!cfg.raw_binary)
                        err = show_memblaze_smart_log(dev->fd, cfg.namespace_id,
-                                                     nvme_dev->name,
-                                                     &smart_log);
+                                                     dev->name, &smart_log);
                else
                        d_raw((unsigned char *)&smart_log, sizeof(smart_log));
        }
index e42c28fa20d2a4f22fde60e2c246346cf886d2c2..44f4feafed6bf873de36f4ce75ef457fbe2f327b 100644 (file)
@@ -432,10 +432,10 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
        if (!err) {
                if (cfg.json)
                        show_sfx_smart_log_jsn(&smart_log, cfg.namespace_id,
-                                              nvme_dev->name);
+                                              dev->name);
                else if (!cfg.raw_binary)
                        show_sfx_smart_log(&smart_log, cfg.namespace_id,
-                                          nvme_dev->name);
+                                          dev->name);
                else
                        d_raw((unsigned char *)&smart_log, sizeof(smart_log));
        }
index 63ff5261e381287bd01be5293acdb6dbc65724dc..179a7e6ec2e1f000796a8fde7ca8b2e8126212bd 100644 (file)
@@ -1128,7 +1128,7 @@ static int get_host_tele(int argc, char **argv, struct command *cmd, struct plug
 
                if (!cfg.raw_binary) {
                        printf("Device:%s log-id:%d namespace-id:%#x\n",
-                              nvme_dev->name, cfg.log_id,
+                              dev->name, cfg.log_id,
                               cfg.namespace_id);
                        printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n",
                               tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3);
@@ -1249,7 +1249,7 @@ static int get_ctrl_tele(int argc, char **argv, struct command *cmd, struct plug
 
                if (!cfg.raw_binary) {
                        printf("Device:%s namespace-id:%#x\n",
-                              nvme_dev->name, cfg.namespace_id);
+                              dev->name, cfg.namespace_id);
                        printf("Data Block 1 Last Block:%d Data Block 2 Last Block:%d Data Block 3 Last Block:%d\n",
                               tele_log.tele_data_area1, tele_log.tele_data_area2, tele_log.tele_data_area3);
 
index 7b02b452c20fed89b484fdb1050f3c5c39c202b4..c1c5b5a9c9d3d93afb3379ae803c05b423569fdc 100644 (file)
@@ -146,7 +146,7 @@ static int get_additional_smart_log(int argc, char **argv, struct command *cmd,
        if (!err) {
                if (!cfg.raw_binary)
                        show_shannon_smart_log(&smart_log, cfg.namespace_id,
-                                              nvme_dev->name);
+                                              dev->name);
                else
                        d_raw((unsigned char *)&smart_log, sizeof(smart_log));
        }
index bd0041c62111cbb938fe9adae918f0d8c5daf9b3..9e40c88eaccf31c08239649d091c685e8587f161 100644 (file)
@@ -99,9 +99,9 @@ int solidigm_get_garbage_collection_log(int argc, char **argv, struct command *c
                if (flags & BINARY)     {
                        d_raw((unsigned char *)&gc_log, sizeof(gc_log));
                } else if (flags & JSON) {
-                       vu_gc_log_show_json(&gc_log, nvme_dev->name);
+                       vu_gc_log_show_json(&gc_log, dev->name);
                } else {
-                       vu_gc_log_show(&gc_log, nvme_dev->name);
+                       vu_gc_log_show(&gc_log, dev->name);
                }
        }
        else if (err > 0) {
index 7d885951a35fc398b42e6a9c8034a133f7ef1b14..5e01066e49c91861dbd2f9d32847baaab187a57a 100644 (file)
@@ -236,13 +236,12 @@ int solidigm_get_additional_smart_log(int argc, char **argv, struct command *cmd
        if (!err) {
                if (flags & JSON) {
                        vu_smart_log_show_json(&smart_log_payload,
-                                              cfg.namespace_id,
-                                              nvme_dev->name);
+                                              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,
-                                         nvme_dev->name);
+                                         dev->name);
                }
        } else if (err > 0) {
                nvme_show_status(err);
index b9fd6b6fd1ee8e47796b7222b6f0697be11e46b5..f1893051a37f3b8e8ca81d7bce6892e5c1470bd2 100644 (file)
@@ -10507,7 +10507,7 @@ static int wdc_vs_temperature_stats(int argc, char **argv,
        if (fmt == NORMAL) {
                /* print the temperature stats */
                printf("Temperature Stats for NVME device:%s namespace-id:%x\n",
-                                       nvme_dev->name, WDC_DE_GLOBAL_NSID);
+                                       dev->name, WDC_DE_GLOBAL_NSID);
 
                printf("Current Composite Temperature           : %d °C\n", temperature);
                printf("WCTEMP                                  : %"PRIu16" °C\n", id_ctrl.wctemp - 273);
@@ -10582,7 +10582,7 @@ static int wdc_capabilities(int argc, char **argv,
     capabilities = wdc_get_drive_capabilities(r, dev);
 
     /* print command and supported status */
-    printf("WDC Plugin Capabilities for NVME device:%s\n", nvme_dev->name);
+    printf("WDC Plugin Capabilities for NVME device:%s\n", dev->name);
     printf("cap-diag                      : %s\n", 
             capabilities & WDC_DRIVE_CAP_CAP_DIAG ? "Supported" : "Not Supported");
     printf("drive-log                     : %s\n",