diff mbox

[1.0] checkpatch.pl: fix CAST detection

Message ID 1322213056-16612-1-git-send-email-pbonzini@redhat.com
State New
Headers show

Commit Message

Paolo Bonzini Nov. 25, 2011, 9:24 a.m. UTC
From: Florian Mickler <florian@mickler.org>

We should only claim that something is a cast if we did not encouter a
token before, that did set av_pending.

This fixes the operator * in the line below to be detected as binary (vs
unary).

kmalloc(sizeof(struct alphatrack_ocmd) * true_size, GFP_KERNEL);

Reported-by: Peter Chubb <nicta.com.au>
Signed-off-by: Florian Mickler <florian@mickler.org>
(cherry-picked from Linux kernel commit c023e4734c3e8801e0ecb5e81b831d42a374d861)
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Cc: Blue Swirl <blauwirbel@gmail.com>
---
 scripts/checkpatch.pl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Comments

Blue Swirl Nov. 26, 2011, 9:52 a.m. UTC | #1
Thanks, applied.

On Fri, Nov 25, 2011 at 09:24, Paolo Bonzini <pbonzini@redhat.com> wrote:
> From: Florian Mickler <florian@mickler.org>
>
> We should only claim that something is a cast if we did not encouter a
> token before, that did set av_pending.
>
> This fixes the operator * in the line below to be detected as binary (vs
> unary).
>
> kmalloc(sizeof(struct alphatrack_ocmd) * true_size, GFP_KERNEL);
>
> Reported-by: Peter Chubb <nicta.com.au>
> Signed-off-by: Florian Mickler <florian@mickler.org>
> (cherry-picked from Linux kernel commit c023e4734c3e8801e0ecb5e81b831d42a374d861)
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> Cc: Blue Swirl <blauwirbel@gmail.com>
> ---
>  scripts/checkpatch.pl |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 36d6851..ddd27d8 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -859,7 +859,7 @@ sub annotate_values {
>                                $av_preprocessor = 0;
>                        }
>
> -               } elsif ($cur =~ /^(\(\s*$Type\s*)\)/) {
> +               } elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
>                        print "CAST($1)\n" if ($dbg_values > 1);
>                        push(@av_paren_type, $type);
>                        $type = 'C';
> --
> 1.7.7.1
>
>
diff mbox

Patch

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 36d6851..ddd27d8 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -859,7 +859,7 @@  sub annotate_values {
 				$av_preprocessor = 0;
 			}
 
-		} elsif ($cur =~ /^(\(\s*$Type\s*)\)/) {
+		} elsif ($cur =~ /^(\(\s*$Type\s*)\)/ && $av_pending eq '_') {
 			print "CAST($1)\n" if ($dbg_values > 1);
 			push(@av_paren_type, $type);
 			$type = 'C';