]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nbft: Fix uninitialized variable
authorTomas Bzatek <tbzatek@redhat.com>
Tue, 19 Mar 2024 13:31:13 +0000 (14:31 +0100)
committerDaniel Wagner <wagi@monom.org>
Tue, 19 Mar 2024 16:40:26 +0000 (17:40 +0100)
../nbft.c:106:28: warning: variable 'entry' is uninitialized when used here [-Wuninitialized]
  106 |         list_for_each(&nbft_list, entry, node)
      |                                   ^~~~~
../ccan/ccan/list/list.h:524:40: note: expanded from macro 'list_for_each'
  524 |         list_for_each_off(h, i, list_off_var_(i, member))
      |                                               ^
../ccan/ccan/list/list.h:824:21: note: expanded from macro 'list_off_var_'
  824 |         (container_off_var(var, member) +               \
      |                            ^~~
../ccan/ccan/container_of/container_of.h:142:19: note: expanded from macro 'container_off_var'
  142 |         ((const char *)&(var)->member - (const char *)(var))
      |                          ^~~
../ccan/ccan/list/list.h:738:34: note: expanded from macro 'list_for_each_off'
  738 |         list_for_each_off_dir_((h),(i),(off),next)
      |                                         ^~~
../ccan/ccan/list/list.h:693:9: note: expanded from macro 'list_for_each_off_dir_'
  693 |                                    (off));                              \
      |                                     ^~~
../nbft.c:90:31: note: initialize the variable 'entry' to silence this warning
   90 |         struct nbft_file_entry *entry;
      |                                      ^
      |                                       = NULL

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
nbft.c

diff --git a/nbft.c b/nbft.c
index ff36119d2217498017caf5af0e2e890df30588bf..eb2c3ac6f415029a3dfcb370758b20a5aee81b27 100644 (file)
--- a/nbft.c
+++ b/nbft.c
@@ -87,7 +87,7 @@ int discover_from_nbft(nvme_root_t r, char *hostnqn_arg, char *hostid_arg,
        nvme_ctrl_t c;
        int ret, i;
        struct list_head nbft_list;
-       struct nbft_file_entry *entry;
+       struct nbft_file_entry *entry = NULL;
        struct nbft_info_subsystem_ns **ss;
        struct nbft_info_hfi *hfi;