All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: Andrew Morton <akpm@linux-foundation.org>
Cc: linux-kernel@vger.kernel.org, Andy Whitcroft <apw@canonical.com>
Subject: [PATCH] checkpatch: Prefer __printf not __attribute__((format(printf,...)))
Date: Wed, 02 Nov 2011 04:27:37 +0200	[thread overview]
Message-ID: <1320200857.15779.4.camel@Joe-Laptop> (raw)
In-Reply-To: <20111101150908.b482fad5.akpm@linux-foundation.org>

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",



      parent reply	other threads:[~2011-11-02  2:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-08-25 20:26 [PATCH] mm: Neaten warn_alloc_failed Joe Perches
2011-08-25 20:26 ` Joe Perches
2011-08-25 23:50 ` Andrew Morton
2011-08-25 23:50   ` Andrew Morton
2011-08-26  0:00   ` Joe Perches
2011-08-26  0:00     ` Joe Perches
2011-08-26  0:05     ` Andrew Morton
2011-08-26  0:05       ` Andrew Morton
2011-08-26  0:38       ` Joe Perches
2011-08-26  0:38         ` Joe Perches
2011-08-26  1:07         ` Andrew Morton
2011-08-26  1:07           ` Andrew Morton
2011-08-26  2:55           ` [PATCH] treewide: Use __printf not __attribute__((format(printf,...))) Joe Perches
2011-08-26  2:55             ` Joe Perches
2011-10-11 17:22             ` Kirill A. Shutemov
2011-10-11 17:22               ` Kirill A. Shutemov
2011-10-11 17:22               ` Kirill A. Shutemov
2011-10-11 17:43               ` Joe Perches
2011-10-11 17:43                 ` Joe Perches
     [not found]             ` <20111101150908.b482fad5.akpm@linux-foundation.org>
2011-11-02  2:27               ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1320200857.15779.4.camel@Joe-Laptop \
    --to=joe@perches.com \
    --cc=akpm@linux-foundation.org \
    --cc=apw@canonical.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.