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>
This commit is contained in:
parent
32cae13714
commit
dcb59dcec4
@ -4221,6 +4221,15 @@ sub process {
|
|||||||
$herecurr);
|
$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.
|
# check for static char foo[] = "bar" declarations.
|
||||||
if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
|
if ($line =~ /\bstatic\s+char\s+(\w+)\s*\[\s*\]\s*=\s*"/) {
|
||||||
WARN("STATIC_CONST_CHAR_ARRAY",
|
WARN("STATIC_CONST_CHAR_ARRAY",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user