]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: use name as argument to nvme_ctrl_lookup_subsystem_name()
authorHannes Reinecke <hare@suse.de>
Tue, 28 Sep 2021 09:55:07 +0000 (11:55 +0200)
committerDaniel Wagner <dwagner@suse.de>
Tue, 11 Jan 2022 15:31:16 +0000 (16:31 +0100)
When looking up the subsystem in ctrl_lookup_subsystem_name() we
only need the controller name, not the entire controller structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
src/nvme/tree.c

index a782f04a2e92df048a0c5aed659c06b92dd2b2e5..396f521a87f3fd2342362b677f0c883b7688600f 100644 (file)
@@ -1075,7 +1075,7 @@ static int nvme_ctrl_scan_namespaces(struct nvme_ctrl *c)
        return 0;
 }
 
-static char *nvme_ctrl_lookup_subsystem_name(nvme_ctrl_t c)
+static char *nvme_ctrl_lookup_subsystem_name(char *ctrl_name)
 {
        struct dirent **subsys;
        char *subsys_name = NULL;
@@ -1089,7 +1089,7 @@ static char *nvme_ctrl_lookup_subsystem_name(nvme_ctrl_t c)
                struct stat st;
 
                sprintf(path, "%s/%s/%s", nvme_subsys_sysfs_dir,
-                       subsys[i]->d_name, c->name);
+                       subsys[i]->d_name, ctrl_name);
                nvme_msg(LOG_DEBUG, "lookup subsystem %s\n", path);
                if (stat(path, &st) < 0)
                        continue;
@@ -1162,7 +1162,7 @@ int nvme_init_ctrl(nvme_host_t h, nvme_ctrl_t c, int instance)
                }
        }
 
-       subsys_name = nvme_ctrl_lookup_subsystem_name(c);
+       subsys_name = nvme_ctrl_lookup_subsystem_name(name);
        if (!subsys_name) {
                nvme_msg(LOG_ERR, "Failed to lookup subsystem name for %s\n",
                         c->name);