checkpatch: fix false positive on casting to double pointer
PATCH 1/1 checkpatch: fix false positive on casting to double pointer
--- scripts/checkpatch.pl | 4 +++- tests/t/t9190-double-pointers | 6 ++++++ 2 files changed, 9 insertions(+), 1 deletions(-) create mode 100644 tests/t/t9190-double-pointers
scripts/checkpatch.pl +3 -1
@@ -1982,7 +1982,9 @@ sub process { $op eq '*' or $op eq '/' or $op eq '%') { - if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { + if ($op eq '*' && $cc =~ /^\*/) { + # double pointer is ok + } elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { ERROR("need consistent spacing around '$op' $at\n" . $hereptr); }
tests/t/t9190-double-pointers new file +6 -0
@@ -0,0 +1,6 @@ +pass "foo **x;" +pass "x = **y;" +pass "x = (foo **)y;" + +err='"(foo ** )" should be "(foo **)"' +fail "x = (foo ** )y;" "$err"
Signature · 1 line
1.6.0.3
Andy Whitcroft
maintainerQuoted 14 lines · Scott J. Goldman
Signed-off-by Scott J. Goldman <[email protected]>---
scripts/checkpatch.pl | 4 +++-
tests/t/t9190-double-pointers | 6 ++++++2 files changed, 9 insertions(+), 1 deletions(-)create mode 100644 tests/t/t9190-double-pointers
scripts/checkpatch.pl +0
-0@@ -1982,7 +1982,9 @@ sub process {$op eq '*' or $op eq '/' or
Quoted 8 lines
$op eq '%')
{
- if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) {
+ if ($op eq '*' && $cc =~ /^\*/) {
+ # double pointer is ok
+ } elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { ERROR("need consistent spacing around '$op' $at\n" . $hereptr);
Hrm, I would expect any number of levels of pointers to be detected already correctly.
/me goes check.
-apw
Andy Whitcroft
maintainerQuoted 4 lines
Hrm, I would expect any number of levels of pointers to be detected already correctly.
/me goes check.
We already have tests for both types which are passing generally, in t730-* and t7020-* so I think this is more likely a failure to detect the type as a type. If you could send on the sample that triggers this I will have a look.
-apw
Quoted 11 lines
Quoted 4 lines
Hrm, I would expect any number of levels of pointers to be detected already correctly.
/me goes check.
We already have tests for both types which are passing generally, in t730-* and t7020-* so I think this is more likely a failure to detect the type as a type. If you could send on the sample that triggers this I will have a look.
-apw
Yikes! you're right, lousy tests on my part. The part of my patch that triggered it was:
+ return snmp_fold_field((void __percpu **)net->mib.udp_statistics,
+ UDP_MIB_RCVBUFERRORS) +
+ snmp_fold_field((void __percpu **)net->mib.udplite_statistics,
+ UDP_MIB_RCVBUFERRORS);
ERROR: need consistent spacing around '*' (ctx:WxO) #115: FILE: drivers/net/vmxnet3/vmxnet3_drv.c:1784:
+ return snmp_fold_field((void __percpu **)net->mib.udp_statistics,
^
Maybe caused by the __percpu attr?
PATCH 1/1 checkpatch: fix false positives involving __percpu attribute
In reply to Andy Whitcroft--- scripts/checkpatch.pl | 3 ++- tests/t/t7005-attr-matcher | 2 ++ 2 files changed, 4 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +2 -1
@@ -150,7 +150,8 @@ our $Attribute = qr{ ____cacheline_aligned| ____cacheline_aligned_in_smp| ____cacheline_internodealigned_in_smp| - __weak + __weak| + __percpu }x; our $Modifier; our $Inline = qr{inline|__always_inline|noinline};
tests/t/t7005-attr-matcher +2 -0
@@ -31,6 +31,8 @@ attr "____cacheline_internodealigned_in_smp" attr "__weak" +attr "__percpu" + attr "__user" attr "__kernel" attr "__force"
Signature · 1 line
1.6.0.3