]> www.infradead.org Git - users/sagi/libnvme.git/commitdiff
tree: Explicitly initialize auto-cleanup variables
authorTomas Bzatek <tbzatek@redhat.com>
Fri, 29 Dec 2023 17:49:36 +0000 (18:49 +0100)
committerDaniel Wagner <wagi@monom.org>
Thu, 18 Jan 2024 10:35:14 +0000 (11:35 +0100)
gcc complains about potentially uninitialized variables.

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
src/nvme/tree.c

index 07a3c532f37cc45b051c492aa850aca70cbebe87..97bd3ef4e851483eb11cef2fb33d9ee45cb4d329 100644 (file)
@@ -122,7 +122,8 @@ static void cleanup_dirents(struct dirents *ents)
 nvme_host_t nvme_default_host(nvme_root_t r)
 {
        struct nvme_host *h;
-       _cleanup_free_ char *hostnqn, *hostid;
+       _cleanup_free_ char *hostnqn = NULL;
+       _cleanup_free_ char *hostid = NULL;
 
        hostnqn = nvmf_hostnqn_from_file();
        if (!hostnqn)
@@ -1853,7 +1854,7 @@ static nvme_ctrl_t nvme_ctrl_alloc(nvme_root_t r, nvme_subsystem_t s,
        nvme_ctrl_t c, p;
        _cleanup_free_ char *addr = NULL, *address = NULL;
        char *a, *e;
-       _cleanup_free_ char *transport;
+       _cleanup_free_ char *transport = NULL;
        char *traddr = NULL, *trsvcid = NULL;
        char *host_traddr = NULL, *host_iface = NULL;
        int ret;