public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
* [patch] checkpatch: putting the && or || on the wrong line
@ 2011-01-04  5:59 Dan Carpenter
  2011-01-04  6:58 ` Joe Perches
  2011-01-04 16:38 ` J. Bruce Fields
  0 siblings, 2 replies; 22+ messages in thread
From: Dan Carpenter @ 2011-01-04  5:59 UTC (permalink / raw)
  To: Andy Whitcroft; +Cc: linux-kernel, kernel-janitors, joe

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)) { ...

If you do it in the wrong way the message is:  "put the && or || at the
end of the previous line"

Signed-off-by: Dan Carpenter <error27@gmail.com>

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3c7fc0..0a813db 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1509,6 +1509,11 @@ sub process {
 			WARN("please, no space before tabs\n" . $herevet);
 		}
 
+# check for && or || at the start of a line
+		if ($rawline =~ /^\+\W+(&&|\|\|)/) {
+			WARN("put the && or || at the end of the previous line\n" . $herecurr);
+		}
+
 # check for spaces at the beginning of a line.
 # Exceptions:
 #  1) within comments

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

end of thread, other threads:[~2011-01-08 17:12 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-04  5:59 [patch] checkpatch: putting the && or || on the wrong line Dan Carpenter
2011-01-04  6:58 ` Joe Perches
2011-01-04  9:24   ` Dan Carpenter
2011-01-05 10:24     ` Martin Knoblauch
2011-01-04 16:38 ` J. Bruce Fields
2011-01-04 16:44   ` Samuel Thibault
2011-01-04 17:07     ` Joe Perches
2011-01-05 17:38       ` Krzysztof Halasa
2011-01-05 17:45         ` Joe Perches
2011-01-06 12:11           ` Martin Knoblauch
2011-01-06 17:43             ` Valdis.Kletnieks
2011-01-06 12:32           ` Krzysztof Halasa
2011-01-06 17:57             ` Joe Perches
2011-01-06 20:23               ` Krzysztof Halasa
2011-01-06 21:02                 ` Joe Perches
2011-01-06 21:14                   ` Krzysztof Halasa
2011-01-06 21:38                     ` Joe Perches
2011-01-07 17:12                       ` Valdis.Kletnieks
2011-01-08 13:42                       ` Krzysztof Halasa
2011-01-08 17:12                         ` Joe Perches
2011-01-06 11:55         ` Martin Knoblauch
2011-01-06 12:38           ` Krzysztof Halasa

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