aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/checkpatch.pl
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2010-10-26 17:23:20 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 19:52:21 -0400
commitcb710eca6820493add0ddd3d7e8e3ee53f2b6e57 (patch)
tree752ca452a0d2fa3f9cb085c4f4e050a5e657f5f5 /scripts/checkpatch.pl
parent267ad8f42644c2fa4ff6c2e7596d2b02c7397c85 (diff)
scripts/checkpatch.pl: add warnings for static char that could be static const char
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> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts/checkpatch.pl')
-rwxr-xr-xscripts/checkpatch.pl12
1 files changed, 12 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index c1e7fb3eab44..2ec5fc6a4046 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -1869,6 +1869,18 @@ sub process {
1869 $herecurr); 1869 $herecurr);
1870 } 1870 }
1871 1871
1872# check for static const char * arrays.
1873 if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) {
1874 WARN("static const char * array should probably be static const char * const\n" .
1875 $herecurr);
1876 }
1877
1878# check for static char foo[] = "bar" declarations.
1879 if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
1880 WARN("static char array declaration should probably be static const char\n" .
1881 $herecurr);
1882 }
1883
1872# check for new typedefs, only function parameters and sparse annotations 1884# check for new typedefs, only function parameters and sparse annotations
1873# make sense. 1885# make sense.
1874 if ($line =~ /\btypedef\s/ && 1886 if ($line =~ /\btypedef\s/ &&