summaryrefslogtreecommitdiffstats
path: root/CODING_STYLE
diff options
context:
space:
mode:
authorAvi Kivity2011-07-25 17:55:53 +0200
committerAnthony Liguori2011-07-29 16:33:56 +0200
commit5f070c5fb768cc587b1a75379b7b17c3f841fd40 (patch)
tree99cbf3de3b393d0078c2ea65832a7559b2e3d6cf /CODING_STYLE
parentFix a compilation error in xen-mapcache.c (diff)
downloadqemu-5f070c5fb768cc587b1a75379b7b17c3f841fd40.tar.gz
qemu-5f070c5fb768cc587b1a75379b7b17c3f841fd40.tar.xz
qemu-5f070c5fb768cc587b1a75379b7b17c3f841fd40.zip
CODING_STYLE: explicitly allow braceless 'else if'
It's already allowed by the example; there are about 1800 instances in the tree; and disallowing it would lead to if (a) { ... } else { if (b) { ... } else { if (c) { ... } else { if (d) { ... } else { ... } } } } instead of if (a) { ... } else if (b) { ... } else if (c) { ... } else if (d) { ... } else { ... } which is more readable. Acked-by: Blue Swirl <blauwirbel@gmail.com> Signed-off-by: Avi Kivity <avi@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Diffstat (limited to 'CODING_STYLE')
-rw-r--r--CODING_STYLE4
1 files changed, 4 insertions, 0 deletions
diff --git a/CODING_STYLE b/CODING_STYLE
index 5ecfa22161..6e61c49089 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -68,6 +68,10 @@ keyword. Example:
printf("a was something else entirely.\n");
}
+Note that 'else if' is considered a single statement; otherwise a long if/
+else if/else if/.../else sequence would need an indent for every else
+statement.
+
An exception is the opening brace for a function; for reasons of tradition
and clarity it comes on a line by itself: