lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Fri,  9 May 2014 21:41:51 -0700
From:	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
To:	joe@...ches.com, akpm@...ux-foundation.org
Cc:	David Ertman <davidx.m.ertman@...el.com>,
	linux-kernel@...r.kernel.org, netdev@...r.kernel.org,
	Jeff Kirsher <jeffrey.t.kirsher@...el.com>
Subject: [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break

From: David Ertman <davidx.m.ertman@...el.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@...el.com>
Tested-by: Aaron Brown <aaron.f.brown@...el.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@...el.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

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ