* [PUSHED/OBVIOUS] Fix 'obj' may be used uninitialized warning in symtab.c:matching_obj_sections.
@ 2019-01-12 7:04 Philippe Waroquiers
2019-01-12 16:27 ` Tom Tromey
0 siblings, 1 reply; 2+ messages in thread
From: Philippe Waroquiers @ 2019-01-12 7:04 UTC (permalink / raw)
To: gdb-patches; +Cc: Philippe Waroquiers
Fix warning:
gdb/symtab.c: In function âint matching_obj_sections(obj_section*, obj_section*)â:
gdb/symtab.c:1024:12: warning: âobjâ may be used uninitialized in this function [-Wmaybe-uninitialized]
if (obj->separate_debug_objfile_backlink != NULL
2019-01-12 Philippe Waroquiers <philippe.waroquiers@skynet.be>
* symtab.c (matching_obj_sections): Initialize obj,
declare it closer to its usage.
---
gdb/ChangeLog | 5 +++++
gdb/symtab.c | 2 +-
2 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 7fd2051cb0..e0b47b4bb0 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,8 @@
+2019-01-12 Philippe Waroquiers <philippe.waroquiers@skynet.be>
+
+ * symtab.c (matching_obj_sections): Initialize obj,
+ declare it closer to its usage.
+
2019-01-10 Tom Tromey <tom@tromey.com>
* thread-iter.h (inf_threads_iterator): Use next_iterator.
diff --git a/gdb/symtab.c b/gdb/symtab.c
index d5e18a64d0..29b24328fb 100644
--- a/gdb/symtab.c
+++ b/gdb/symtab.c
@@ -970,7 +970,6 @@ matching_obj_sections (struct obj_section *obj_first,
{
asection *first = obj_first? obj_first->the_bfd_section : NULL;
asection *second = obj_second? obj_second->the_bfd_section : NULL;
- struct objfile *obj;
/* If they're the same section, then they match. */
if (first == second)
@@ -1010,6 +1009,7 @@ matching_obj_sections (struct obj_section *obj_first,
/* Otherwise check that they are in corresponding objfiles. */
+ struct objfile *obj = NULL;
for (objfile *objfile : all_objfiles (current_program_space))
if (objfile->obfd == first->owner)
{
--
2.20.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PUSHED/OBVIOUS] Fix 'obj' may be used uninitialized warning in symtab.c:matching_obj_sections.
2019-01-12 7:04 [PUSHED/OBVIOUS] Fix 'obj' may be used uninitialized warning in symtab.c:matching_obj_sections Philippe Waroquiers
@ 2019-01-12 16:27 ` Tom Tromey
0 siblings, 0 replies; 2+ messages in thread
From: Tom Tromey @ 2019-01-12 16:27 UTC (permalink / raw)
To: Philippe Waroquiers; +Cc: gdb-patches
>>>>> "Philippe" == Philippe Waroquiers <philippe.waroquiers@skynet.be> writes:
Philippe> Fix warning:
Philippe> gdb/symtab.c: In function ‘int matching_obj_sections(obj_section*, obj_section*)’:
Philippe> gdb/symtab.c:1024:12: warning: ‘obj’ may be used uninitialized in this function [-Wmaybe-uninitialized]
Philippe> if (obj->separate_debug_objfile_backlink != NULL
Philippe> 2019-01-12 Philippe Waroquiers <philippe.waroquiers@skynet.be>
Philippe> * symtab.c (matching_obj_sections): Initialize obj,
Philippe> declare it closer to its usage.
Thanks, this is ok.
Tom
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-01-12 16:27 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-12 7:04 [PUSHED/OBVIOUS] Fix 'obj' may be used uninitialized warning in symtab.c:matching_obj_sections Philippe Waroquiers
2019-01-12 16:27 ` Tom Tromey
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).