Skip to content

Commit e4b7d30

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: clarify the EMBEDDED_FUNCTION_NAME message
Try to make the conversion of embedded function names to "%s: ", __func__ a bit clearer. Add a bit more information to the comment describing the test too. Link: http://lkml.kernel.org/r/38f5d32f0aec1cd98cb9ceeedd6a736cc9a802db.1491759835.git.joe@perches.com Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e795556 commit e4b7d30

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

scripts/checkpatch.pl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5174,14 +5174,16 @@ sub process {
51745174
"break quoted strings at a space character\n" . $hereprev);
51755175
}
51765176

5177-
#check for an embedded function name in a string when the function is known
5178-
# as part of a diff. This does not work for -f --file checking as it
5179-
#depends on patch context providing the function name
5177+
# check for an embedded function name in a string when the function is known
5178+
# This does not work very well for -f --file checking as it depends on patch
5179+
# context providing the function name or a single line form for in-file
5180+
# function declarations
51805181
if ($line =~ /^\+.*$String/ &&
51815182
defined($context_function) &&
5182-
get_quoted_string($line, $rawline) =~ /\b$context_function\b/) {
5183+
get_quoted_string($line, $rawline) =~ /\b$context_function\b/ &&
5184+
length(get_quoted_string($line, $rawline)) != (length($context_function) + 2)) {
51835185
WARN("EMBEDDED_FUNCTION_NAME",
5184-
"Prefer using \"%s\", __func__ to embedded function names\n" . $herecurr);
5186+
"Prefer using '\"%s...\", __func__' to using '$context_function', this function's name, in a string\n" . $herecurr);
51855187
}
51865188

51875189
# check for spaces before a quoted newline

0 commit comments

Comments
 (0)