* [Qemu-devel] [PATCH] Get coding style closer to the real world
@ 2009-11-30 21:55 Alexander Graf
2009-12-01 9:39 ` Markus Armbruster
2009-12-04 17:47 ` Paul Brook
0 siblings, 2 replies; 6+ messages in thread
From: Alexander Graf @ 2009-11-30 21:55 UTC (permalink / raw)
To: qemu-devel
Currently we have this stupid role of disallowing:
if (r)
break;
By disallowing this we clutter the code, making it less readable without
buying us anything. In fact, nobody actually sticks to this because it'd show
just how much bad taste the programmer doing this would have.
So IMHO we should change the coding style, so we can finally focus on
programming again and don't focus on useless coding style rules.
Signed-off-by: Alexander Graf <agraf@suse.de>
---
CODING_STYLE | 23 ++++++++++++++++++-----
1 files changed, 18 insertions(+), 5 deletions(-)
diff --git a/CODING_STYLE b/CODING_STYLE
index a579cb1..806a1f8 100644
--- a/CODING_STYLE
+++ b/CODING_STYLE
@@ -51,11 +51,24 @@ QEMU coding style.
4. Block structure
-Every indented statement is braced; even if the block contains just one
-statement. The opening brace is on the line that contains the control
-flow statement that introduces the new block; the closing brace is on the
-same line as the else keyword, or on a line by itself if there is no else
-keyword. Example:
+Usually indented statements are braced; even if the block contains just one
+statement. When braces reduce readability, they are not mandatory.
+
+Examples:
+
+ if (a == 5)
+ break;
+
+ if (b == 6) {
+ c = do_something();
+ /* Probably more code to be added here later */
+ }
+
+The opening brace is on the line that contains the control flow statement
+that introduces the new block; the closing brace is on the same line as
+the else keyword, or on a line by itself if there is no else keyword.
+
+Example:
if (a == 5) {
printf("a was 5.\n");
--
1.6.0.2
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Get coding style closer to the real world
2009-11-30 21:55 [Qemu-devel] [PATCH] Get coding style closer to the real world Alexander Graf
@ 2009-12-01 9:39 ` Markus Armbruster
2009-12-04 17:47 ` Paul Brook
1 sibling, 0 replies; 6+ messages in thread
From: Markus Armbruster @ 2009-12-01 9:39 UTC (permalink / raw)
To: Alexander Graf; +Cc: qemu-devel
Alexander Graf <agraf@suse.de> writes:
> Currently we have this stupid role of disallowing:
>
> if (r)
> break;
>
> By disallowing this we clutter the code, making it less readable without
> buying us anything. In fact, nobody actually sticks to this because it'd show
> just how much bad taste the programmer doing this would have.
>
> So IMHO we should change the coding style, so we can finally focus on
> programming again and don't focus on useless coding style rules.
>
> Signed-off-by: Alexander Graf <agraf@suse.de>
ACK
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Get coding style closer to the real world
2009-11-30 21:55 [Qemu-devel] [PATCH] Get coding style closer to the real world Alexander Graf
2009-12-01 9:39 ` Markus Armbruster
@ 2009-12-04 17:47 ` Paul Brook
2009-12-04 22:30 ` Anthony Liguori
2009-12-04 23:47 ` Alexander Graf
1 sibling, 2 replies; 6+ messages in thread
From: Paul Brook @ 2009-12-04 17:47 UTC (permalink / raw)
To: qemu-devel
On Monday 30 November 2009, Alexander Graf wrote:
> Currently we have this stupid role of disallowing:
>
> if (r)
> break;
This has been discussed to death several times, in several different paces,
and with no clear resolution or consensus, so I'm going to make an executive
decision:
The coding style stays as-is. Braces are required. Please ensure that all
patches follow the coding style. There may be exceptions, but there should be
a *good* reason for deviation.
If there are real problems or ambiguities in the coding style then I am
willing to consider fixing it. This particular change meets neither criteria.
By picking a single coding style we've pretty much guaranteed that most people
will disagree with some of it. IMO consistency is more important.
Paul
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Get coding style closer to the real world
2009-12-04 17:47 ` Paul Brook
@ 2009-12-04 22:30 ` Anthony Liguori
2009-12-05 17:33 ` Avi Kivity
2009-12-04 23:47 ` Alexander Graf
1 sibling, 1 reply; 6+ messages in thread
From: Anthony Liguori @ 2009-12-04 22:30 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
Paul Brook wrote:
> On Monday 30 November 2009, Alexander Graf wrote:
>
>> Currently we have this stupid role of disallowing:
>>
>> if (r)
>> break;
>>
>
> This has been discussed to death several times, in several different paces,
> and with no clear resolution or consensus, so I'm going to make an executive
> decision:
>
> The coding style stays as-is. Braces are required. Please ensure that all
> patches follow the coding style. There may be exceptions, but there should be
> a *good* reason for deviation.
>
>
> If there are real problems or ambiguities in the coding style then I am
> willing to consider fixing it. This particular change meets neither criteria.
>
> By picking a single coding style we've pretty much guaranteed that most people
> will disagree with some of it. IMO consistency is more important.
>
I agree 100%.
Regards,
Anthony Liguori
> Paul
>
>
>
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Get coding style closer to the real world
2009-12-04 22:30 ` Anthony Liguori
@ 2009-12-05 17:33 ` Avi Kivity
0 siblings, 0 replies; 6+ messages in thread
From: Avi Kivity @ 2009-12-05 17:33 UTC (permalink / raw)
To: Anthony Liguori; +Cc: Paul Brook, qemu-devel
On 12/05/2009 12:30 AM, Anthony Liguori wrote:
> Paul Brook wrote:
>> On Monday 30 November 2009, Alexander Graf wrote:
>>> Currently we have this stupid role of disallowing:
>>>
>>> if (r)
>>> break;
>>
>> This has been discussed to death several times, in several different
>> paces, and with no clear resolution or consensus, so I'm going to
>> make an executive decision:
>>
>> The coding style stays as-is. Braces are required. Please ensure that
>> all patches follow the coding style. There may be exceptions, but
>> there should be a *good* reason for deviation.
>>
>>
>> If there are real problems or ambiguities in the coding style then I
>> am willing to consider fixing it. This particular change meets
>> neither criteria.
>>
>> By picking a single coding style we've pretty much guaranteed that
>> most people will disagree with some of it. IMO consistency is more
>> important.
>
> I agree 100%.
+1'ed, and I note that although brace-happy code looks more cluttered it
is a bit safer and produces cleaner patches.
--
Do not meddle in the internals of kernels, for they are subtle and quick to panic.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [Qemu-devel] [PATCH] Get coding style closer to the real world
2009-12-04 17:47 ` Paul Brook
2009-12-04 22:30 ` Anthony Liguori
@ 2009-12-04 23:47 ` Alexander Graf
1 sibling, 0 replies; 6+ messages in thread
From: Alexander Graf @ 2009-12-04 23:47 UTC (permalink / raw)
To: Paul Brook; +Cc: qemu-devel
On 04.12.2009, at 18:47, Paul Brook wrote:
> On Monday 30 November 2009, Alexander Graf wrote:
>> Currently we have this stupid role of disallowing:
>>
>> if (r)
>> break;
>
> This has been discussed to death several times, in several different paces,
> and with no clear resolution or consensus, so I'm going to make an executive
> decision:
>
> The coding style stays as-is. Braces are required. Please ensure that all
> patches follow the coding style. There may be exceptions, but there should be
> a *good* reason for deviation.
>
>
> If there are real problems or ambiguities in the coding style then I am
> willing to consider fixing it. This particular change meets neither criteria.
>
> By picking a single coding style we've pretty much guaranteed that most people
> will disagree with some of it. IMO consistency is more important.
Could we please convert all the code base to the new style then? For exactly the consistency reason.
Alex
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2009-12-05 17:33 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-11-30 21:55 [Qemu-devel] [PATCH] Get coding style closer to the real world Alexander Graf
2009-12-01 9:39 ` Markus Armbruster
2009-12-04 17:47 ` Paul Brook
2009-12-04 22:30 ` Anthony Liguori
2009-12-05 17:33 ` Avi Kivity
2009-12-04 23:47 ` Alexander Graf
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).