[PATCH] checkpatch: Prefer __printf not__attribute__((format(printf,...)))

From: Joe Perches
Date: Tue Nov 01 2011 - 22:27:42 EST


Add a warn for not using __printf.

Signed-off-by: Joe Perches <joe@xxxxxxxxxxx>
---
On Tue, 2011-11-01 at 15:09 -0700, Andrew Morton wrote:
> hm, we don't appear to have a checkpatch rule telling people not to use
> __attribute__((format(printf, ...))). Who should I hassle about that? :)

Probably Andy Whitcroft. Until he reappears though...

scripts/checkpatch.pl | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 5e93342..6cae370 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -3097,6 +3097,12 @@ sub process {
"__aligned(size) is preferred over __attribute__((aligned(size)))\n" . $herecurr);
}

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


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/