[lkml]   [2007]   [Apr]   [6]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
Messages in this thread
    SubjectRe: coding style for long conditions
    [I can't believe I'm stepping into an indentation flamewar, but here goes...]

    > Please change your coding style to conform to Documentation/CodingStyle.
    > *** Only indent with tabs!! ***
    > Every one of those examples violates that simple rule.

    Yes, Documentation/CodingStyle says that we should only indent with
    tabs. However, that simple rule has to be interpreted with some
    common sense, and the case of multi-line if conditions is definitely a
    case where using only tabs makes code much less readable.

    If you want an excuse, you could say that in code like

    if (foo___________ &&
    bar___________) {

    that the line with "bar" on it is properly indented with one tab
    (since it is part of the if statement that is also indented one tab),
    and then four spaces are used to align the "bar" with the previous
    line. So only tabs are used for indentation, and the spaces after the
    tab are used for alignment, and the letter of the law is observed.

    If you have a git tree handy, you can do "git show 68380b58" and see
    that Linus himself wrote:

    if (get_wq_data(work) == cwq
    && work_pending(work)
    && !list_empty(&work->entry)) {

    I have to admit that I would have put the &&s at the ends of the
    previous lines rather than where Linus put them, but... egads! Linus
    put spaces before the &&s to line them up nicely!

    "more in the breach" and all that I guess...

    - R.
    To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
    the body of a message to
    More majordomo info at
    Please read the FAQ at

     \ /
      Last update: 2007-04-06 23:41    [W:0.023 / U:47.564 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site