lkml.org 
[lkml]   [2017]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectRe: [PATCH] checkpatch: support function pointers for unnamed function definition arguments
From
Date
On Thu, 2017-09-14 at 11:01 +0800, Miles Chen wrote:
> 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.
>
> Signed-off-by: Miles Chen <miles.chen@mediatek.com>
> ---
> scripts/checkpatch.pl | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index dd2c262..dc6da15 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -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(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 05dd72693621..7289c1eb0b19 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -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) {

\
 
 \ /
  Last update: 2017-09-14 07:34    [W:0.043 / U:0.632 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site