From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21536 invoked by alias); 23 Feb 2009 03:13:50 -0000 Received: (qmail 21527 invoked by uid 22791); 23 Feb 2009 03:13:49 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 23 Feb 2009 03:13:44 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id C5A0A2BAB66; Sun, 22 Feb 2009 22:13:44 -0500 (EST) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id G82vbe+3ySDT; Sun, 22 Feb 2009 22:13:44 -0500 (EST) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 65C782BAB5E; Sun, 22 Feb 2009 22:13:44 -0500 (EST) Received: by joel.gnat.com (Postfix, from userid 1000) id 0E01FE7ACD; Sun, 22 Feb 2009 19:13:40 -0800 (PST) Date: Mon, 23 Feb 2009 04:07:00 -0000 From: Joel Brobecker To: Jay Cc: gdb-patches@sourceware.org Subject: Re: warning/error about possibly uninitialized 'exact' in find_line_symtab Message-ID: <20090223031339.GF26056@adacore.com> References: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="huq684BweRXVnRxX" Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.2i 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: 2009-02/txt/msg00434.txt.bz2 --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-length: 1822 Jay, > So maybe I'll go back to that. For future contributes, I would appreciate if you did indeed send patches applying to the HEAD. Otherwise, it can just introduce confusion. As mentioned previously, please make sure to read gdb/CONTRIBUTE to make sure that your contributions follow the proper procedure. > Sure, now it may be unoptimally unnecessarily initialized but > I don't think that is worth worrying about. Agreed. And I can see how the compiler might think that this variable might be used before being initialized (the value is set during a call to a function that's passed a pointer to this variable, so technically the function might not change its value). > I use { 0 } instead of 0 because it is a more generic form that > can zero initialize "anything", except some unions on some compilers, > it might not always zero the entire thing. That's right, but really in this case, we're initializing an int. The day we change it to another type, we'll be careful to initialize it properly... In the meantime, I checked in the attached patch, which uses the simple integer initialization... I mentioned copyright assignment in my previous email to you. We're able to accept this contribution in this particular case, because the change is very small and relatively obvious. Besides, I changed the implementation, so technically you only contributed ideas, which are not copyrightable, but I decided to credit the change to you nonetheless. 2009-02-23 Jay Krell (tiny change) * symtab.c (find_line_symtab): Initialize exact to avoid a compiler warning. Tested on x86-linux. Checked in. (thinking aloud - do we need a more descriptive comment about why we initialize this variable here? I don't think it's necessary, but let me know otherwise) -- Joel --huq684BweRXVnRxX Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="symtab.c.diff" Content-length: 464 diff --git a/gdb/symtab.c b/gdb/symtab.c index 1ef92a8..d51c7aa 100644 --- a/gdb/symtab.c +++ b/gdb/symtab.c @@ -2361,7 +2361,7 @@ find_pc_line (CORE_ADDR pc, int notcurrent) struct symtab * find_line_symtab (struct symtab *symtab, int line, int *index, int *exact_match) { - int exact; + int exact = 0; /* Initialized here to avoid a compiler warning. */ /* BEST_INDEX and BEST_LINETABLE identify the smallest linenumber > LINE so far seen. */ --huq684BweRXVnRxX--