From: Joe Perches <joe@perches.com>
To: Heba Aamer <heba93aamer@gmail.com>
Cc: apw@canonical.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts
Date: Fri, 30 Jan 2015 23:27:31 -0800 [thread overview]
Message-ID: <1422689251.10874.7.camel@perches.com> (raw)
In-Reply-To: <20150131020414.GA9833@mohammed-Inspiron-3537>
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) {
prev parent reply other threads:[~2015-01-31 7:27 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-31 2:04 Heba Aamer
2015-01-31 7:27 ` Joe Perches [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1422689251.10874.7.camel@perches.com \
--to=joe@perches.com \
--cc=apw@canonical.com \
--cc=heba93aamer@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®