From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MvFJn-0000yl-AH for qemu-devel@nongnu.org; Tue, 06 Oct 2009 15:03:27 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MvFJh-0000na-25 for qemu-devel@nongnu.org; Tue, 06 Oct 2009 15:03:25 -0400 Received: from [199.232.76.173] (port=53064 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MvFJg-0000nL-Tf for qemu-devel@nongnu.org; Tue, 06 Oct 2009 15:03:20 -0400 Received: from mx1.redhat.com ([209.132.183.28]:9885) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MvFJg-0003zY-62 for qemu-devel@nongnu.org; Tue, 06 Oct 2009 15:03:20 -0400 Date: Tue, 6 Oct 2009 21:01:15 +0200 From: "Michael S. Tsirkin" Message-ID: <20091006190115.GA4768@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [Qemu-devel] [PATCH] CODING_STYLE: {} as in linux kernel List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Blue Swirl Cc: qemu-devel@nongnu.org Most people seem to hate using {} around sngle-statement blocks. And code isn't consistent either way. So let's change our standard to something most people like, and eliminate the pain source. Signed-off-by: Michael S. Tsirkin --- The idea is to see which parts of linux kernel style we can pick without much transitional pain. Let's start small, the following seems to be almost unanimously hated. diff --git a/CODING_STYLE b/CODING_STYLE index a579cb1..2e3ecba 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -51,19 +51,19 @@ QEMU coding style. 4. Block structure -Every indented statement is braced; even if the block contains just one -statement. The 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. Example: +If an indented block contains just one statement, it is not braced. This +matches the Linux coding style. The opening brace of a block 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. Example: - if (a == 5) { + if (a == 5) printf("a was 5.\n"); - } else if (a == 6) { + else if (a == 6) { printf("a was 6.\n"); - } else { + printf("multiply by 7 to get the answer.\n"); + } else printf("a was something else entirely.\n"); - } An exception is the opening brace for a function; for reasons of tradition and clarity it comes on a line by itself: @@ -75,4 +75,5 @@ and clarity it comes on a line by itself: Rationale: a consistent (except for functions...) bracing style reduces ambiguity and avoids needless churn when lines are added or removed. +This matches the linux coding style. Furthermore, it is the QEMU coding style.