From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 5763 invoked by alias); 14 May 2002 01:28:39 -0000 Mailing-List: contact gdb-patches-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sources.redhat.com Received: (qmail 5684 invoked from network); 14 May 2002 01:28:37 -0000 Received: from unknown (HELO www.dberlin.org) (151.203.29.129) by sources.redhat.com with SMTP; 14 May 2002 01:28:37 -0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by www.dberlin.org (Postfix) with ESMTP id D3E964C9D217; Mon, 13 May 2002 21:28:37 -0400 (EDT) Date: Mon, 13 May 2002 18:28:00 -0000 From: Daniel Berlin To: Andrew Cagney Cc: Jim Blandy , Subject: Re: RFA: coding style tweaks In-Reply-To: <3CE0666F.1000304@cygnus.com> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-SW-Source: 2002-05/txt/msg00518.txt.bz2 On Mon, 13 May 2002, Andrew Cagney wrote: > > for the code: > >> > >> /* It's not us. Try all our children, and return the lowest. */ > >> { > >> struct macro_source_file *child; > >> struct macro_source_file *best = 0; > >> int best_depth; > >> > >> for (child = source->includes; child; child = child->next_included) > >> { > >> struct macro_source_file *result > >> = macro_lookup_inclusion (child, name); > >> > >> if (result) > >> { > >> int result_depth = inclusion_depth (result); > >> > >> if (! best || result_depth < best_depth) <-- HERE > > > > > > It's an obvious false positive (!best will be true the first time through, > > meaning the only time we check best_depth, it's already been set at > > least once). > > (I know it is a ``false positive'' but then again if GCC can't figure it > out, how will I :-) Depends on which version of gcc. Some can figure it out. :) Fun, isn't -Wuninitialized? > > > Here, you can't just initialize best_depth to 0, you have to initialize it > > to either INT_MAX, or inclusion_depth (result). > > Since || is a short-circuit, the RHS really doesn't matter. Yeah, yer right. > INT_MAX, though, would make it clearer, could even drop ``!best''. And 3 years from now, when someone decides to rewrite this code, they won't break it if they decide to transform that way. > > enjoy, > Andrew > > > > >