[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1213272362-19457-4-git-send-email-apw@shadowen.org>
Date: Thu, 12 Jun 2008 13:05:42 +0100
From: Andy Whitcroft <apw@...dowen.org>
To: Andrew Morton <akpm@...l.org>
Cc: Randy Dunlap <rdunlap@...otime.net>,
Joel Schopp <jschopp@...tin.ibm.com>,
Ingo Molnar <mingo@...e.hu>, linux-kernel@...r.kernel.org,
Andy Whitcroft <apw@...dowen.org>
Subject: [PATCH 03/23] checkpatch: types: some types may also be identifiers
Some types such as typedefs may overlap real identifiers. Be more
targetted about when a type can really exist. Where it cannot let it be
an identifier. This prevents false reporting of the minus '-' in unary
context in the following:
foo[bar->bool - 1];
Signed-off-by: Andy Whitcroft <apw@...dowen.org>
---
scripts/checkpatch.pl | 11 ++++++-----
1 files changed, 6 insertions(+), 5 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 83ae37b..5420db6 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -171,6 +171,7 @@ our @modifierList = (
sub build_types {
my $mods = "(?: \n" . join("|\n ", @modifierList) . "\n)";
my $all = "(?: \n" . join("|\n ", @typeList) . "\n)";
+ $Modifier = qr{(?:$Attribute|$Sparse|$mods)};
$NonptrType = qr{
(?:const\s+)?
(?:$mods\s+)?
@@ -178,15 +179,14 @@ sub build_types {
(?:typeof|__typeof__)\s*\(\s*\**\s*$Ident\s*\)|
(?:${all}\b)
)
- (?:\s+$Sparse|\s+const)*
+ (?:\s+$Modifier|\s+const)*
}x;
$Type = qr{
$NonptrType
(?:\s*\*+\s*const|\s*\*+|(?:\s*\[\s*\])+)?
- (?:\s+$Inline|\s+$Sparse|\s+$Attribute|\s+$mods)*
+ (?:\s+$Inline|\s+$Modifier)*
}x;
$Declare = qr{(?:$Storage\s+)?$Type};
- $Modifier = qr{(?:$Attribute|$Sparse|$mods)};
}
build_types();
@@ -715,7 +715,7 @@ sub annotate_values {
$av_preprocessor = 0;
}
- } elsif ($cur =~ /^($Type)/) {
+ } elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\))/) {
print "DECLARE($1)\n" if ($dbg_values > 1);
$type = 'T';
@@ -800,8 +800,9 @@ sub annotate_values {
print "PAREN('$1')\n" if ($dbg_values > 1);
}
- } elsif ($cur =~ /^($Ident)\(/o) {
+ } elsif ($cur =~ /^($Ident)\s*\(/o) {
print "FUNC($1)\n" if ($dbg_values > 1);
+ $type = 'V';
$av_pending = 'V';
} elsif ($cur =~ /^($Ident|$Constant)/o) {
--
1.5.6.rc0.140.ga9675
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists