From: Joe Perches Date: Tue, 26 Mar 2013 23:25:05 +0000 (+1100) Subject: checkpatch: Prefer seq_puts to seq_printf X-Git-Tag: next-20130404~3^2~296 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=c5cfaac685029046b7ad17ee31d9d4cd1d1d88dc;p=karo-tx-linux.git 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 Suggested-by: Bjorn Helgaas Signed-off-by: Andrew Morton --- diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 7ef2b4bd0145..3540bcf1cd22 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; @@ -3372,6 +3379,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 &&