mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Guenter Roeck <linux@roeck-us.net>,
	Andrew Morton <akpm@linux-foundation.org>
Cc: Josh Triplett <josh@joshtriplett.org>,
	Andy Whitcroft <apw@canonical.com>,
	ksummit-2013-discuss@lists.linuxfoundation.org,
	Linus Torvalds <torvalds@linux-foundation.org>,
	linux-kernel@vger.kernel.org,
	Mauro Carvalho Chehab <m.chehab@samsung.com>
Subject: [PATCH] checkpatch: Report missing spaces around trigraphs with --strict
Date: Mon, 02 Sep 2013 15:14:46 -0700	[thread overview]
Message-ID: <1378160086.1953.129.camel@joe-AO722> (raw)
In-Reply-To: <5224EF32.5060104@roeck-us.net>

Spaces around trigraphs are specified by CodingStyle
but checkpatch is currently silent about them because
there are many current instances without them.

Make missing spaces around trigraphs a --strict message.

Signed-off-by: Joe Perches <joe@perches.com>
---
> Oddly enough, the opposite is true as well. 3.1, spaces around binary
> and ternary operators, is for example not enforced, presumably because
> it would generate too many positives. Since I like that rule, I have
> my private version of checkpatch.pl which does check for it. After all,
> it _is_ a CodingStyle rule.

 scripts/checkpatch.pl | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 9bb056c..bb34c11 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2817,7 +2817,7 @@ sub process {
 				\+=|-=|\*=|\/=|%=|\^=|\|=|&=|
 				=>|->|<<|>>|<|>|=|!|~|
 				&&|\|\||,|\^|\+\+|--|&|\||\+|-|\*|\/|%|
-				\?|:
+				\?:|\?|:
 			}x;
 			my @elements = split(/($ops|;)/, $opline);
 
@@ -3040,15 +3040,13 @@ sub process {
 					    	$ok = 1;
 					}
 
-					# Ignore ?:
-					if (($opv eq ':O' && $ca =~ /\?$/) ||
-					    ($op eq '?' && $cc =~ /^:/)) {
-					    	$ok = 1;
-					}
-
+					# messages are ERROR, but ?: are CHK
 					if ($ok == 0) {
-						if (ERROR("SPACING",
-							  "spaces required around that '$op' $at\n" . $hereptr)) {
+						my $msg_type = \&ERROR;
+						$msg_type = \&CHK if (($op eq '?:' || $op eq '?' || $op eq ':') && $ctx =~ /VxV/);
+
+						if (&{$msg_type}("SPACING",
+								 "spaces required around that '$op' $at\n" . $hereptr)) {
 							$good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " ";
 							if (defined $fix_elements[$n + 2]) {
 								$fix_elements[$n + 2] =~ s/^\s+//;



  reply	other threads:[~2013-09-02 22:14 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <9976.1378132260@warthog.procyon.org.uk>
2013-09-02 16:10 ` Making changes to the Coding Style Joe Perches
2013-09-02 18:15   ` [Ksummit-2013-discuss] " Josh Triplett
2013-09-02 18:19     ` [PATCH] checkpatch: Add comment about updating Documentation/CodingStyle Josh Triplett
2013-09-02 18:39       ` [Ksummit-2013-discuss] " Mauro Carvalho Chehab
2013-09-02 18:59         ` Joe Perches
2013-09-02 19:48           ` Mauro Carvalho Chehab
2013-09-02 19:50           ` Josh Triplett
2013-09-02 20:04             ` Guenter Roeck
2013-09-02 22:14               ` Joe Perches [this message]
2013-09-02 23:15                 ` [PATCH] checkpatch: Report missing spaces around trigraphs with --strict Josh Triplett
2013-09-02 23:54                   ` Joe Perches
2013-09-03  0:32                     ` Josh Triplett
2013-09-02 20:50           ` [Ksummit-2013-discuss] [PATCH] checkpatch: Add comment about updating Documentation/CodingStyle David Howells
2013-09-02 21:11             ` Joe Perches
2013-09-03  0:26               ` Shilong Wang
2013-09-03  0:36                 ` Josh Triplett
2013-09-03  1:21                   ` Fengguang Wu
2013-09-03  0:39               ` Fengguang Wu
2013-09-03  0:47                 ` Joe Perches
2013-09-03  1:35                   ` Fengguang Wu
2013-09-03  1:34                 ` Josh Triplett
2013-09-03  1:52                   ` Joe Perches
2013-09-03  2:12                     ` Josh Triplett
2013-09-03  2:21                       ` Joe Perches
2013-09-03  2:46                     ` Fengguang Wu
2013-09-03  3:16                       ` Josh Triplett
2013-09-03  3:22                         ` Fengguang Wu
2013-09-03 18:09                 ` Bjorn Helgaas
2013-09-04  0:49                   ` Fengguang Wu
2013-09-02 22:08             ` Josh Triplett
2013-09-02 19:34         ` Josh Triplett
2013-09-02 19:40       ` [PATCH] checkpatch: Add warning about submitting patches using --file Joe Perches
2013-09-02 19:54         ` [Ksummit-2013-discuss] " Mauro Carvalho Chehab
2013-09-02 19:56         ` Josh Triplett
2013-09-02 20:37         ` Dan Carpenter
2013-09-02 21:51           ` Joe Perches
2013-09-17 21:33           ` Andrew Morton

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=1378160086.1953.129.camel@joe-AO722 \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=josh@joshtriplett.org \
    --cc=ksummit-2013-discuss@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=m.chehab@samsung.com \
    --cc=torvalds@linux-foundation.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

all inboxes | Powered by JetHome®