From: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
To: joe@perches.com, akpm@linux-foundation.org
Cc: David Ertman <davidx.m.ertman@intel.com>,
linux-kernel@vger.kernel.org, netdev@vger.kernel.org,
Jeff Kirsher <jeffrey.t.kirsher@intel.com>
Subject: [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break
Date: Fri, 9 May 2014 21:41:51 -0700 [thread overview]
Message-ID: <1399696911-6550-1-git-send-email-jeffrey.t.kirsher@intel.com> (raw)
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
next reply other threads:[~2014-05-10 4:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-10 4:41 Jeff Kirsher [this message]
2014-05-10 4:47 ` [PATCH] checkpatch.pl: Fix checkpatch false positive due to ternary operator break Joe Perches
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1399696911-6550-1-git-send-email-jeffrey.t.kirsher@intel.com \
--to=jeffrey.t.kirsher@intel.com \
--cc=akpm@linux-foundation.org \
--cc=davidx.m.ertman@intel.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).