lkml.org 
[lkml]   [2011]   [Nov]   [1]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH] checkpatch: Prefer __printf not __attribute__((format(printf,...)))
From
Date
Add a warn for not using __printf.

Signed-off-by: Joe Perches <joe@perches.com>
---
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",



\
 
 \ /
  Last update: 2011-11-02 03:29    [W:0.091 / U:0.552 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site