This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] Fix unitialized warning on gdb/typeprint.c:whatis_exp
- From: Sergio Durigan Junior <sergiodj at redhat dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Eli Zaretskii <eliz at gnu dot org>, Sergio Durigan Junior <sergiodj at redhat dot com>
- Date: Tue, 16 Jan 2018 15:32:39 -0500
- Subject: [PATCH] Fix unitialized warning on gdb/typeprint.c:whatis_exp
- Authentication-results: sourceware.org; auth=none
- References: <87po69zkxe.fsf@redhat.com>
This simple patch initializes "struct value *val" to NULL, which
silences a when compiling GDB with certain GCC versions.
This warning is technically incorrect, because there is now way that
"val" will be used unitialized if you look at the code flow, but it's
a simple "fix" and doesn't do any harm.
Is it OK to push this to master and 8.1? I believe I will still need
to create a bug with the 8.1 milestone set, even for this simple
patch.
gdb/ChangeLog:
2017-01-16 Sergio Durigan Junior <sergiodj@redhat.com>
* typeprint.c (whatis_exp): Initialize "val" to NULL.
---
gdb/typeprint.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gdb/typeprint.c b/gdb/typeprint.c
index 9a125076a1..bf9aec5436 100644
--- a/gdb/typeprint.c
+++ b/gdb/typeprint.c
@@ -405,7 +405,7 @@ error_unknown_type (const char *sym_print_name)
static void
whatis_exp (const char *exp, int show)
{
- struct value *val;
+ struct value *val = NULL;
struct cleanup *old_chain;
struct type *real_type = NULL;
struct type *type;
--
2.14.3