aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2013-04-29 16:18:13 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2013-04-29 18:28:19 -0700
commita6962d7273d8f89c136fe9ea3d61d7f47adcd823 (patch)
tree67d260393e057398039f81acf41c4d35d7c6a01f /scripts/checkpatch.pl
parent972fdea2e6ece7578915d386a5447bc78d3fb8b8 (diff)
downloadkernel_goldelico_gta04-a6962d7273d8f89c136fe9ea3d61d7f47adcd823.zip
kernel_goldelico_gta04-a6962d7273d8f89c136fe9ea3d61d7f47adcd823.tar.gz
kernel_goldelico_gta04-a6962d7273d8f89c136fe9ea3d61d7f47adcd823.tar.bz2
checkpatch: Prefer seq_puts to seq_printf
Add a check for seq_printf use with a constant format without additional arguments. Suggest seq_puts instead. Signed-off-by: Joe Perches <joe@perches.com> Suggested-by: Bjorn Helgaas <bhelgaas@google.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl16
1 files changed, 16 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index a820249..b8b03aa 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -628,6 +628,13 @@ sub sanitise_line {
return $res;
}
+sub get_quoted_string {
+ my ($line, $rawline) = @_;
+
+ return "" if ($line !~ m/(\"[X]+\")/g);
+ return substr($rawline, $-[0], $+[0] - $-[0]);
+}
+
sub ctx_statement_block {
my ($linenr, $remain, $off) = @_;
my $line = $linenr - 1;
@@ -3373,6 +3380,15 @@ sub process {
"struct spinlock should be spinlock_t\n" . $herecurr);
}
+# check for seq_printf uses that could be seq_puts
+ if ($line =~ /\bseq_printf\s*\(/) {
+ my $fmt = get_quoted_string($line, $rawline);
+ if ($fmt !~ /[^\\]\%/) {
+ WARN("PREFER_SEQ_PUTS",
+ "Prefer seq_puts to seq_printf\n" . $herecurr);
+ }
+ }
+
# Check for misused memsets
if ($^V && $^V ge 5.10.0 &&
defined $stat &&