mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts
@ 2015-01-31  2:04 Heba Aamer
  2015-01-31  7:27 ` Joe Perches
  0 siblings, 1 reply; 2+ messages in thread
From: Heba Aamer @ 2015-01-31  2:04 UTC (permalink / raw)
  To: apw, joe; +Cc: linux-kernel

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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts
  2015-01-31  2:04 [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts Heba Aamer
@ 2015-01-31  7:27 ` Joe Perches
  0 siblings, 0 replies; 2+ messages in thread
From: Joe Perches @ 2015-01-31  7:27 UTC (permalink / raw)
  To: Heba Aamer; +Cc: apw, linux-kernel

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) {



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-31  7:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-01-31  2:04 [PATCH] checkpatch: enhance check for seq_printf uses that could be seq_puts Heba Aamer
2015-01-31  7:27 ` Joe Perches

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®