This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[ob] Fix -Wuninitialized failures with GCC 4.3
- From: Daniel Jacobowitz <drow at false dot org>
- To: gdb-patches at sourceware dot org
- Date: Mon, 31 Dec 2007 13:41:41 -0500
- Subject: [ob] Fix -Wuninitialized failures with GCC 4.3
This patch lets GDB build with GCC 4.3. Both warnings are caused by
functions which take a pointer and initialize the target only
conditionally. In remote.c this would lead to accepting bad packets,
so the correct fix was to call error instead; GCC can then see that
the variable is always initialized if the function returns. In
symtab.c it was ultimately harmless, but always initializing
*exact_match even if we return -1 is IMO reasonable.
Tested on x86_64-linux with GCC 4.2 and HEAD, and checked in. Thanks
to Martin Michlmayr for test-building all of Debian with GCC HEAD.
--
Daniel Jacobowitz
CodeSourcery
2007-12-31 Daniel Jacobowitz <dan@codesourcery.com>
* remote.c (unpack_nibble): Use fromhex.
* symtab.c (find_line_common): Always set exact_match.
---
gdb/remote.c | 2 +-
gdb/symtab.c | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
Index: gdb-6.7.1/gdb/remote.c
===================================================================
--- gdb-6.7.1.orig/gdb/remote.c 2007-12-31 13:23:10.000000000 -0500
+++ gdb-6.7.1/gdb/remote.c 2007-12-31 13:27:07.000000000 -0500
@@ -1343,7 +1343,7 @@ unpack_varlen_hex (char *buff, /* packet
static char *
unpack_nibble (char *buf, int *val)
{
- ishex (*buf++, val);
+ *val = fromhex (*buf++);
return buf;
}
Index: gdb-6.7.1/gdb/symtab.c
===================================================================
--- gdb-6.7.1.orig/gdb/symtab.c 2007-12-31 13:23:10.000000000 -0500
+++ gdb-6.7.1/gdb/symtab.c 2007-12-31 13:29:57.000000000 -0500
@@ -2408,6 +2408,8 @@ find_line_common (struct linetable *l, i
int best_index = -1;
int best = 0;
+ *exact_match = 0;
+
if (lineno <= 0)
return -1;
if (l == 0)
@@ -2433,8 +2435,6 @@ find_line_common (struct linetable *l, i
}
/* If we got here, we didn't get an exact match. */
-
- *exact_match = 0;
return best_index;
}