From: akpm@linux-foundation.org
To: mm-commits@vger.kernel.org
Cc: joe@perches.com, apw@canonical.com, vapier.adi@gmail.com
Subject: + scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char.patch added to -mm tree
Date: Fri, 10 Sep 2010 17:12:16 -0700 [thread overview]
Message-ID: <201009110012.o8B0CGJl011112@imap1.linux-foundation.org> (raw)
The patch titled
scripts/checkpatch.pl: add warnings for static char that could be static const char
has been added to the -mm tree. Its filename is
scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char.patch
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/SubmitChecklist when testing your code ***
See http://userweb.kernel.org/~akpm/stuff/added-to-mm.txt to find
out what to do about this
The current -mm tree may be found at http://userweb.kernel.org/~akpm/mmotm/
------------------------------------------------------
Subject: scripts/checkpatch.pl: add warnings for static char that could be static const char
From: Joe Perches <joe@perches.com>
Add warnings for possible missing const uses of
static char foo[] = "bar"
that could be
static const char foo[] = "bar"
and
static const char *foo[] = {"bar", "baz"}
that could be
static const char * const foo[] = {"bar", "baz"}
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Mike Frysinger <vapier.adi@gmail.com>
Cc: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
---
scripts/checkpatch.pl | 12 ++++++++++++
1 file changed, 12 insertions(+)
diff -puN scripts/checkpatch.pl~scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char scripts/checkpatch.pl
--- a/scripts/checkpatch.pl~scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char
+++ a/scripts/checkpatch.pl
@@ -1869,6 +1869,18 @@ sub process {
$herecurr);
}
+# check for static const char * arrays.
+ if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
+ WARN("static const char * array should probably be static const char * const\n" .
+ $herecurr);
+ }
+
+# check for static char foo[] = "bar" declarations.
+ if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
+ WARN("static char array declaration should probably be static const char\n" .
+ $herecurr);
+ }
+
# check for new typedefs, only function parameters and sparse annotations
# make sense.
if ($line =~ /\btypedef\s/ &&
_
Patches currently in -mm which might be from joe@perches.com are
origin.patch
linux-next.patch
kernelh-add-minmax3-macros.patch
kernelh-add-minmax3-macros-fix.patch
replace-nested-max-min-macros-with-maxmin3-macro.patch
checkpatch-add-check-for-space-after-struct-union-and-enum.patch
checkpatch-add-additional-attribute-defines.patch
scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char.patch
reply other threads:[~2010-09-11 0:12 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=201009110012.o8B0CGJl011112@imap1.linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=apw@canonical.com \
--cc=joe@perches.com \
--cc=linux-kernel@vger.kernel.org \
--cc=mm-commits@vger.kernel.org \
--cc=vapier.adi@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox