linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] checkpatch.pl: false positive: space prohibited before open square bracket
@ 2018-04-03 19:02 Heinrich Schuchardt
  2018-04-03 19:16 ` [PATCH 1/1] checkpatch: allow space between colon and bracket Heinrich Schuchardt
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-04-03 19:02 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches; +Cc: linux-kernel, Heinrich Schuchardt

This patch leads to errors "space prohibited before open square
bracket '['" for the asm statement.

In the inline assembler statement the bracket is not used for an index.
Adding a space after a colon or a comma should be allowable.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 foo.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
 create mode 100644 foo.c

diff --git a/foo.c b/foo.c
new file mode 100644
index 000000000000..7f0ed923f997
--- /dev/null
+++ b/foo.c
@@ -0,0 +1,11 @@
+static inline u32 deref(u32 *addr)
+{
+	int ret;
+
+	asm(
+		"ldr %[out], [%[in]]\n\t"
+		: [out] "=r" (ret)
+		: [in] "r" (addr)
+	);
+	return ret;
+}
-- 
2.16.3

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

* [PATCH 1/1] checkpatch: allow space between colon and bracket
  2018-04-03 19:02 [BUG] checkpatch.pl: false positive: space prohibited before open square bracket Heinrich Schuchardt
@ 2018-04-03 19:16 ` Heinrich Schuchardt
  2018-04-03 21:20   ` Joe Perches
  0 siblings, 1 reply; 3+ messages in thread
From: Heinrich Schuchardt @ 2018-04-03 19:16 UTC (permalink / raw)
  To: Andy Whitcroft, Joe Perches; +Cc: linux-kernel, Heinrich Schuchardt

Allow a space between a colon and subsequent opening bracket.
This sequence may occur in inline assembler statements like

	asm(
		"ldr %[out], [%[in]]\n\t"
		: [out] "=r" (ret)
		: [in] "r" (addr)
	);

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index d2464002bb40..2cbab86e6d4c 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -4083,7 +4083,7 @@ sub process {
 			my ($where, $prefix) = ($-[1], $1);
 			if ($prefix !~ /$Type\s+$/ &&
 			    ($where != 0 || $prefix !~ /^.\s+$/) &&
-			    $prefix !~ /[{,]\s+$/) {
+			    $prefix !~ /[{,:]\s+$/) {
 				if (ERROR("BRACKET_SPACE",
 					  "space prohibited before open square bracket '['\n" . $herecurr) &&
 				    $fix) {
-- 
2.16.3

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

* Re: [PATCH 1/1] checkpatch: allow space between colon and bracket
  2018-04-03 19:16 ` [PATCH 1/1] checkpatch: allow space between colon and bracket Heinrich Schuchardt
@ 2018-04-03 21:20   ` Joe Perches
  0 siblings, 0 replies; 3+ messages in thread
From: Joe Perches @ 2018-04-03 21:20 UTC (permalink / raw)
  To: Heinrich Schuchardt, Andy Whitcroft, Andrew Morton; +Cc: linux-kernel

On Tue, 2018-04-03 at 21:16 +0200, Heinrich Schuchardt wrote:
> Allow a space between a colon and subsequent opening bracket.
> This sequence may occur in inline assembler statements like
> 
> 	asm(
> 		"ldr %[out], [%[in]]\n\t"
> 		: [out] "=r" (ret)
> 		: [in] "r" (addr)
> 	);
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>

I can't think of a valid c90 sequence that has a colon
before a bracket so

Acked-by: Joe Perches <joe@perches.com>

> ---
>  scripts/checkpatch.pl | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index d2464002bb40..2cbab86e6d4c 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -4083,7 +4083,7 @@ sub process {
>  			my ($where, $prefix) = ($-[1], $1);
>  			if ($prefix !~ /$Type\s+$/ &&
>  			    ($where != 0 || $prefix !~ /^.\s+$/) &&
> -			    $prefix !~ /[{,]\s+$/) {
> +			    $prefix !~ /[{,:]\s+$/) {
>  				if (ERROR("BRACKET_SPACE",
>  					  "space prohibited before open square bracket '['\n" . $herecurr) &&
>  				    $fix) {

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

end of thread, other threads:[~2018-04-03 21:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-03 19:02 [BUG] checkpatch.pl: false positive: space prohibited before open square bracket Heinrich Schuchardt
2018-04-03 19:16 ` [PATCH 1/1] checkpatch: allow space between colon and bracket Heinrich Schuchardt
2018-04-03 21:20   ` Joe Perches

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