Silence GCC "uninitialized" warning on minsyms.c:lookup_minimal_symbol_by_pc_section
Commit Message
Commit 20944a6e20324cd897bf6c4c5fd20ef7224dacaa ("Fix stepping past
GNU ifunc resolvers (introduce lookup_msym_prefer)") introduced a new
way to determine the 'want_type' variable on
minsyms.c:lookup_minimal_symbol_by_pc_section. Because the
'lookup_msym_prefer' has a default value, we know that 'want_type'
will always be initialized. However, GCC is complaining that the
variable can be used uninitialized in the function:
../../gdb/minsyms.c: In function 'bound_minimal_symbol lookup_minimal_symbol_by_pc_section(CORE_ADDR, obj_section*, lookup_msym_prefer)':
../../gdb/minsyms.c:825:40: warning: 'want_type' may be used uninitialized in this function [-Wmaybe-uninitialized]
&& MSYMBOL_TYPE (&msymbol[hi]) != want_type
(This is with gcc-8.1.1-1.fc29.x86_64).
This patch fixes it by initializing 'want_type' with 'mst_text', which
is the same default value that is passed in the 'lookup_msym_prefer'
variable.
Even though this can be considered an obvious patch, I'm sending it
for approval.
gdb/ChangeLog:
2018-06-18 Sergio Durigan Junior <sergiodj@redhat.com>
* minsyms.c (lookup_minimal_symbol_by_pc_section): Initialize
'want_type' to silence GCC warning.
---
gdb/ChangeLog | 5 +++++
gdb/minsyms.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
@@ -1,3 +1,8 @@
+2018-06-18 Sergio Durigan Junior <sergiodj@redhat.com>
+
+ * minsyms.c (lookup_minimal_symbol_by_pc_section): Initialize
+ 'want_type' to silence GCC warning.
+
2018-06-18 Tom Tromey <tom@tromey.com>
* solib-aix.c (solib_aix_get_section_offsets): Return
@@ -683,7 +683,7 @@ lookup_minimal_symbol_by_pc_section (CORE_ADDR pc_in, struct obj_section *sectio
struct minimal_symbol *best_symbol = NULL;
struct objfile *best_objfile = NULL;
struct bound_minimal_symbol result;
- enum minimal_symbol_type want_type;
+ enum minimal_symbol_type want_type = mst_text;
if (section == NULL)
{