checkpatch: Fixing two cases of false positives in checkpatch.pl
cover checkpatch: Fixing two cases of false positives in checkpatch.pl
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definition
scripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Signature · 1 line
2.4.3
PATCH 1/2 checkpatch: Eliminate false positive in case of comma-space-square bracket
Previously, an error was printed in cases such as:
{ [1] = 5, [2] = 6 }
The space passed OK after a curly brace, but not after a comma. Now, a space before a square bracket is allowed, if a comma comes before it.
--- scripts/checkpatch.pl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
scripts/checkpatch.pl +3 -1
@@ -1715,11 +1715,13 @@ sub process { # 1. with a type on the left -- int [] a; # 2. at the beginning of a line for slice initialisers -- [0...10] = 5, # 3. inside a curly brace -- = { [0...10] = 5 } +# 4. after a comma -- [1] = 5, [2] = 6 while ($line =~ /(.*?\s)\[/g) { my ($where, $prefix) = ($-[1], $1); if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) && - $prefix !~ /{\s+$/) { + $prefix !~ /{\s+$/ && + $prefix !~ /,\s+$/) { ERROR("space prohibited before open square bracket '['\n" . $herecurr); } }
Signature · 1 line
2.4.3
PATCH 2/2 checkpatch: Eliminate false positive in case of space before square bracket in a definition
In reply to Leonid BlochNow, macro definition such as "#define abc(x) [x] = y" should pass without an error.
--- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+)
scripts/checkpatch.pl +2 -0
@@ -1716,11 +1716,13 @@ sub process { # 2. at the beginning of a line for slice initialisers -- [0...10] = 5, # 3. inside a curly brace -- = { [0...10] = 5 } # 4. after a comma -- [1] = 5, [2] = 6 +# 5. in a macro definition -- #define abc(x) [x] = y while ($line =~ /(.*?\s)\[/g) { my ($where, $prefix) = ($-[1], $1); if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) && $prefix !~ /{\s+$/ && + $prefix !~ /\#\s*define[^(]*\([^)]*\)\s+$/ && $prefix !~ /,\s+$/) { ERROR("space prohibited before open square bracket '['\n" . $herecurr); }
Signature · 1 line
2.4.3
Re: [Qemu-devel] [PATCH 2/2] checkpatch: Eliminate false positive in case of space before square bracket in a definition
Quoted 2 lines · Leonid Bloch
Now, macro definition such as "#define abc(x) [x] = y" should pass without an error.
Do we even have macros like that? Without context, it seems like that macro definition is under-parenthesized, and that you wouldn't want to use abc(x) in an arbitrary expression for fear of precedence rules causing nasty surprises.
Quoted 25 lines
Signed-off-by Leonid Bloch <[email protected]>--- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+)scripts/checkpatch.pl +2
-0@@ -1716,11 +1716,13 @@ sub process { # 2. at the beginning of a line for slice initialisers -- [0...10] = 5, # 3. inside a curly brace -- = { [0...10] = 5 } # 4. after a comma -- [1] = 5, [2] = 6 +# 5. in a macro definition -- #define abc(x) [x] = y while ($line =~ /(.*?\s)\[/g) { my ($where, $prefix) = ($-[1], $1); if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) && $prefix !~ /{\s+$/ && + $prefix !~ /\#\s*define[^(]*\([^)]*\)\s+$/ && $prefix !~ /,\s+$/) { ERROR("space prohibited before open square bracket '['\n" . $herecurr); }
Signature · 2 lines
Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Re: [Qemu-devel] [PATCH 2/2] checkpatch: Eliminate false positive in case of space before square bracket in a definition
Quoted 9 lines · Eric Blake
Quoted 2 lines · Leonid Bloch
Now, macro definition such as "#define abc(x) [x] = y" should pass without an error.
Do we even have macros like that? Without context, it seems like that macro definition is under-parenthesized, and that you wouldn't want to use abc(x) in an arbitrary expression for fear of precedence rules causing nasty surprises.
Yes, for example, in hw/net/e1000.c, there is:
#define getreg(x) [x] = mac_readreg (l: 1209)
#define putreg(x) [x] = mac_writereg (l: 1230)
This issue came up in the latest patches I've sent to e1000, and in the RFC patches we have sent for e1000e.
Leonid.
Quoted 31 lines
Quoted 16 lines
Signed-off-by Leonid Bloch <[email protected]>--- scripts/checkpatch.pl | 2 ++ 1 file changed, 2 insertions(+)scripts/checkpatch.pl +0
-0@@ -1716,11 +1716,13 @@ sub process { # 2. at the beginning of a line for slice initialisers -- [0...10] = 5, # 3. inside a curly brace -- = { [0...10] = 5 } # 4. after a comma -- [1] = 5, [2] = 6scripts/checkpatch.pl sub process { · line 1728
Quoted 10 lines
scripts/checkpatch.pl +2
-0+# 5. in a macro definition -- #define abc(x) [x] = y while ($line =~ /(.*?\s)\[/g) { my ($where, $prefix) = ($-[1], $1); if ($prefix !~ /$Type\s+$/ && ($where != 0 || $prefix !~ /^.\s+$/) && $prefix !~ /{\s+$/ && + $prefix !~ /\#\s*define[^(]*\([^)]*\)\s+$/ && $prefix !~ /,\s+$/) { ERROR("space prohibited before open square bracket '['\n" . $herecurr); }--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762
Quoted 16 lines · Leonid Bloch
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)--
2.4.3
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762
Quoted 22 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 16 lines · Leonid Bloch
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)--
2.4.3
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762
Quoted 31 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 6 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762On Thu, Oct 29, 2015 at 11:48 AM, Leonid Bloch <[email protected]>
Quoted 3 lines · wrote:
Quoted 3 lines
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual
commits).
Quoted 13 lines
Quoted 13 lines
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)--
2.4.3
ping
Quoted 42 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 33 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 6 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762On Thu, Oct 29, 2015 at 11:48 AM, Leonid Bloch <[email protected]>
Quoted 1 line · wrote:
Quoted 1 line
This series addresses two cases where errors were printed if
whitespaces
Quoted 1 line
Quoted 1 line
appeared in front of a square bracket in places where there should be
no
Quoted 1 line
Quoted 1 line
problem with such placements (please see messages of individual
commits).
Quoted 13 lines
Quoted 13 lines
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)--
2.4.3
Copying Paolo.
Quoted 12 lines · Leonid Bloch
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762
Quoted 18 lines · Markus Armbruster
Copying Paolo.
Quoted 12 lines · Leonid Bloch
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762
Quoted 27 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 19 lines · Markus Armbruster
Copying Paolo.
Quoted 13 lines · Leonid Bloch
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Paolo Bonzini
AppliedQuoted 33 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 27 lines · Leonid Bloch
ping
http://patchwork.ozlabs.org/patch/537763
http://patchwork.ozlabs.org/patch/537762Quoted 19 lines · Markus Armbruster
Copying Paolo.
Quoted 13 lines · Leonid Bloch
This series addresses two cases where errors were printed if whitespaces appeared in front of a square bracket in places where there should be no problem with such placements (please see messages of individual commits).
Leonid Bloch (2):
checkpatch: Eliminate false positive in case of comma-space-square
bracket
checkpatch: Eliminate false positive in case of space before square
bracket in a definitionscripts/checkpatch.pl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
Thanks, applied to my queue.
Paolo