netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break
@ 2014-05-10  4:41 Jeff Kirsher
  2014-05-10  4:47 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Jeff Kirsher @ 2014-05-10  4:41 UTC (permalink / raw)
  To: joe, akpm; +Cc: David Ertman, linux-kernel, netdev, Jeff Kirsher

From: David Ertman <davidx.m.ertman@intel.com>

Using the intuitive breaking of a ternary operator used in the
initialization of a variable in its declaration:

type var = FOO ?
           BAR :
           FEE;

is causing a checkpatch warning:
"WARNING:SPACING: networking uses a blank line after declarations"

Checkpatch is checking for the ternary operators at the beginning of the
lines after the initial break like the following:

type var = FOO
           ? BAR
           : FEE;

Change checkpatch so that it is checking fot the correct breaking of ternary
operators used in networking variable declaration/initialization.

Signed-off-by: Dave Ertman <davidx.m.ertman@intel.com>
Tested-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
---
 scripts/checkpatch.pl | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34eb216..baabf1c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2269,12 +2269,13 @@ sub process {
 		if ($realfile =~ m@^(drivers/net/|net/)@ &&
 		    $prevline =~ /^\+\s+$Declare\s+$Ident/ &&
 		    !($prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
-		      $prevline =~ /(?:\{\s*|\\)$/) &&		#extended lines
+		      $prevline =~ /(?:\{\s*|\\)$/ ||		#extended lines
+		      $prevline =~ /(?:[\?\:])$/) &&		#ternary ops
 		    $sline =~ /^\+\s+/ &&			#Not at char 1
 		    !($sline =~ /^\+\s+$Declare/ ||
 		      $sline =~ /^\+\s+$Ident\s+$Ident/ ||	#eg: typedef foo
 		      $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ ||
-		      $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(])/ ||
+		      $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\(])/ ||
 		      $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) {
 			WARN("SPACING",
 			     "networking uses a blank line after declarations\n" . $hereprev);
-- 
1.9.0

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

* Re: [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break
  2014-05-10  4:41 [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break Jeff Kirsher
@ 2014-05-10  4:47 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2014-05-10  4:47 UTC (permalink / raw)
  To: Jeff Kirsher; +Cc: akpm, David Ertman, linux-kernel, netdev

On Fri, 2014-05-09 at 21:41 -0700, Jeff Kirsher wrote:
> From: David Ertman <davidx.m.ertman@intel.com>

Hey David.

> Using the intuitive breaking of a ternary operator used in the
> initialization of a variable in its declaration:
> 
> type var = FOO ?
>            BAR :
>            FEE;
[]
> type var = FOO
>            ? BAR
>            : FEE;
> 
> Change checkpatch so that it is checking fot the correct breaking of ternary
> operators used in networking variable declaration/initialization.

There is no "correct" breaking for ternary operators.
Both should be acceptable.

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

end of thread, other threads:[~2014-05-10  4:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-10  4:41 [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break Jeff Kirsher
2014-05-10  4:47 ` Joe Perches

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).