Skip to content

Commit 5f14d3b

Browse files
JoePerchestorvalds
authored andcommitted
checkpatch: prefer __printf over __attribute__((format(printf,...)))
Add a warn for not using __printf. 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 270c49a commit 5f14d3b

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

scripts/checkpatch.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3114,6 +3114,12 @@ sub process {
31143114
"__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
31153115
}
31163116

3117+
# Check for __attribute__ format(printf, prefer __printf
3118+
if ($line =~ /\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf/) {
3119+
WARN("PREFER_PRINTF",
3120+
"__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr);
3121+
}
3122+
31173123
# check for sizeof(&)
31183124
if ($line =~ /\bsizeof\s*\(\s*\&/) {
31193125
WARN("SIZEOF_ADDRESS",

0 commit comments

Comments
 (0)