gdb/linespec.c: Fix -Wmaybe-uninitialized warning
authorAaron Merey <amerey@redhat.com>
Sat, 7 Jan 2023 00:06:15 +0000 (19:06 -0500)
committerAaron Merey <amerey@redhat.com>
Tue, 10 Jan 2023 00:47:00 +0000 (19:47 -0500)
Although the bool want_start_sal isn't actually used without being assigned
a value, initialize it to be false in order to prevent the following
-Wmaybe-uninitialized warning:

    linespec.c: In function ‘void minsym_found(linespec_state*, objfile*, minimal_symbol*, std::vector<symtab_and_line>*)’:
    linespec.c:4150:19: warning: ‘want_start_sal’ may be used uninitialized [-Wmaybe-uninitialized]
     4150 |   if (is_function && want_start_sal)

gdb/linespec.c

index e9339c3338c09363e9e155df99b5a00e4e22de56..b8c77541a290616df906649da97406e3f3691131 100644 (file)
@@ -4129,7 +4129,7 @@ minsym_found (struct linespec_state *self, struct objfile *objfile,
              struct minimal_symbol *msymbol,
              std::vector<symtab_and_line> *result)
 {
-  bool want_start_sal;
+  bool want_start_sal = false;
 
   CORE_ADDR func_addr;
   bool is_function = msymbol_is_function (objfile, msymbol, &func_addr);