Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Carlos O'Donell <carlos@codesourcery.com>
To: Jim Blandy <jimb@codesourcery.com>
Cc: gdb-patches@sourceware.org, Daniel Jacobowitz <dan@codesourcery.com>
Subject: Re: [PATCH] Fix uninitialized use of variables.
Date: Wed, 24 Oct 2007 17:24:00 -0000	[thread overview]
Message-ID: <20071024171544.GO21241@lios> (raw)
In-Reply-To: <m3wstdo1yu.fsf@codesourcery.com>

On Tue, Oct 23, 2007 at 04:17:29PM -0700, Jim Blandy wrote:
> 
> Carlos O'Donell <carlos at codesourcery.com> writes:
> > In symtab.c (find_line_common) the variable *exact_match is not set if
> > no match is found. Callers of find_line_common expect *exact_match to be
> > set. The solution is to initialize *exact_match to zero, assuming an
> > inexact match. In the case that we don't find a match in
> > find_line_common, the statement `(best_index < 0 || !exact)' in
> > symtab.c:2267 is true, instead of undefined. The comment is adjusted to
> > indicate that one must look at another symtab if we failed to find a
> > match `best_index < 0' or we found an inexact match `!exact.'
> 
> As far as the symtab.c change is concerned: the specification of
> find_line_common is that *EXACT_MATCH is set only if the function
> returns a match (a non-negative value).  As far as I can see,
> find_line_symtab doesn't actually use the value of 'exact' unless the
> corresponding call to find_line_common returned a match.  So the
> warning looks spurious to me.
> 
> (I don't mind initializing 'exact' in find_line_symtab to placate the
> compiler.)

Sorry, yes, the boolean short circuit avoids the evaluation of !exact.
The compiler probably can't see that though and warns that it *may* be
an uninitialized use of the variable.

I'll whip up a patch that initializes exact in find_line_symtab.

Thanks for the review.

Cheers,
Carlos.
-- 
Carlos O'Donell
CodeSourcery
carlos@codesourcery.com
(650) 331-3385 x716


  reply	other threads:[~2007-10-24 17:15 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-20 18:07 Carlos O'Donell
2007-10-23 23:20 ` Jim Blandy
2007-10-24 17:24   ` Carlos O'Donell [this message]
2007-10-24  0:10 ` Jim Blandy
2007-10-24  4:05   ` Daniel Jacobowitz
2007-10-24 17:12     ` Jim Blandy
2007-10-24 17:57       ` Daniel Jacobowitz
2007-10-24 17:15   ` Jim Blandy
2007-10-24 18:02   ` Carlos O'Donell
2007-10-24 18:21     ` Jim Blandy
2007-10-26 18:51       ` Carlos O'Donell

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=20071024171544.GO21241@lios \
    --to=carlos@codesourcery.com \
    --cc=dan@codesourcery.com \
    --cc=gdb-patches@sourceware.org \
    --cc=jimb@codesourcery.com \
    /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