From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751609AbbAaH1f (ORCPT ); Sat, 31 Jan 2015 02:27:35 -0500 Received: from smtprelay0041.hostedemail.com ([216.40.44.41]:46176 "EHLO smtprelay.hostedemail.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751055AbbAaH1e (ORCPT ); Sat, 31 Jan 2015 02:27:34 -0500 X-Session-Marker: 6A6F6540706572636865732E636F6D X-Spam-Summary: 2,0,0,,d41d8cd98f00b204,joe@perches.com,:::::,RULES_HIT:41:355:379:541:599:982:988:989:1260:1277:1311:1313:1314:1345:1359:1373:1437:1515:1516:1518:1534:1541:1593:1594:1711:1730:1747:1777:1792:2393:2559:2562:2828:3138:3139:3140:3141:3142:3352:3622:3653:3865:3866:3867:3871:3872:3874:4321:5007:6119:6261:10004:10400:10848:11026:11232:11473:11658:11914:12043:12296:12517:12519:12555:12740:13069:13255:13311:13357:21080,0,RBL:none,CacheIP:none,Bayesian:0.5,0.5,0.5,Netcheck:none,DomainCache:0,MSF:not bulk,SPF:fn,MSBL:0,DNSBL:none,Custom_rules:0:0:0 X-HE-Tag: self85_24c1c8d1f7b06 X-Filterd-Recvd-Size: 2530 Message-ID: <1422689251.10874.7.camel@perches.com> Subject: Re: [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts From: Joe Perches To: Heba Aamer Cc: apw@canonical.com, linux-kernel@vger.kernel.org Date: Fri, 30 Jan 2015 23:27:31 -0800 In-Reply-To: <20150131020414.GA9833@mohammed-Inspiron-3537> References: <20150131020414.GA9833@mohammed-Inspiron-3537> Content-Type: text/plain; charset="ISO-8859-1" X-Mailer: Evolution 3.12.7-0ubuntu1 Mime-Version: 1.0 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 2015-01-31 at 04:04 +0200, Heba Aamer wrote: > This patch enhances the check for seq_printf uses that could > be seq_puts. > > It was considering the escape of % is \%, but it is %%. > This led to skipping some valid cases related to that warning. [] > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl [] > @@ -4804,11 +4804,14 @@ sub process { > # check for seq_printf uses that could be seq_puts > if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) { > my $fmt = get_quoted_string($line, $rawline); > - if ($fmt ne "" && $fmt !~ /[^\\]\%/) { > - if (WARN("PREFER_SEQ_PUTS", > - "Prefer seq_puts to seq_printf\n" . $herecurr) && > - $fix) { > - $fixed[$fixlinenr] =~ s/\bseq_printf\b/seq_puts/; > + if ($fmt ne "") { > + $fmt =~ s/%%//g; > + if ($fmt !~ /%/) { > + if (WARN("PREFER_SEQ_PUTS", > + "Prefer seq_puts to seq_printf\n" . $herecurr) && > + $fix) { > + $fixed[$fixlinenr] =~ s/\bseq_printf\b/seq_puts/; > + } > } > } > } Probably be simpler to use: --- scripts/checkpatch.pl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 059c032..7f1804e 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -4854,7 +4854,8 @@ sub process { # check for seq_printf uses that could be seq_puts if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) { my $fmt = get_quoted_string($line, $rawline); - if ($fmt ne "" && $fmt !~ /[^\\]\%/) { + $fmt =~ s/%%//g; + if ($fmt !~ /%/) { if (WARN("PREFER_SEQ_PUTS", "Prefer seq_puts to seq_printf\n" . $herecurr) && $fix) {