diff options
author | Elyes Haouas <ehaouas@noos.fr> | 2023-08-01 18:21:26 +0200 |
---|---|---|
committer | Elyes Haouas <ehaouas@noos.fr> | 2023-08-09 20:41:21 +0000 |
commit | e572765be1a99c58c54307c43eace2b069e7306e (patch) | |
tree | 1e039b2aac6c9e26ae04a421dc404db94b07cbba /util/lint | |
parent | dcb59dcec4bfaac790d72efb38a5af6526c7dfc1 (diff) |
lint/checkpatch: Add check for old-style declarations
This reduce the difference with linux v6.5-rc4. and check for
const static or static <non ptr type> const declarations.
Change-Id: Ib4b37e130f2edbfe0385f0707a8c910a244bcfc7
Signed-off-by: Elyes Haouas <ehaouas@noos.fr>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/70202
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Martin L Roth <gaumless@gmail.com>
Diffstat (limited to 'util/lint')
-rwxr-xr-x | util/lint/checkpatch.pl | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/util/lint/checkpatch.pl b/util/lint/checkpatch.pl index 21704ac74b..c843c6cc6b 100755 --- a/util/lint/checkpatch.pl +++ b/util/lint/checkpatch.pl @@ -4249,6 +4249,18 @@ sub process { } } +# check for const static or static <non ptr type> const declarations +# prefer 'static const <foo>' over 'const static <foo>' and 'static <foo> const' + if ($sline =~ /^\+\s*const\s+static\s+($Type)\b/ || + $sline =~ /^\+\s*static\s+($BasicType)\s+const\b/) { + if (WARN("STATIC_CONST", + "Move const after static - use 'static const $1'\n" . $herecurr) && + $fix) { + $fixed[$fixlinenr] =~ s/\bconst\s+static\b/static const/; + $fixed[$fixlinenr] =~ s/\bstatic\s+($BasicType)\s+const\b/static const $1/; + } + } + # check for non-global char *foo[] = {"bar", ...} declarations. if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) { WARN("STATIC_CONST_CHAR_ARRAY", |