Preferred line-break style around binary operators?
There are two common approaches to breaking long lines at binary
operators: breaking the line before the operator (putting the operator at the start of the next line), or breaking the line after the operator (putting the operator at the end of the previous line).
CodingStyle doesn't define any requirement here, and the kernel uses both approaches; for instance, using && as a sample:
$ git grep -h '&&$' | wc -l 28872 $ git grep -h '^[[:space:]]*&&' | wc -l 4169
Which style should kernel code use? I can submit a CodingStyle patch documenting that preference for future reference.
- Josh Triplett
Quoted 8 lines · Josh Triplett
There are two common approaches to breaking long lines at binary
operators: breaking the line before the operator (putting the operator at the start of the next line), or breaking the line after the operator (putting the operator at the end of the previous line).CodingStyle doesn't define any requirement here, and the kernel uses both approaches; for instance, using && as a sample:
Quoted 7 lines
$ git grep -h '&&$' | wc -l 28872 $ git grep -h '^[[:space:]]*&&' | wc -l 4169Which style should kernel code use? I can submit a CodingStyle patch documenting that preference for future reference.
That was pretty contentious awhile ago.
An example:
https://lkml.org/lkml/2009/12/5/30
net/ and drivers/net/ use && and || at EOL.
Quoted 14 lines · Joe Perches
Quoted 13 lines · Josh Triplett
There are two common approaches to breaking long lines at binary
operators: breaking the line before the operator (putting the operator at the start of the next line), or breaking the line after the operator (putting the operator at the end of the previous line).CodingStyle doesn't define any requirement here, and the kernel uses both approaches; for instance, using && as a sample:
$ git grep -h '&&$' | wc -l 28872 $ git grep -h '^[[:space:]]*&&' | wc -l 4169
Quoted 8 lines
Quoted 2 lines
Which style should kernel code use? I can submit a CodingStyle patch documenting that preference for future reference.
That was pretty contentious awhile ago.
An example:
https://lkml.org/lkml/2009/12/5/30
net/anddrivers/net/use && and || at EOL.
It appears that the vast majority of kernel code does the same, judging by the grep above.
Personally I prefer to put binary operators at the start of the following line, but my preference isn't the deciding factor here.
I'd just like to see one or the other style documented as preferred in CodingStyle for future reference, rather than having new kernel code continue to use a mix of both styles.
- Josh Triplett