From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28876 invoked by alias); 14 May 2002 01:20:46 -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 28859 invoked from network); 14 May 2002 01:20:43 -0000 Received: from unknown (HELO localhost.redhat.com) (24.112.240.27) by sources.redhat.com with SMTP; 14 May 2002 01:20:43 -0000 Received: from cygnus.com (localhost [127.0.0.1]) by localhost.redhat.com (Postfix) with ESMTP id F402D3E16; Mon, 13 May 2002 21:20:47 -0400 (EDT) Message-ID: <3CE0666F.1000304@cygnus.com> Date: Mon, 13 May 2002 18:20:00 -0000 From: Andrew Cagney User-Agent: Mozilla/5.0 (X11; U; NetBSD macppc; en-US; rv:1.0rc1) Gecko/20020429 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Daniel Berlin Cc: Jim Blandy , gdb-patches@sources.redhat.com Subject: Re: RFA: coding style tweaks References: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2002-05/txt/msg00516.txt.bz2 > 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 :-) > 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. INT_MAX, though, would make it clearer, could even drop ``!best''. enjoy, Andrew