From: Joe Perches <joe@perches.com>
To: Dan Carpenter <dan.carpenter@oracle.com>,
Andrew Morton <akpm@linux-foundation.org>
Cc: Aldo Iljazi <mail@aldo.io>,
Samuel Thibault <samuel.thibault@ens-lyon.org>,
w.d.hubbs@gmail.com, chris@the-brannons.com, kirk@reisers.ca,
gregkh@linuxfoundation.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>
Subject: [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line
Date: Wed, 04 Dec 2013 05:47:47 -0800 [thread overview]
Message-ID: <1386164867.30493.70.camel@joe-AO722> (raw)
In-Reply-To: <20131204082137.GR5443@mwanda>
The "space before a non-naked semicolon" test has
unwanted output when used in "for ( ;; )" loops.
Make the test work only on end-of-line statement
termination semicolons.
Signed-off-by: Joe Perches <joe@perches.com>
---
On Wed, 2013-12-04 at 11:21 +0300, Dan Carpenter wrote:
> You and I generally agree on style preferences...
True, and I think that's a good thing.
> I think the warning
> should be limited to grep " ;$".
Look at the output of:
$ git grep " ;" -- "*.[ch]" | grep -w for
...
The "| wc -l" output above in -next is
1407
Which of those should not be warned on?
$ git grep " ;" -- "*.[ch]" | grep -P "\bfor\s*\(\s+;" | wc -l
211
I think all of the uses like "for ( ; expression; expression)"
are unbalanced and should be avoided.
<I go off and look at checkpatch output>
Oh. checkpatch doesn't complain about spacing around
semicolon with for loops here. This error is a separate
test that looks only for space before semicolon.
So, we agree after all.
This test should look only for space before end-of-statement
semicolons at EOL.
This has still has false positives with multi-line fors like:
for ( ; expression ;
expression);
scripts/checkpatch.pl | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 38be5d5..d26eac6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3131,7 +3131,7 @@ sub process {
}
# check for whitespace before a non-naked semicolon
- if ($line =~ /^\+.*\S\s+;/) {
+ if ($line =~ /^\+.*\S\s+;\s*$/) {
if (WARN("SPACING",
"space prohibited before semicolon\n" . $herecurr) &&
$fix) {
next prev parent reply other threads:[~2013-12-04 13:47 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-12-03 20:08 [PATCH] Staging: speakup: synth.c: removed a space Aldo Iljazi
2013-12-03 22:17 ` Samuel Thibault
2013-12-04 4:35 ` Aldo Iljazi
2013-12-04 7:38 ` Dan Carpenter
2013-12-04 7:45 ` Joe Perches
2013-12-04 8:21 ` Dan Carpenter
2013-12-04 13:47 ` Joe Perches [this message]
2013-12-05 7:41 ` [PATCH -next] checkpatch: Warn only on "space before semicolon" at end of line Dan Carpenter
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=1386164867.30493.70.camel@joe-AO722 \
--to=joe@perches.com \
--cc=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=chris@the-brannons.com \
--cc=dan.carpenter@oracle.com \
--cc=devel@driverdev.osuosl.org \
--cc=gregkh@linuxfoundation.org \
--cc=kirk@reisers.ca \
--cc=linux-kernel@vger.kernel.org \
--cc=mail@aldo.io \
--cc=samuel.thibault@ens-lyon.org \
--cc=w.d.hubbs@gmail.com \
/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®