public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* Preferred line-break style around binary operators?
@ 2013-10-06 21:48 Josh Triplett
  2013-10-06 22:01 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Josh Triplett @ 2013-10-06 21:48 UTC (permalink / raw)
  To: torvalds; +Cc: linux-kernel

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Preferred line-break style around binary operators?
  2013-10-06 21:48 Preferred line-break style around binary operators? Josh Triplett
@ 2013-10-06 22:01 ` Joe Perches
  2013-10-06 22:11   ` Josh Triplett
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2013-10-06 22:01 UTC (permalink / raw)
  To: Josh Triplett; +Cc: torvalds, linux-kernel

On Sun, 2013-10-06 at 14:48 -0700, Josh Triplett wrote:
> 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.

That was pretty contentious awhile ago.
An example:
https://lkml.org/lkml/2009/12/5/30

net/ and drivers/net/ use && and || at EOL.


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Preferred line-break style around binary operators?
  2013-10-06 22:01 ` Joe Perches
@ 2013-10-06 22:11   ` Josh Triplett
  0 siblings, 0 replies; 3+ messages in thread
From: Josh Triplett @ 2013-10-06 22:11 UTC (permalink / raw)
  To: Joe Perches; +Cc: torvalds, linux-kernel

On Sun, Oct 06, 2013 at 03:01:26PM -0700, Joe Perches wrote:
> On Sun, 2013-10-06 at 14:48 -0700, Josh Triplett wrote:
> > 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.
> 
> That was pretty contentious awhile ago.
> An example:
> https://lkml.org/lkml/2009/12/5/30
> 
> net/ and drivers/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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-10-06 22:11 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-10-06 21:48 Preferred line-break style around binary operators? Josh Triplett
2013-10-06 22:01 ` Joe Perches
2013-10-06 22:11   ` Josh Triplett

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox