From: Avi Kivity <avi@redhat.com>
To: Anthony Liguori <anthony@codemonkey.ws>,
av1474@comtv.ru, blauwirbel@gmail.com, qemu-devel@nongnu.org
Subject: [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if'
Date: Mon, 25 Jul 2011 18:55:53 +0300 [thread overview]
Message-ID: <1311609353-28365-1-git-send-email-avi@redhat.com> (raw)
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.
Signed-off-by: Avi Kivity <avi@redhat.com>
---
CODING_STYLE | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
diff --git a/CODING_STYLE b/CODING_STYLE
index 5ecfa22..6e61c49 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:
--
1.7.5.3
next reply other threads:[~2011-07-25 15:56 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-25 15:55 Avi Kivity [this message]
2011-07-25 17:00 ` [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if' Blue Swirl
2011-07-26 6:02 ` Stefan Hajnoczi
2011-07-29 14:37 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1311609353-28365-1-git-send-email-avi@redhat.com \
--to=avi@redhat.com \
--cc=anthony@codemonkey.ws \
--cc=av1474@comtv.ru \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).