checkpatch: Allow space before [ in the case of inline asm constraints
PATCH 1/1 checkpatch: Allow space before [ in the case of inline asm constraints
This allows the customary syntax for declaring named arguments, such as:
asm ("mov %[out],%[in]" : [out] "=r" (x) : [in] "r" (y));Since :[ is comple-error-inducingly invalid syntax in other cases, this won't create unintentional leniency for normal uses of [
--- scripts/checkpatch.pl | 4 +++- 1 files changed, 3 insertions(+), 1 deletions(-)
scripts/checkpatch.pl +3 -1
@@ -1988,11 +1988,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 colon for inline asm -- asm ("..." : [name] "constraint" (arg)) 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
1.7.1
Joe Perches
maintainerQuoted 4 lines · Dave Martin
This allows the customary syntax for declaring named arguments, such as:
asm ("mov %[out],%[in]" : [out] "=r" (x) : [in] "r" (y));
Andy:
Maybe it'd be better to have a checkpatch pass that does something similar to the c comment removal for asm blocks.
Maybe keyed on "\basm(\s+volatile){0,1}\s*" and strip everything in the () block that follows it.
Andy Whitcroft
maintainerQuoted 6 lines · Joe Perches
Quoted 4 lines · Dave Martin
This allows the customary syntax for declaring named arguments, such as:
asm ("mov %[out],%[in]" : [out] "=r" (x) : [in] "r" (y));
Quoted 7 lines
Andy:
Maybe it'd be better to have a checkpatch pass that does something similar to the c comment removal for asm blocks.
Maybe keyed on "\basm(\s+volatile){0,1}\s*" and strip everything in the () block that follows it.
Yeah am starting to think that whatever is in there is a different world.
-apw