Re: coding style for long conditions

Roland Dreier
2007-04-06T21:38:37Z

[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___________) {
doit;

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.