From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21978 invoked by alias); 31 Mar 2011 11:23:33 -0000 Received: (qmail 21968 invoked by uid 22791); 31 Mar 2011 11:23:31 -0000 X-SWARE-Spam-Status: No, hits=-1.3 required=5.0 tests=AWL,BAYES_00,MSGID_FROM_MTA_HEADER,SPF_SOFTFAIL,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mtagate6.uk.ibm.com (HELO mtagate6.uk.ibm.com) (194.196.100.166) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Thu, 31 Mar 2011 11:23:27 +0000 Received: from d06nrmr1707.portsmouth.uk.ibm.com (d06nrmr1707.portsmouth.uk.ibm.com [9.149.39.225]) by mtagate6.uk.ibm.com (8.13.1/8.13.1) with ESMTP id p2VBNHhj031562 for ; Thu, 31 Mar 2011 11:23:17 GMT Received: from d06av02.portsmouth.uk.ibm.com (d06av02.portsmouth.uk.ibm.com [9.149.37.228]) by d06nrmr1707.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p2VBNr2g1462326 for ; Thu, 31 Mar 2011 12:23:53 +0100 Received: from d06av02.portsmouth.uk.ibm.com (loopback [127.0.0.1]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p2VBNGqJ020322 for ; Thu, 31 Mar 2011 05:23:17 -0600 Received: from tuxmaker.boeblingen.de.ibm.com (tuxmaker.boeblingen.de.ibm.com [9.152.85.9]) by d06av02.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with SMTP id p2VBNFKn020306; Thu, 31 Mar 2011 05:23:15 -0600 Message-Id: <201103311123.p2VBNFKn020306@d06av02.portsmouth.uk.ibm.com> Received: by tuxmaker.boeblingen.de.ibm.com (sSMTP sendmail emulation); Thu, 31 Mar 2011 13:23:15 +0200 Subject: [commit] Fix uninitialized warning (Re: [RFA] Refactor breakpoint_re_set_one) To: bauerman@br.ibm.com (Thiago Jung Bauermann) Date: Thu, 31 Mar 2011 14:37:00 -0000 From: "Ulrich Weigand" Cc: brobecker@adacore.com (Joel Brobecker), gdb-patches@sourceware.org (gdb-patches ml) In-Reply-To: <1301347008.2433.11.camel@hactar> from "Thiago Jung Bauermann" at Mar 28, 2011 06:16:48 PM MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2011-03/txt/msg01213.txt.bz2 Thiago Jung Bauermann wrote: > 2011-03-28 Thiago Jung Bauermann > > * 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