public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] checkpatch.pl: Fix wrong curly bracket position reporting
@ 2013-12-18  2:56 Jean-Baptiste Theou
  0 siblings, 0 replies; 4+ messages in thread
From: Jean-Baptiste Theou @ 2013-12-18  2:56 UTC (permalink / raw)
  To: linux-kernel; +Cc: joe, Jean-Baptiste Theou

This patch fixes wrong curly bracket position reporting when function
declarations have only one void argument.

Missing error (ERROR: space required before the open brace '{') on this
situation :

int foo(void){
	...
}

Signed-off-by: Jean-Baptiste Theou <jtheou@adeneo-embedded.us>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8f3aecd..3a18c5e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3159,7 +3159,7 @@ sub process {
 ## 		}
 
 #need space before brace following if, while, etc
-		if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
+		if (($line =~ /\(.*\){/ && ($line =~ /\(void\){/ || $line !~ /\($Type\){/)) ||
 		    $line =~ /do{/) {
 			if (ERROR("SPACING",
 				  "space required before the open brace '{'\n" . $herecurr) &&
-- 
1.8.4.2


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

* [PATCH] checkpatch.pl: Fix wrong curly bracket position reporting
@ 2013-12-18  2:59 Jean-Baptiste Theou
  2013-12-18  5:39 ` Joe Perches
  0 siblings, 1 reply; 4+ messages in thread
From: Jean-Baptiste Theou @ 2013-12-18  2:59 UTC (permalink / raw)
  To: linux-kernel; +Cc: joe, Jean-Baptiste Theou

This patch fixes wrong curly bracket position reporting when function
declarations have only one void argument.

Missing error (ERROR: space required before the open brace '{') on this
situation :

int foo(void){
	...
}

Signed-off-by: Jean-Baptiste Theou <jtheou@adeneo-embedded.us>
---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8f3aecd..3a18c5e 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3159,7 +3159,7 @@ sub process {
 ## 		}
 
 #need space before brace following if, while, etc
-		if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
+		if (($line =~ /\(.*\){/ && ($line =~ /\(void\){/ || $line !~ /\($Type\){/)) ||
 		    $line =~ /do{/) {
 			if (ERROR("SPACING",
 				  "space required before the open brace '{'\n" . $herecurr) &&
-- 
1.8.4.2


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

* Re: [PATCH] checkpatch.pl: Fix wrong curly bracket position reporting
  2013-12-18  2:59 [PATCH] checkpatch.pl: Fix wrong curly bracket position reporting Jean-Baptiste Theou
@ 2013-12-18  5:39 ` Joe Perches
  2013-12-18 17:43   ` Jean-Baptiste Theou
  0 siblings, 1 reply; 4+ messages in thread
From: Joe Perches @ 2013-12-18  5:39 UTC (permalink / raw)
  To: Jean-Baptiste Theou; +Cc: linux-kernel

On Tue, 2013-12-17 at 18:59 -0800, Jean-Baptiste Theou wrote:
> This patch fixes wrong curly bracket position reporting when function
> declarations have only one void argument.
> 
> Missing error (ERROR: space required before the open brace '{') on this
> situation :
> 
> int foo(void){
> 	...
> }

That's true for any declaration with { on the same line.

Perhaps this would be better:
---
 scripts/checkpatch.pl | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 8f3aecd..c4dbb8a 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2784,7 +2784,8 @@ sub process {
 
 # function brace can't be on same line, except for #defines of do while,
 # or if closed on same line
-		if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
+		if ($^V && $^V ge 5.10.0 &&
+		    ($line=~/$Type\s*$Ident\s*$balanced_parens\s*{\s*$/) &&
 		    !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
 			ERROR("OPEN_BRACE",
 			      "open brace '{' following function declarations go on the next line\n" . $herecurr);
@@ -3159,7 +3160,9 @@ sub process {
 ## 		}
 
 #need space before brace following if, while, etc
-		if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
+		if ($^V && $^V ge 5.10.0 &&
+		    ($line !~ /$Type\s*$Ident\s*$balanced_parens\s*{\s*$/) &&
+		    ($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
 		    $line =~ /do{/) {
 			if (ERROR("SPACING",
 				  "space required before the open brace '{'\n" . $herecurr) &&



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

* Re: [PATCH] checkpatch.pl: Fix wrong curly bracket position reporting
  2013-12-18  5:39 ` Joe Perches
@ 2013-12-18 17:43   ` Jean-Baptiste Theou
  0 siblings, 0 replies; 4+ messages in thread
From: Jean-Baptiste Theou @ 2013-12-18 17:43 UTC (permalink / raw)
  To: Joe Perches; +Cc: linux-kernel

Hi Joe,

Looks good to me, it fix this issue and for sure more global.

Regards,

Jean-Baptiste
On 12/17/2013 09:39 PM, Joe Perches wrote:
> On Tue, 2013-12-17 at 18:59 -0800, Jean-Baptiste Theou wrote:
>> This patch fixes wrong curly bracket position reporting when function
>> declarations have only one void argument.
>>
>> Missing error (ERROR: space required before the open brace '{') on this
>> situation :
>>
>> int foo(void){
>> 	...
>> }
> That's true for any declaration with { on the same line.
>
> Perhaps this would be better:
> ---
>   scripts/checkpatch.pl | 7 +++++--
>   1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 8f3aecd..c4dbb8a 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2784,7 +2784,8 @@ sub process {
>   
>   # function brace can't be on same line, except for #defines of do while,
>   # or if closed on same line
> -		if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and
> +		if ($^V && $^V ge 5.10.0 &&
> +		    ($line=~/$Type\s*$Ident\s*$balanced_parens\s*{\s*$/) &&
>   		    !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) {
>   			ERROR("OPEN_BRACE",
>   			      "open brace '{' following function declarations go on the next line\n" . $herecurr);
> @@ -3159,7 +3160,9 @@ sub process {
>   ## 		}
>   
>   #need space before brace following if, while, etc
> -		if (($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
> +		if ($^V && $^V ge 5.10.0 &&
> +		    ($line !~ /$Type\s*$Ident\s*$balanced_parens\s*{\s*$/) &&
> +		    ($line =~ /\(.*\){/ && $line !~ /\($Type\){/) ||
>   		    $line =~ /do{/) {
>   			if (ERROR("SPACING",
>   				  "space required before the open brace '{'\n" . $herecurr) &&
>
>


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

end of thread, other threads:[~2013-12-18 17:43 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-18  2:59 [PATCH] checkpatch.pl: Fix wrong curly bracket position reporting Jean-Baptiste Theou
2013-12-18  5:39 ` Joe Perches
2013-12-18 17:43   ` Jean-Baptiste Theou
  -- strict thread matches above, loose matches on Subject: below --
2013-12-18  2:56 Jean-Baptiste Theou

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox