]> git.proxmox.com Git - mirror_qemu.git/commitdiff
CODING_STYLE: explicitly allow braceless 'else if'
authorAvi Kivity <avi@redhat.com>
Mon, 25 Jul 2011 15:55:53 +0000 (18:55 +0300)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 29 Jul 2011 14:33:56 +0000 (09:33 -0500)
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>
CODING_STYLE

index 5ecfa2216109963cb646b5fcf00a10c85d3d0655..6e61c490894e244e7b8bc3c8553de9cae8cc9ead 100644 (file)
@@ -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: