* [Qemu-devel] Who maintains checkpatch.pl now?
@ 2011-11-25 3:17 Peter Chubb
2011-11-25 9:24 ` [Qemu-devel] [PATCH 1.0] checkpatch.pl: fix CAST detection Paolo Bonzini
2011-11-25 9:26 ` [Qemu-devel] Who maintains checkpatch.pl now? Paolo Bonzini
0 siblings, 2 replies; 4+ messages in thread
From: Peter Chubb @ 2011-11-25 3:17 UTC (permalink / raw)
To: Anthony Liguori, qemu-devel
Who maintainss checkpatch.pl now?
checkpatch.pl says to look for CHECKPATCH in the MAINTAINERS file, but
that entry isn't there.
The issue I'm encountering is that sizeof is not a function, but an
operator, that takes as its operand either a variable or a cast. As
such there needn't be any parentheses (if the operand is a variable),
and there should a space before the cast.
In the QEMU code at present, the use of whitespace around sizeof varies
from file to file;
checkpatch.pl complains about
sizeof (struct foo)
WARNING: space prohibited between function name and open parenthesis '('
If I fix the problem as in the appended patch, I start seeing other
complaints:
ERROR: space prohibited after that '*' (ctx:WxW)
+#define PRIO_PER_WORD (sizeof (uint32_t) * 8 / 4)
^
Index: qemu-working/scripts/checkpatch.pl
===================================================================
--- qemu-working.orig/scripts/checkpatch.pl 2011-11-10 10:16:43.215022488 +1100
+++ qemu-working/scripts/checkpatch.pl 2011-11-25 14:02:30.908358997 +1100
@@ -1953,21 +1953,21 @@ sub process {
}
# check for spaces between functions and their parentheses.
while ($line =~ /($Ident)\s+\(/g) {
my $name = $1;
my $ctx_before = substr($line, 0, $-[1]);
my $ctx = "$ctx_before$name";
# Ignore those directives where spaces _are_ permitted.
if ($name =~ /^(?:
- if|for|while|switch|return|case|
+ if|for|while|switch|return|case|sizeof|
volatile|__volatile__|
__attribute__|format|__extension__|
asm|__asm__)$/x)
{
# cpp #define statements have non-optional spaces, ie
# if there is a space between the name and the open
# parenthesis it is simply not a parameter group.
} elsif ($ctx_before =~ /^.\s*\#\s*define\s*$/) {
--
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au
http://www.ertos.nicta.com.au ERTOS within National ICT Australia
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Qemu-devel] [PATCH 1.0] checkpatch.pl: fix CAST detection
2011-11-25 3:17 [Qemu-devel] Who maintains checkpatch.pl now? Peter Chubb
@ 2011-11-25 9:24 ` Paolo Bonzini
2011-11-26 9:52 ` Blue Swirl
2011-11-25 9:26 ` [Qemu-devel] Who maintains checkpatch.pl now? Paolo Bonzini
1 sibling, 1 reply; 4+ messages in thread
From: Paolo Bonzini @ 2011-11-25 9:24 UTC (permalink / raw)
To: qemu-devel; +Cc: Blue Swirl, peter.chubb
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
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] Who maintains checkpatch.pl now?
2011-11-25 3:17 [Qemu-devel] Who maintains checkpatch.pl now? Peter Chubb
2011-11-25 9:24 ` [Qemu-devel] [PATCH 1.0] checkpatch.pl: fix CAST detection Paolo Bonzini
@ 2011-11-25 9:26 ` Paolo Bonzini
1 sibling, 0 replies; 4+ messages in thread
From: Paolo Bonzini @ 2011-11-25 9:26 UTC (permalink / raw)
To: Peter Chubb; +Cc: Blue Swirl, Anthony Liguori, qemu-devel
On 11/25/2011 04:17 AM, Peter Chubb wrote:
> If I fix the problem as in the appended patch, I start seeing other
> complaints:
>
> ERROR: space prohibited after that '*' (ctx:WxW)
> +#define PRIO_PER_WORD (sizeof (uint32_t) * 8 / 4)
> ^
This was fixed recently in upstream Linux checkpatch, I posted a patch.
I'm ambivalent about the patch below; it's fine but perhaps we should
fix sizeof occurrences followed by a space instead. But it's just a
warning.
Blue Swirl, can you please add yourself as checkpatch maintainer (in Odd
Fixes status, I guess)?
Paolo
> Index: qemu-working/scripts/checkpatch.pl
> ===================================================================
> --- qemu-working.orig/scripts/checkpatch.pl 2011-11-10 10:16:43.215022488 +1100
> +++ qemu-working/scripts/checkpatch.pl 2011-11-25 14:02:30.908358997 +1100
> @@ -1953,21 +1953,21 @@ sub process {
> }
>
> # check for spaces between functions and their parentheses.
> while ($line =~ /($Ident)\s+\(/g) {
> my $name = $1;
> my $ctx_before = substr($line, 0, $-[1]);
> my $ctx = "$ctx_before$name";
>
> # Ignore those directives where spaces_are_ permitted.
> if ($name =~ /^(?:
> - if|for|while|switch|return|case|
> + if|for|while|switch|return|case|sizeof|
> volatile|__volatile__|
> __attribute__|format|__extension__|
> asm|__asm__)$/x)
> {
>
> # cpp #define statements have non-optional spaces, ie
> # if there is a space between the name and the open
> # parenthesis it is simply not a parameter group.
> } elsif ($ctx_before =~ /^.\s*\#\s*define\s*$/) {
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [Qemu-devel] [PATCH 1.0] checkpatch.pl: fix CAST detection
2011-11-25 9:24 ` [Qemu-devel] [PATCH 1.0] checkpatch.pl: fix CAST detection Paolo Bonzini
@ 2011-11-26 9:52 ` Blue Swirl
0 siblings, 0 replies; 4+ messages in thread
From: Blue Swirl @ 2011-11-26 9:52 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: peter.chubb, qemu-devel
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
>
>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2011-11-26 9:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-25 3:17 [Qemu-devel] Who maintains checkpatch.pl now? Peter Chubb
2011-11-25 9:24 ` [Qemu-devel] [PATCH 1.0] checkpatch.pl: fix CAST detection Paolo Bonzini
2011-11-26 9:52 ` Blue Swirl
2011-11-25 9:26 ` [Qemu-devel] Who maintains checkpatch.pl now? Paolo Bonzini
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).