* + scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char.patch added to -mm tree
@ 2010-09-11 0:12 akpm
0 siblings, 0 replies; only message in thread
From: akpm @ 2010-09-11 0:12 UTC (permalink / raw)
To: mm-commits; +Cc: joe, apw, vapier.adi
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
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2010-09-11 0:12 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-11 0:12 + scripts-checkpatchpl-add-warnings-for-static-char-that-could-be-static-const-char.patch added to -mm tree akpm
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.