aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoe Perches2014-04-03 16:49:18 -0500
committerLinus Torvalds2014-04-03 18:21:13 -0500
commit9b0fa60d9be0a82bc9e49bdd2dcacdfe4d1d5192 (patch)
tree6c3fa27f737a6a5221469ea0771da14b9fbdf2cd /scripts
parent447432f32328dcd081ae5e23f27d2ffa19f2ecf8 (diff)
downloadlinux-phy-9b0fa60d9be0a82bc9e49bdd2dcacdfe4d1d5192.tar.gz
linux-phy-9b0fa60d9be0a82bc9e49bdd2dcacdfe4d1d5192.tar.xz
linux-phy-9b0fa60d9be0a82bc9e49bdd2dcacdfe4d1d5192.zip
checkpatch: add test for char * arrays that could be static const
static const char* arrays create smaller text as each function call does not have to populate the array. Emit a warning when char *arrays aren't static const and the array is not apparently global by being declared in the first column. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl7
1 files changed, 7 insertions, 0 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 646295cd9990..91308bec89b9 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2675,6 +2675,13 @@ sub process {
2675 $herecurr); 2675 $herecurr);
2676 } 2676 }
2677 2677
2678# check for non-global char *foo[] = {"bar", ...} declarations.
2679 if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
2680 WARN("STATIC_CONST_CHAR_ARRAY",
2681 "char * array declaration might be better as static const\n" .
2682 $herecurr);
2683 }
2684
2678# check for function declarations without arguments like "int foo()" 2685# check for function declarations without arguments like "int foo()"
2679 if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) { 2686 if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
2680 if (ERROR("FUNCTION_WITHOUT_ARGS", 2687 if (ERROR("FUNCTION_WITHOUT_ARGS",