Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Ulrich Weigand" <uweigand@de.ibm.com>
To: bauerman@br.ibm.com (Thiago Jung Bauermann)
Cc: brobecker@adacore.com (Joel Brobecker),
	       gdb-patches@sourceware.org (gdb-patches ml)
Subject: [commit] Fix uninitialized warning (Re: [RFA] Refactor breakpoint_re_set_one)
Date: Thu, 31 Mar 2011 14:37:00 -0000	[thread overview]
Message-ID: <201103311123.p2VBNFKn020306@d06av02.portsmouth.uk.ibm.com> (raw)
In-Reply-To: <1301347008.2433.11.camel@hactar> from "Thiago Jung Bauermann" at Mar 28, 2011 06:16:48 PM

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.

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


  parent reply	other threads:[~2011-03-31 11:23 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-28 15:18 [RFA] Refactor breakpoint_re_set_one Thiago Jung Bauermann
2011-03-28 20:08 ` Joel Brobecker
2011-03-28 20:24   ` Pedro Alves
2011-03-29  1:40   ` Thiago Jung Bauermann
2011-03-29  1:55     ` Joel Brobecker
2011-03-29 12:36       ` Ulrich Weigand
2011-03-31 14:46         ` Thiago Jung Bauermann
2011-03-31 14:37     ` Ulrich Weigand [this message]
2011-03-31 15:03       ` [commit] Fix uninitialized warning (Re: [RFA] Refactor breakpoint_re_set_one) Thiago Jung Bauermann

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201103311123.p2VBNFKn020306@d06av02.portsmouth.uk.ibm.com \
    --to=uweigand@de.ibm.com \
    --cc=bauerman@br.ibm.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox