[RFA] (cli/cli-cmds.c) ARI fix: Avoid assignment inside if statement

Sergio Durigan Junior sergiodj@redhat.com
Sun Dec 23 22:28:00 GMT 2012


On Sunday, December 23 2012, Eli Zaretskii wrote:

>> From: "Pierre Muller" <pierre.muller@ics-cnrs.unistra.fr>
>> Date: Sun, 23 Dec 2012 19:59:49 +0100
>> 
>>   Looks almost obvious, but
>> as it's the first of that kind,
>> I thought I will send it as RFA nonetheless...
>>   
>>   Can similar changes be committed as obvious?
>> They usually require some formatting changes,
>> but generated behavior should not change.
>> 
>> 
>> Pierre Muller
>> as ARI maintainer
>> 
>> 
>> 2012-12-20  Pierre Muller  <muller@sourceware.org>
>> 
>>         ARI fixes: Assignment within if rule.
>>         * cli/cli-cmds.c (shell_escape): Do not set variable value inside
>>         if statement.
>>         (edit_command): Likewise.
>
> Since when is that bad C, so much so that we would need to enforce it?

Interesting...  I remember when I started hacking GDB, I was strongly
discouraged to do assignments inside `if' checkings.  I don't remember
who told me that, but the reason was something related to the Coding
Standards (I don't have any references either).  Anyway, since that
moment I stopped doing this...

FWIW, I agree that it is not bad C, and totally valid, so I for one vote
to remove this rule from ARI.  Nevertheless, I will take a closer look
at the Coding Standards to make sure we're not doing something "wrong"
in this case...

-- 
Sergio



More information about the Gdb-patches mailing list