lkml.org 
[lkml]   [2015]   [Nov]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    SubjectRe: [PATCH 02/10] KVM: x86: MMU: Add helper function to clear a bit in unsync child bitmap
    From
    Date
    On 2015/11/19 11:46, Xiao Guangrong wrote:

    >> Actually, some people prefer to put braces when one of the
    >> if/else-if/else cases has multiple lines. You can see
    >> some examples in kernel/sched/core.c: see hrtick_start(),
    >> sched_fork(), free_sched_domain().
    >>
    >> In our case, I thought putting braces would align the else-if
    >> and else and make the code look a bit nicer, but I know this
    >> may be just a matter of personal feeling.
    >>
    >> In short, unless the maintainer, Paolo for this file, has any
    >> preference, both ways will be accepted.
    >
    > The reason why i pointed this out is that it is the style documented
    > in Documentation/CodingStyle:
    > | Do not unnecessarily use braces where a single statement will do.
    > |
    > | if (condition)
    > | action();
    > |

    Ah, this is a different thing. For this case, there is a consensus
    and checkpatch will complain if we don't obey the rule.

    What I explained was:

    if (condition) {
    line1;
    line2; // multiple lines
    } else if {
    single-line-statement; -- (*1)
    } else
    single-line-statement; -- (*2)

    For (*1) and (*2), especially for (*1), some people put braces.

    > Actually, Ingo Molnar hated this braces-style too much and blamed
    > many developers who used this style (include me, that why i was
    > nervous to see this style :( ).

    I think he likes the coding style of kernel/sched/core.c very much,
    as you know. Actually that is one reason why I took it as an example.

    Let's just choose the way which Paolo prefers for this time, I don't
    know which is better.

    Thank you,
    Takuya




    \
     
     \ /
      Last update: 2015-11-19 05:21    [W:2.830 / U:0.124 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site