From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1N2S2V-0006Zt-8q for qemu-devel@nongnu.org; Mon, 26 Oct 2009 12:03:23 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1N2S2O-0006Xg-Bc for qemu-devel@nongnu.org; Mon, 26 Oct 2009 12:03:20 -0400 Received: from [199.232.76.173] (port=53691 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1N2S2M-0006X4-Kv for qemu-devel@nongnu.org; Mon, 26 Oct 2009 12:03:15 -0400 Received: from mail-bw0-f228.google.com ([209.85.218.228]:43812) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1N2S2M-0001Y4-5I for qemu-devel@nongnu.org; Mon, 26 Oct 2009 12:03:14 -0400 Received: by bwz28 with SMTP id 28so2507052bwz.17 for ; Mon, 26 Oct 2009 09:03:12 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20091026062637.GA21562@volta.aurel32.net> References: <20091026062637.GA21562@volta.aurel32.net> From: Blue Swirl Date: Mon, 26 Oct 2009 18:02:52 +0200 Message-ID: Subject: Re: [Qemu-devel] [PATCH] CODING_STYLE: don't allow non-indented statements after if/else blocks Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Aurelien Jarno Cc: qemu-devel@nongnu.org On Mon, Oct 26, 2009 at 8:26 AM, Aurelien Jarno wrot= e: > Rationale: The following code is difficult to read, but allowed by the > current coding style. Fully agree. > +Every control flow statement is followed by a new indented and braced > +block; even if the block contains just one statement. =C2=A0The opening = brace > +is on the line that contains the control flow statement that introduces > +the new block; the closing brace is on the same line as the else keyword= , > +or on a line by itself if there is no else keyword. =C2=A0Example: I think an exception should be granted for "else if" case, otherwise the style would require braces around "if", like: if (a =3D=3D 5) { printf("a was 5.\n"); } else { if (a =3D=3D 6) { printf("a was 6.\n"); } } else { printf("a was something else entirely.\n"); } Picking nits: "while" is a control flow statement, even in "do {} while" statement and then it would illegal to require a braced block after the "while" statement.