From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751728AbdINKJL (ORCPT ); Thu, 14 Sep 2017 06:09:11 -0400 Received: from mailgw02.mediatek.com ([210.61.82.184]:20919 "EHLO mailgw02.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1751414AbdINKJK (ORCPT ); Thu, 14 Sep 2017 06:09:10 -0400 X-UUID: 0dd1fe4fcb014b7d96639ec5b3ecd6c9-20170914 Message-ID: <1505383744.21903.2.camel@mtkswgap22> Subject: Re: [PATCH] checkpatch: support function pointers for unnamed function definition arguments From: Miles Chen To: Joe Perches CC: Andy Whitcroft , , , Date: Thu, 14 Sep 2017 18:09:04 +0800 In-Reply-To: <1505367221.8969.25.camel@perches.com> References: <1505358082-12997-1-git-send-email-miles.chen@mediatek.com> <1505367221.8969.25.camel@perches.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.2.3-0ubuntu6 Content-Transfer-Encoding: 7bit MIME-Version: 1.0 X-MTK: N Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2017-09-13 at 22:33 -0700, Joe Perches wrote: > 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 > > --- > > 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 && Hi Joe, thanks for the advise, it looks better. I'll verify this patch and submit it again Miles > $1 ne "void") { > my $args = trim($1); > while ($args =~ m/\s*($Type\s*(?:$Ident|\(\s*\*\s*$Ident?\s*\)\s*$balanced_parens)?)/g) { >