Fix compile warning in symtab.c
authorChristian Biesinger <cbiesinger@google.com>
Fri, 9 Aug 2019 19:25:15 +0000 (14:25 -0500)
committerChristian Biesinger <cbiesinger@google.com>
Sat, 24 Aug 2019 21:45:59 +0000 (16:45 -0500)
commitd0509ba44323dc5550852f0dbdcb2ccc2818d5b3
tree9296b35eb056410f6c379afb2ff9a721d39a6200
parent6d5554a605a8ce908ba04b00fd960d02ca9fc613
Fix compile warning in symtab.c

My compiler (g++ 8.2) can't tell that *bsc_ptr and *slot_ptr are
only used in the cases when it does get initialized. Just initialize
the vars earlier to avoid the warning, there does not seem to be a
downside to it.

../../gdb/symtab.c: In function ‘block_symbol lookup_static_symbol(const char*, domain_enum)’:
../../gdb/symtab.c:1366:11: warning: ‘slot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     xfree (slot->value.not_found.name);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gdb/symtab.c:2578:29: note: ‘slot’ was declared here
   struct symbol_cache_slot *slot;
                             ^~~~
../../gdb/symtab.c:1405:3: warning: ‘bsc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (bsc == NULL)
   ^~
../../gdb/symtab.c:2577:30: note: ‘bsc’ was declared here
   struct block_symbol_cache *bsc;
                              ^~~
../../gdb/symtab.c: In function ‘block_symbol lookup_global_symbol(const char*, const block*, domain_enum)’:
../../gdb/symtab.c:1366:11: warning: ‘slot’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     xfree (slot->value.not_found.name);
     ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
../../gdb/symtab.c:2658:29: note: ‘slot’ was declared here
   struct symbol_cache_slot *slot;
                             ^~~~
../../gdb/symtab.c:1409:14: warning: ‘bsc’ may be used uninitialized in this function [-Wmaybe-uninitialized]
       ++bsc->collisions;
         ~~~~~^~~~~~~~~~
../../gdb/symtab.c:2657:30: note: ‘bsc’ was declared here
   struct block_symbol_cache *bsc;
                              ^~~

gdb/ChangeLog:

2019-08-22  Christian Biesinger  <cbiesinger@google.com>

* symtab.c (symbol_cache_lookup): Always initialize *bsc_ptr and *slot_ptr.
gdb/ChangeLog
gdb/symtab.c
This page took 0.025135 seconds and 4 git commands to generate.