diff options
Diffstat (limited to 'scripts/checkpatch.pl')
| -rwxr-xr-x | scripts/checkpatch.pl | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 377f373db6c0..93e84c9504a1 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -3890,14 +3890,23 @@ sub process { | |||
| 3890 | WARN("STATIC_CONST_CHAR_ARRAY", | 3890 | WARN("STATIC_CONST_CHAR_ARRAY", |
| 3891 | "static const char * array should probably be static const char * const\n" . | 3891 | "static const char * array should probably be static const char * const\n" . |
| 3892 | $herecurr); | 3892 | $herecurr); |
| 3893 | } | 3893 | } |
| 3894 | |||
| 3895 | # check for initialized const char arrays that should be static const | ||
| 3896 | if ($line =~ /^\+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*\[\s*(?:\w+\s*)?\]\s*=\s*"/) { | ||
| 3897 | if (WARN("STATIC_CONST_CHAR_ARRAY", | ||
| 3898 | "const array should probably be static const\n" . $herecurr) && | ||
| 3899 | $fix) { | ||
| 3900 | $fixed[$fixlinenr] =~ s/(^.\s*)const\b/${1}static const/; | ||
| 3901 | } | ||
| 3902 | } | ||
| 3894 | 3903 | ||
| 3895 | # check for static char foo[] = "bar" declarations. | 3904 | # check for static char foo[] = "bar" declarations. |
| 3896 | if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) { | 3905 | if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) { |
| 3897 | WARN("STATIC_CONST_CHAR_ARRAY", | 3906 | WARN("STATIC_CONST_CHAR_ARRAY", |
| 3898 | "static char array declaration should probably be static const char\n" . | 3907 | "static char array declaration should probably be static const char\n" . |
| 3899 | $herecurr); | 3908 | $herecurr); |
| 3900 | } | 3909 | } |
| 3901 | 3910 | ||
| 3902 | # check for const <foo> const where <foo> is not a pointer or array type | 3911 | # check for const <foo> const where <foo> is not a pointer or array type |
| 3903 | if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) { | 3912 | if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) { |
