mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Heba Aamer <heba93aamer@gmail.com>
To: apw@canonical.com, joe@perches.com
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts
Date: Sat, 31 Jan 2015 04:04:14 +0200	[thread overview]
Message-ID: <20150131020414.GA9833@mohammed-Inspiron-3537> (raw)

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.  

Signed-off-by: Heba Aamer <heba93aamer@gmail.com>
---
 scripts/checkpatch.pl |   13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index f0bb6d6..0b125ca 100755
--- 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/;
+					}
 				}
 			}
 		}
-- 
1.7.9.5


             reply	other threads:[~2015-01-31  2:04 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-31  2:04 Heba Aamer [this message]
2015-01-31  7:27 ` Joe Perches

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=20150131020414.GA9833@mohammed-Inspiron-3537 \
    --to=heba93aamer@gmail.com \
    --cc=apw@canonical.com \
    --cc=joe@perches.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®