From: Florian Mickler <florian@mickler.org>
To: Andy Whitcroft <apw@canonical.com>
Cc: Audun Hoem <audun.hoem@gmail.com>,
linux-kernel <linux-kernel@vger.kernel.org>,
Florian Mickler <florian@mickler.org>
Subject: [PATCH] checkpatch.pl: fix CAST detection to not screw with parens handling
Date: Wed, 3 Nov 2010 13:04:33 +0100 [thread overview]
Message-ID: <1288785873-16519-1-git-send-email-florian@mickler.org> (raw)
In-Reply-To: <AANLkTimA1d88FwGGE-BW4WvyuaFB7xewN_ubko+kj2+X@mail.gmail.com>
Casts have to be handled after the last type that is followed by an
opening parenthesis is handled.
On Tue, 2 Nov 2010 23:57:36 +0100
Audun Hoem <audun.hoem@gmail.com> wrote:
> I have stumbled about a bug in checkpatch.pl while working on some
> code in drivers/staging. It seems to get confused when confronted with
> asterisks. For example, this snippe:
>
> kmalloc(sizeof(struct alphatrack_ocmd) * true_size, GFP_KERNEL);
>
> Here the asterisk is in it's binary form, obviously, and performs a
> multiplication, however checkpatch reports this:
>
> drivers/staging/frontier/alphatrack.c:772: ERROR: space prohibited
> after that '*' (ctx:WxW)
>
> So it's obviously thinking it's the unary operator, which should only
> be preceded by a variable name or another unary operator such as ++.
Reported-By: Audun Hoem <audun.hoem@gmail.com>
Signed-off-by: Florian Mickler <florian@mickler.org>
---
scripts/checkpatch.pl | 11 +++++++----
1 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 90b54d4..c1cbb09 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -859,10 +859,6 @@ sub annotate_values {
$av_preprocessor = 0;
}
- } elsif ($cur =~ /^(\(\s*$Type\s*)\)/) {
- print "CAST($1)\n" if ($dbg_values > 1);
- push(@av_paren_type, $type);
- $type = 'C';
} elsif ($cur =~ /^($Type)\s*(?:$Ident|,|\)|\(|\s*$)/) {
print "DECLARE($1)\n" if ($dbg_values > 1);
@@ -963,6 +959,13 @@ sub annotate_values {
$type = 'V';
$av_pending = 'V';
+ } elsif ($cur =~ /^(\(\s*$Type\s*)\)/) {
+ #casts handled after last type that opens a brace
+ #is handled, else it screws up the parens handling
+ print "CAST($1)\n" if ($dbg_values > 1);
+ push(@av_paren_type, $type);
+ $type = 'C';
+
} elsif ($cur =~ /^($Ident\s*):(?:\s*\d+\s*(,|=|;))?/) {
if (defined $2 && $type eq 'C' || $type eq 'T') {
$av_pend_colon = 'B';
--
1.7.3.1
next prev parent reply other threads:[~2010-11-03 12:04 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-11-02 22:57 Bug in checkpatch.pl Audun Hoem
2010-11-03 12:04 ` Florian Mickler [this message]
2010-11-03 15:20 ` [PATCH] checkpatch.pl: fix CAST detection to not screw with parens handling Florian Mickler
2010-11-03 15:26 ` Audun Hoem
2010-11-03 16:07 ` Florian Mickler
2010-11-17 7:30 ` Florian Mickler
2010-11-23 14:15 ` 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=1288785873-16519-1-git-send-email-florian@mickler.org \
--to=florian@mickler.org \
--cc=apw@canonical.com \
--cc=audun.hoem@gmail.com \
--cc=linux-kernel@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).