Skip to contentSkip to conversation

checkpatch: support function pointers for unnamed function definition arguments

PATCH Superseded Miles Chen 2 participants 3 messages Sep 14, 2017

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Miles Chen

author
#0 lore raw

PATCH 1/1 checkpatch: support function pointers for unnamed function definition arguments

Current unnamed function definition argument does not include function pointer cases and it reports warnings like:

WARNING: function definition argument 'void' should also have an identifier name +unsigned int (*dummy)(void);

Support function pointers for unnamed function arguments.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +1 -1
index dd2c262..dc6da15 100755
@@ -5957,7 +5957,7 @@ sub process {
 
 # check for function declarations that have arguments without identifier names
 		if (defined $stat &&
-		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
+		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*\(?\s*\*?\s*$Ident\s*\)\s*\(\s*([^{]+)\s*\)\s*;/s &&
 		    $1 ne "void") {
 			my $args = trim($1);
 			while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
Signature · 1 line
1.9.1
maintainer
#1 lore raw
Quoted 18 lines · Miles Chen

Current unnamed function definition argument does not include function pointer cases and it reports warnings like:

WARNING: function definition argument 'void' should also have an identifier name

Support function pointers for unnamed function arguments.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +0 -0
index dd2c262..dc6da15 100755

scripts/checkpatch.pl sub process { · line 5960

Quoted 5 lines
scripts/checkpatch.pl +1 -1
@@ -5957,7 +5957,7 @@ sub process {
 
 # check for function declarations that have arguments without identifier names
 		if (defined $stat &&
-		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
+		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*\(?\s*\*?\s*$Ident\s*\)\s*\(\s*([^{]+)\s*\)\s*;/s &&

Better would be to specifically support function pointers like:
---
 scripts/checkpatch.pl | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +0 -0
index 05dd72693621..7289c1eb0b19 100755
@@ -5957,7 +5957,7 @@ sub process {

 # check for function declarations that have arguments without identifier names
 		if (defined $stat &&
-		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
+		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&
 		    $1 ne "void") {
 			my $args = trim($1);
 			while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {
author
#2 lore raw
Quoted 35 lines · Joe Perches
Quoted 18 lines · Miles Chen

Current unnamed function definition argument does not include function pointer cases and it reports warnings like:

WARNING: function definition argument 'void' should also have an identifier name

Support function pointers for unnamed function arguments.

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +0 -0
index dd2c262..dc6da15 100755

scripts/checkpatch.pl sub process { · line 5960

Quoted 5 lines
scripts/checkpatch.pl +1 -1
@@ -5957,7 +5957,7 @@ sub process {
 
 # check for function declarations that have arguments without identifier names
 		if (defined $stat &&
-		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
+		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*\(?\s*\*?\s*$Ident\s*\)\s*\(\s*([^{]+)\s*\)\s*;/s &&

Better would be to specifically support function pointers like:

---
 scripts/checkpatch.pl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
scripts/checkpatch.pl +0 -0
index 05dd72693621..7289c1eb0b19 100755

scripts/checkpatch.pl sub process { · line 5960

Quoted 5 lines
scripts/checkpatch.pl +1 -1
@@ -5957,7 +5957,7 @@ sub process {
 
 # check for function declarations that have arguments without identifier names
 		if (defined $stat &&
-		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*$Ident\s*\(\s*([^{]+)\s*\)\s*;/s &&
+		    $stat =~ /^.\s*(?:extern\s+)?$Type\s*(?:$Ident|\(\s*\*\s*$Ident\s*\))\s*\(\s*([^{]+)\s*\)\s*;/s &&

Hi Joe,

thanks for the advise, it looks better.
I'll verify this patch and submit it again

Miles

Quoted 4 lines
scripts/checkpatch.pl +0 -0
 		    $1 ne "void") {
 			my $args = trim($1);
 			while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) {