From: Andy Whitcroft <apw@shadowen.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Ingo Molnar <mingo@elte.hu>,
linux-kernel@vger.kernel.org, Andy Whitcroft <apw@shadowen.org>
Subject: [PATCH 04/13] checkpatch: allow parentheses on return for comparisons
Date: Sun, 7 Dec 2008 18:30:41 +0000 [thread overview]
Message-ID: <1228674650-24392-5-git-send-email-apw@shadowen.org> (raw)
In-Reply-To: <1228674650-24392-1-git-send-email-apw@shadowen.org>
From: Andy Whitcroft <apw@canonical.com>
It seems to be a common idiom to include braces on conditionals in all
contexts including return. Allow this exception to the return is not
a function checks. Reported by Kay Sievers.
Cc: Kay Sievers <kay.sievers@vrfy.org>
Signed-off-by: Andy Whitcroft <apw@canonical.com>
---
scripts/checkpatch.pl | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b953c76..5c7fd1a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -127,6 +127,7 @@ our $Lval = qr{$Ident(?:$Member)*};
our $Constant = qr{(?:[0-9]+|0x[0-9a-fA-F]+)[UL]*};
our $Assignment = qr{(?:\*\=|/=|%=|\+=|-=|<<=|>>=|&=|\^=|\|=|=)};
+our $Compare = qr{<=|>=|==|!=|<|>};
our $Operators = qr{
<=|>=|==|!=|
=>|->|<<|>>|<|>|!|~|
@@ -1983,9 +1984,9 @@ sub process {
my $spacing = $1;
my $value = $2;
- # Flatten any parentheses and braces
+ # Flatten any parentheses
$value =~ s/\)\(/\) \(/g;
- while ($value =~ s/\([^\(\)]*\)/1/) {
+ while ($value !~ /(?:$Ident|-?$Constant)\s*$Compare\s*(?:$Ident|-?$Constant)/ && $value =~ s/\([^\(\)]*\)/1/) {
}
if ($value =~ /^(?:$Ident|-?$Constant)$/) {
--
1.6.0.4.911.gc990
next prev parent reply other threads:[~2008-12-07 18:32 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-12-07 18:30 [PATCH 00/13] update checkpatch to version 0.26 Andy Whitcroft
2008-12-07 18:30 ` [PATCH 01/13] checkpatch: update MAINTAINERS entry Andy Whitcroft
2008-12-07 18:30 ` [PATCH 02/13] checkpatch: update copyrights Andy Whitcroft
2008-12-07 18:30 ` [PATCH 03/13] checkpatch: Add warning for p0-patches Andy Whitcroft
2008-12-07 18:30 ` Andy Whitcroft [this message]
2008-12-07 18:30 ` [PATCH 05/13] checkpatch: try to catch missing VMLINUX_SYMBOL() in vmlinux.lds.h Andy Whitcroft
2008-12-07 18:30 ` [PATCH 06/13] checkpatch: loosen spacing on typedef function checks Andy Whitcroft
2008-12-07 18:30 ` [PATCH 07/13] checkpatch: fix continuation detection when handling spacing on operators Andy Whitcroft
2008-12-07 18:30 ` [PATCH 08/13] checkpatch: track #ifdef/#else/#endif when tracking blocks Andy Whitcroft
2008-12-07 18:30 ` [PATCH 09/13] checkpatch: do not report nr_static as a static declaration Andy Whitcroft
2008-12-07 18:30 ` [PATCH 10/13] checkpatch: ensure we actually detect if assignments split across lines Andy Whitcroft
2008-12-07 18:30 ` [PATCH 11/13] checkpatch: struct file_operations should normally be const Andy Whitcroft
2008-12-09 0:30 ` Steven Rostedt
2008-12-07 18:30 ` [PATCH 12/13] checkpatch: fix the perlcritic errors Andy Whitcroft
2008-12-07 18:30 ` [PATCH 13/13] checkpatch: version: 0.26 Andy Whitcroft
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=1228674650-24392-5-git-send-email-apw@shadowen.org \
--to=apw@shadowen.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mingo@elte.hu \
/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®