This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
Re: RFA: coding style tweaks
- From: Andrew Cagney <ac131313 at cygnus dot com>
- To: Daniel Berlin <dberlin at dberlin dot org>
- Cc: Jim Blandy <jimb at redhat dot com>, gdb-patches at sources dot redhat dot com
- Date: Mon, 13 May 2002 21:20:47 -0400
- Subject: Re: RFA: coding style tweaks
- References: <Pine.LNX.4.44.0205132029510.16238-100000@dberlin.org>
> 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