[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1294160834.6617.51.camel@Joe-Laptop>
Date: Tue, 04 Jan 2011 09:07:14 -0800
From: Joe Perches <joe@...ches.com>
To: Samuel Thibault <samuel.thibault@...-lyon.org>
Cc: "J. Bruce Fields" <bfields@...ldses.org>,
Dan Carpenter <error27@...il.com>,
Andy Whitcroft <apw@...onical.com>,
linux-kernel@...r.kernel.org, kernel-janitors@...r.kernel.org
Subject: Re: [patch] checkpatch: putting the && or || on the wrong line
On Tue, 2011-01-04 at 17:44 +0100, Samuel Thibault wrote:
> J. Bruce Fields, le Tue 04 Jan 2011 11:38:36 -0500, a écrit :
> > On Tue, Jan 04, 2011 at 08:59:00AM +0300, Dan Carpenter wrote:
> > > This patch makes checkpatch.pl complain if you break up conditions in
> > > the wrong way.
> > > Wrong:
> > > if ((really_long_condition)
> > > && (second_condition)) { ...
> > > Right:
> > > if ((really_long_condition) &&
> > > (second_condition)) { ...
> > As far as I can tell, the convention in mathematical typesetting is to
> > put operators on the left, not the right. When the conditions are short
> > of there are more lines, that allows you to left-align on the repeated
> > operator.
> I personally find the left approach more readable.
As do I, but perhaps coding style in a project like this
shouldn't be personal but collective.
The trailing style outnumbers the leading style ~ 5:1.
$ grep -rP --include=*.[ch] "(\|\||&&)[ \t]*$" * | wc -l
39890
$ grep -rP --include=*.[ch] "^[ \t]*(\|\||&&)" * | wc -l
8244
If you take out drivers/staging, trailing is used ~ 6:1.
I think that high enough to be declared the preferred style.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists