CODING_STYLE: explicitly allow braceless 'else if'
PATCH 1/1 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.
--- CODING_STYLE | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
CODING_STYLE +4 -0
@@ -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:
Signature · 1 line
1.7.5.3
Quoted 35 lines · Avi Kivity
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 {
...
}
Quoted 3 lines
which is more readable.
Signed-off-by Avi Kivity <[email protected]>
Quoted 23 lines
---
CODING_STYLE | 4 ++++1 files changed, 4 insertions(+), 0 deletions(-)CODING_STYLE +4
-0@@ -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
Quoted 36 lines · Blue Swirl
Quoted 35 lines · Avi Kivity
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 {
...
}
Quoted 5 lines
Quoted 3 lines
which is more readable.
Signed-off-by Avi Kivity <[email protected]>Acked-by Blue Swirl <[email protected]>
Yes please, I use this too.
Stefan
Anthony Liguori
AppliedQuoted 35 lines · Avi Kivity
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 { ... }
Quoted 3 lines
which is more readable.
Signed-off-by Avi Kivity<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 19 lines
--- CODING_STYLE | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)CODING_STYLE +4
-0@@ -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: