linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] checkpatch: Allow space before [ in the case of inline asm constraints
@ 2010-11-16 12:13 Dave Martin
  2010-11-16 15:00 ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Dave Martin @ 2010-11-16 12:13 UTC (permalink / raw)
  To: linux-kernel; +Cc: Dave Martin, Andy Whitcroft

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 [

Signed-off-by: Dave Martin <dave.martin@linaro.org>
---
 scripts/checkpatch.pl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e3c7fc0..2c2fa51 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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);
 			}
 		}
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] checkpatch: Allow space before [ in the case of inline asm constraints
  2010-11-16 12:13 [PATCH] checkpatch: Allow space before [ in the case of inline asm constraints Dave Martin
@ 2010-11-16 15:00 ` Joe Perches
  2010-11-23 14:32   ` Andy Whitcroft
  0 siblings, 1 reply; 3+ messages in thread
From: Joe Perches @ 2010-11-16 15:00 UTC (permalink / raw)
  To: Dave Martin; +Cc: linux-kernel, Andy Whitcroft

On Tue, 2010-11-16 at 12:13 +0000, Dave Martin wrote:
> 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.



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] checkpatch: Allow space before [ in the case of inline asm constraints
  2010-11-16 15:00 ` Joe Perches
@ 2010-11-23 14:32   ` Andy Whitcroft
  0 siblings, 0 replies; 3+ messages in thread
From: Andy Whitcroft @ 2010-11-23 14:32 UTC (permalink / raw)
  To: Joe Perches; +Cc: Dave Martin, linux-kernel

On Tue, Nov 16, 2010 at 07:00:12AM -0800, Joe Perches wrote:
> On Tue, 2010-11-16 at 12:13 +0000, Dave Martin wrote:
> > 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.

Yeah am starting to think that whatever is in there is a different
world.

-apw

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-11-23 14:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-16 12:13 [PATCH] checkpatch: Allow space before [ in the case of inline asm constraints Dave Martin
2010-11-16 15:00 ` Joe Perches
2010-11-23 14:32   ` Andy Whitcroft

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).