* [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if'
@ 2011-07-25 15:55 Avi Kivity
2011-07-25 17:00 ` Blue Swirl
2011-07-29 14:37 ` Anthony Liguori
0 siblings, 2 replies; 4+ messages in thread
From: Avi Kivity @ 2011-07-25 15:55 UTC (permalink / raw)
To: Anthony Liguori, av1474, blauwirbel, qemu-devel
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if'
2011-07-25 15:55 [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if' Avi Kivity
@ 2011-07-25 17:00 ` Blue Swirl
2011-07-26 6:02 ` Stefan Hajnoczi
2011-07-29 14:37 ` Anthony Liguori
1 sibling, 1 reply; 4+ messages in thread
From: Blue Swirl @ 2011-07-25 17:00 UTC (permalink / raw)
To: Avi Kivity; +Cc: qemu-devel
On Mon, Jul 25, 2011 at 6:55 PM, Avi Kivity <avi@redhat.com> 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 <avi@redhat.com>
Acked-by: Blue Swirl <blauwirbel@gmail.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
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if'
2011-07-25 17:00 ` Blue Swirl
@ 2011-07-26 6:02 ` Stefan Hajnoczi
0 siblings, 0 replies; 4+ messages in thread
From: Stefan Hajnoczi @ 2011-07-26 6:02 UTC (permalink / raw)
To: Blue Swirl; +Cc: Avi Kivity, qemu-devel
On Mon, Jul 25, 2011 at 6:00 PM, Blue Swirl <blauwirbel@gmail.com> wrote:
> On Mon, Jul 25, 2011 at 6:55 PM, Avi Kivity <avi@redhat.com> 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 <avi@redhat.com>
>
> Acked-by: Blue Swirl <blauwirbel@gmail.com>
Yes please, I use this too.
Stefan
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if'
2011-07-25 15:55 [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if' Avi Kivity
2011-07-25 17:00 ` Blue Swirl
@ 2011-07-29 14:37 ` Anthony Liguori
1 sibling, 0 replies; 4+ messages in thread
From: Anthony Liguori @ 2011-07-29 14:37 UTC (permalink / raw)
To: Avi Kivity; +Cc: blauwirbel, qemu-devel
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<avi@redhat.com>
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:
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-07-29 14:37 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-25 15:55 [Qemu-devel] [PATCH] CODING_STYLE: explicitly allow braceless 'else if' Avi Kivity
2011-07-25 17:00 ` Blue Swirl
2011-07-26 6:02 ` Stefan Hajnoczi
2011-07-29 14:37 ` Anthony Liguori
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).