]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
plugins/nbft: Fix uninitialized variables
authorTomas Bzatek <tbzatek@redhat.com>
Tue, 19 Mar 2024 13:29:37 +0000 (14:29 +0100)
committerDaniel Wagner <wagi@monom.org>
Tue, 19 Mar 2024 16:40:26 +0000 (17:40 +0100)
../plugins/nbft/nbft-plugin.c:328:27: warning: variable 'entry' is uninitialized when used here [-Wuninitialized]
  328 |         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));                              \
      |                                     ^~~
../plugins/nbft/nbft-plugin.c:322:31: note: initialize the variable 'entry' to silence this warning
  322 |         struct nbft_file_entry *entry;
      |                                      ^
      |                                       = NULL

../plugins/nbft/nbft-plugin.c:515:27: warning: variable 'entry' is uninitialized when used here [-Wuninitialized]
  515 |         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));                              \
      |                                     ^~~
../plugins/nbft/nbft-plugin.c:513:31: note: initialize the variable 'entry' to silence this warning
  513 |         struct nbft_file_entry *entry;
      |                                      ^
      |                                       = NULL

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

index 2193ffb53522d249bb236811023e038260417443..720af930c1c0111a1bc50ee92e8dbabab6a6d7b3 100644 (file)
@@ -319,7 +319,7 @@ static int json_show_nbfts(struct list_head *nbft_list, bool show_subsys,
                           bool show_hfi, bool show_discovery)
 {
        struct json_object *nbft_json_array, *nbft_json;
-       struct nbft_file_entry *entry;
+       struct nbft_file_entry *entry = NULL;
 
        nbft_json_array = json_create_array();
        if (!nbft_json_array)
@@ -510,7 +510,7 @@ static void normal_show_nbfts(struct list_head *nbft_list, bool show_subsys,
                              bool show_hfi, bool show_discovery)
 {
        bool not_first = false;
-       struct nbft_file_entry *entry;
+       struct nbft_file_entry *entry = NULL;
 
        list_for_each(nbft_list, entry, node) {
                if (not_first)