qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] CODING_STYLE: {} as in linux kernel
@ 2009-10-06 19:01 Michael S. Tsirkin
  2009-10-06 21:08 ` Stefan Weil
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Michael S. Tsirkin @ 2009-10-06 19:01 UTC (permalink / raw)
  To: Blue Swirl; +Cc: qemu-devel

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 <mst@redhat.com>

---

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.

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2009-10-07 17:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-10-06 19:01 [Qemu-devel] [PATCH] CODING_STYLE: {} as in linux kernel Michael S. Tsirkin
2009-10-06 21:08 ` Stefan Weil
2009-10-06 21:43   ` Anthony Liguori
2009-10-07 12:59     ` Markus Armbruster
2009-10-06 21:41 ` Stuart Brady
2009-10-07  9:11 ` Jamie Lokier
2009-10-07 14:12 ` Kevin Wolf
2009-10-07 14:54   ` Gerd Hoffmann
2009-10-07 17:09     ` Stuart Brady

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).