This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Fix uninitialized warning (Re: [RFA] Refactor breakpoint_re_set_one)
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: bauerman at br dot ibm dot com (Thiago Jung Bauermann)
- Cc: brobecker at adacore dot com (Joel Brobecker), gdb-patches at sourceware dot org (gdb-patches ml)
- Date: Thu, 31 Mar 2011 13:23:15 +0200 (CEST)
- Subject: [commit] Fix uninitialized warning (Re: [RFA] Refactor breakpoint_re_set_one)
Thiago Jung Bauermann wrote:
> 2011-03-28 Thiago Jung Bauermann <bauerman@br.ibm.com>
>
> * breakpoint.c (breakpoint_re_set_one): Factor out breakpoint-resetting
> code from here ...
> (re_set_breakpoint): ... to here ...
> (addr_string_to_sals): ... and here.
+static struct symtabs_and_lines
+addr_string_to_sals (struct breakpoint *b, char *addr_string, int *found)
+{
+ char *s;
+ int marker_spec, not_found;
+ struct symtabs_and_lines sals;
+ struct gdb_exception e;
This caused a compiler warning for me, aborting the build:
/home/uweigand/fsf/gdb-head/gdb/breakpoint.c: In function 'addr_string_to_sals':
/home/uweigand/fsf/gdb-head/gdb/breakpoint.c:10587: warning: 'sals.nelts' may be used uninitialized in this function
/home/uweigand/fsf/gdb-head/gdb/breakpoint.c:10587: warning: 'sals.sals' may be used uninitialized in this function
At the place where you removed the variable definition, we used to have
a dummy initializer, presumably to avoid just such warnings:
@@ -10493,14 +10603,6 @@ breakpoint_re_set_one (void *bint)
{
/* Get past catch_errs. */
struct breakpoint *b = (struct breakpoint *) bint;
- int not_found = 0;
- int *not_found_ptr = ¬_found;
- struct symtabs_and_lines sals = {0};
The patch below adds the initializer back, fixing the build for me.
Tested on amd64-linux, committed to mainline.
Bye,
Ulrich
ChangeLog:
* breakpoint.c (addr_string_to_sals): Avoid uninitialized
variable compiler warning.
Index: gdb/breakpoint.c
===================================================================
RCS file: /cvs/src/src/gdb/breakpoint.c,v
retrieving revision 1.558
diff -u -p -r1.558 breakpoint.c
--- gdb/breakpoint.c 30 Mar 2011 20:59:08 -0000 1.558
+++ gdb/breakpoint.c 31 Mar 2011 10:28:52 -0000
@@ -10584,7 +10584,7 @@ addr_string_to_sals (struct breakpoint *
{
char *s;
int marker_spec, not_found;
- struct symtabs_and_lines sals;
+ struct symtabs_and_lines sals = {0};
struct gdb_exception e;
s = addr_string;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com