aboutsummaryrefslogtreecommitdiff
path: root/util/lint
diff options
context:
space:
mode:
authorElyes Haouas <ehaouas@noos.fr>2023-08-01 18:18:32 +0200
committerElyes Haouas <ehaouas@noos.fr>2023-08-09 20:40:48 +0000
commitdcb59dcec4bfaac790d72efb38a5af6526c7dfc1 (patch)
tree843204baa5d474eaf9a233679c68066680e05e29 /util/lint
parent32cae137142c3f94d601ce9275e1b54300d2b853 (diff)
lint/checkpatch: Add check for initialized const char arrays
This reduces the difference with linux v6.5-rc4. Change-Id: I9f0e9f12a177c32b401fda74cbb30c5c259b3744 Signed-off-by: Elyes Haouas <ehaouas@noos.fr> Reviewed-on: https://review.coreboot.org/c/coreboot/+/70201 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Martin L Roth <gaumless@gmail.com>
Diffstat (limited to 'util/lint')
-rwxr-xr-xutil/lint/checkpatch.pl9
1 files changed, 9 insertions, 0 deletions
diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl
index 91cf2da840..21704ac74b 100755
--- a/util/lint/checkpatch.pl
+++ b/util/lint/checkpatch.pl
@@ -4221,6 +4221,15 @@ sub process {
$herecurr);
}
+# check for initialized const char arrays that should be static const
+ if ($line =~ /^\+\s*const\s+(char|unsigned\s+char|_*u8|(?:[us]_)?int8_t)\s+\w+\s*\[\s*(?:\w+\s*)?\]\s*=\s*"/) {
+ if (WARN("STATIC_CONST_CHAR_ARRAY",
+ "const array should probably be static const\n" . $herecurr) &&
+ $fix) {
+ $fixed[$fixlinenr] =~ s/(^.\s*)const\b/${1}static const/;
+ }
+ }
+
# check for static char foo[] = "bar" declarations.
if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
WARN("STATIC_CONST_CHAR_ARRAY",