This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [commit] Fix uninitialized warning (Re: [RFA] Refactor breakpoint_re_set_one)


On Thu, 2011-03-31 at 13:23 +0200, Ulrich Weigand wrote:
> 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 = &not_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.

I just compiled with -O3 and I was able to reproduce the problem here.
I've been compiling without any optimization. Sorry for the trouble, and
thanks for fixing it.

BTW, I'm also seeing a warning in macroexp.c when compiling with -O3.
I'll commit a patch to fix that shortly if someone doesn't beat me to
it.
-- 
[]'s
Thiago Jung Bauermann
IBM Linux Technology Center


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]