qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH 0/5] CODING_STYLE amendments


From: Blue Swirl
Subject: Re: [Qemu-devel] [PATCH 0/5] CODING_STYLE amendments
Date: Fri, 20 Aug 2010 20:24:53 +0000

On Fri, Aug 20, 2010 at 6:44 PM, Blue Swirl <address@hidden> wrote:
> On Fri, Aug 20, 2010 at 1:47 PM, Markus Armbruster <address@hidden> wrote:
>> Anthony Liguori <address@hidden> writes:
>>
>>> On 08/17/2010 03:04 AM, Jes Sorensen wrote:
>>>> On 08/13/10 20:02, Blue Swirl wrote:
>>>>
>>>>> On Fri, Aug 13, 2010 at 3:22 PM, Miguel Di Ciurcio Filho
>>>>> <address@hidden>  wrote:
>>>>>
>>>>>> The existing code that I have touched don't follow the current coding
>>>>>> style guidance, much less all the new recommendations being suggested.
>>>>>>
>>>>>> Although, I do believe that this situation needs to change. If we
>>>>>> agree in a coding style, I would volunteer to be a some kind of
>>>>>> observer to fix and alert people about coding styles mistakes.
>>>>>>
>>>>> I fully agree on the need of change and support your excellent idea.
>>>>> There are other ways to solve the problem, but I believe we need more
>>>>> order than more chaos. Perhaps we the QEMU developers should appoint
>>>>> you the Guardian of the CODING_STYLE, and add a rule that no patch
>>>>> shall be committed without your CS-Acked-by line?
>>>>>
>>>> I don't think this would ever work, it is begging for trouble relying on
>>>> one person to review all patches for this.
>>>>
>>>> While I agree coding style is good since it enforces consistency, there
>>>> are plenty problems with the old rules
>>>
>>> To be perfectly honest, we have enough hard problems to solve in QEMU.
>>> We're spending a lot more time on coding style than we probably need
>>> to :-)
>>
>> In my not so humble opinion, that's because the current CODING_STYLE is
>> idiosyncratic, widely disliked (follows from idiosyncratic pretty much
>> inevitably), widely violated by existing code, and only haphazardly
>> enforced for new code.
>
> I think Coccinelle could help us here, it can check for some of the
> CODING_STYLE issues. We only need to include it to our build system
> and add git hooks if possible. It can also perform mechanical
> conversions (if desired).

This Coccinelle script seems to do the job:
@curly_if@
position p;
@@

address@hidden (...) { ... }

@simple_if@
position p != curly_if.p;
statement S;
expression E;
@@

- address@hidden (E) S
+ if (E) {
+    S
+ }

@curly_for@
position q;
@@

address@hidden (...;...;...) { ... }

@simple_for@
position q != curly_for.q;
statement S;
expression E1, E2, E3;
@@

- address@hidden (E1; E2; E3) S
+ for (E1; E2; E3) {
+    S
+ }

@curly_while@
position r;
@@

address@hidden (...) { ... }

@simple_while@
position r != curly_while.r;
statement S;
expression E;
@@

- address@hidden (E) S
+ while (E) {
+    S
+ }

There are some formatting issues though, I get changes like:
-    for (i=0; i<5; i++)
+    for(i = 0;i < 5;i++) {

Reformatting the expressions with more spaces is nice, but removing
the spaces between 'for' and '(' and especially after ';' is not.



reply via email to

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