From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4319 invoked by alias); 23 Dec 2012 22:28:46 -0000 Received: (qmail 4307 invoked by uid 22791); 23 Dec 2012 22:28:45 -0000 X-SWARE-Spam-Status: No, hits=-6.2 required=5.0 tests=AWL,BAYES_00,KHOP_RCVD_UNTRUST,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 23 Dec 2012 22:28:36 +0000 Received: from int-mx02.intmail.prod.int.phx2.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id qBNMSVu0029978 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Sun, 23 Dec 2012 17:28:31 -0500 Received: from psique ([10.3.113.16]) by int-mx02.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id qBNMSR1u015626; Sun, 23 Dec 2012 17:28:28 -0500 From: Sergio Durigan Junior To: Eli Zaretskii Cc: Pierre Muller , gdb-patches@sourceware.org Subject: Re: [RFA] (cli/cli-cmds.c) ARI fix: Avoid assignment inside if statement References: <001201cde13f$af3ad4b0$0db07e10$%muller@ics-cnrs.unistra.fr> <837go8pnxn.fsf@gnu.org> X-URL: http://www.redhat.com Date: Sun, 23 Dec 2012 22:28:00 -0000 In-Reply-To: <837go8pnxn.fsf@gnu.org> (Eli Zaretskii's message of "Sun, 23 Dec 2012 21:29:24 +0200") Message-ID: User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2012-12/txt/msg00794.txt.bz2 On Sunday, December 23 2012, Eli Zaretskii wrote: >> From: "Pierre Muller" >> 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 >> >> 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