qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else


From: Anthony Liguori
Subject: Re: [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if'
Date: Fri, 29 Jul 2011 09:37:29 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.17) Gecko/20110516 Lightning/1.0b2 Thunderbird/3.1.10

On 07/25/2011 10:55 AM, Avi Kivity wrote:
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<address@hidden>

Applied.  Thanks.

Regards,

Anthony Liguori

---
  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:





reply via email to

[Prev in Thread] Current Thread [Next in Thread]