From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752677AbdDIRp5 (ORCPT ); Sun, 9 Apr 2017 13:45:57 -0400 Received: from smtprelay0152.hostedemail.com ([216.40.44.152]:48130 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1752495AbdDIRpu (ORCPT ); Sun, 9 Apr 2017 13:45:50 -0400 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 64,4,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:800:960:973:982:988:989:1260:1345:1359:1437:1534:1541:1711:1730:1747:1777:1792:2332:2393:2559:2562:2892:3138:3139:3140:3141:3142:3352:3653:3743:3865:3866:3867:3870:3871:3872:4321:5007:6119:6261:10004:10848:11026:11473:11658:11914:12043:12114:12438:12555:12895:13069:13311:13357:14181:14384:14394:14721:14775:21080:21212:21433:21451:30029:30030:30054:30070:30075,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:,MSBL:0,DNSBL:none,Custom_rules:0:0:0,LFtime:2,LUA_SUMMARY:none X-HE-Tag: rain61_89c625afaac4e X-Filterd-Recvd-Size: 2418 From: Joe Perches To: Andrew Morton , Andy Whitcroft Cc: linux-kernel@vger.kernel.org Subject: [PATCH 1/2] checkpatch: Clarify the EMBEDDED_FUNCTION_NAME message Date: Sun, 9 Apr 2017 10:45:43 -0700 Message-Id: <38f5d32f0aec1cd98cb9ceeedd6a736cc9a802db.1491759835.git.joe@perches.com> X-Mailer: git-send-email 2.10.0.rc2.1.g053435c In-Reply-To: <20170409085531.GA26418@rhlx01.hs-esslingen.de> References: <20170409085531.GA26418@rhlx01.hs-esslingen.de> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Try to make the conversion of embedded function names to "%s: ", __func__ a bit clearer. Add a bit more information to the comment describing the test too. Signed-off-by: Joe Perches --- scripts/checkpatch.pl | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 089c974aa3a5..e8d8481b24c8 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -5172,14 +5172,16 @@ sub process { "break quoted strings at a space character\n" . $hereprev); } -#check for an embedded function name in a string when the function is known -# as part of a diff. This does not work for -f --file checking as it -#depends on patch context providing the function name +# check for an embedded function name in a string when the function is known +# This does not work very well for -f --file checking as it depends on patch +# context providing the function name or a single line form for in-file +# function declarations if ($line =~ /^\+.*$String/ && defined($context_function) && - get_quoted_string($line, $rawline) =~ /\b$context_function\b/) { + get_quoted_string($line, $rawline) =~ /\b$context_function\b/ && + length(get_quoted_string($line, $rawline)) != (length($context_function) + 2)) { WARN("EMBEDDED_FUNCTION_NAME", - "Prefer using \"%s\", __func__ to embedded function names\n" . $herecurr); + "Prefer using '\"%s...\", __func__' to using '$context_function', this function's name, in a string\n" . $herecurr); } # check for spaces before a quoted newline -- 2.10.0.rc2.1.g053435c