From e572765be1a99c58c54307c43eace2b069e7306e Mon Sep 17 00:00:00 2001 From: Elyes Haouas Date: Tue, 1 Aug 2023 18:21:26 +0200 Subject: lint/checkpatch: Add check for old-style declarations This reduce the difference with linux v6.5-rc4. and check for const static or static const declarations. Change-Id: Ib4b37e130f2edbfe0385f0707a8c910a244bcfc7 Signed-off-by: Elyes Haouas Reviewed-on: https://review.coreboot.org/c/coreboot/+/70202 Tested-by: build bot (Jenkins) Reviewed-by: Martin L Roth --- util/lint/checkpatch.pl | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'util/lint') 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 const declarations +# prefer 'static const ' over 'const static ' and 'static 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", -- cgit v1.2.3