]> www.infradead.org Git - users/sagi/nvme-cli.git/commitdiff
nvme-print-json: Fix uninitialized variable
authorTomas Bzatek <tbzatek@redhat.com>
Tue, 19 Mar 2024 13:25:17 +0000 (14:25 +0100)
committerDaniel Wagner <wagi@monom.org>
Tue, 19 Mar 2024 16:40:26 +0000 (17:40 +0100)
../nvme-print-json.c:1340:22: warning: variable 'node' is uninitialized when used here [-Wuninitialized]
 1340 |         list_for_each(list, node, 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));                              \
      |                                     ^~~
../nvme-print-json.c:1338:31: note: initialize the variable 'node' to silence this warning
 1338 |         nvme_effects_log_node_t *node;
      |                                      ^
      |                                       = NULL

Signed-off-by: Tomas Bzatek <tbzatek@redhat.com>
nvme-print-json.c

index 5ce50e02df2c200fe766e0f8e6a48baa21a46e57..3e47cd506da2580ba555841b6f5337e62105d0ef 100644 (file)
@@ -1335,7 +1335,7 @@ struct json_object* json_effects_log(enum nvme_csi csi,
 static void json_effects_log_list(struct list_head *list)
 {
        struct json_object *r = json_create_array();
-       nvme_effects_log_node_t *node;
+       nvme_effects_log_node_t *node = NULL;
 
        list_for_each(list, node, node) {
                struct json_object *json_page =