[PATCH 2/3] checkpatch: tweak extern in C warning

From: Jim Cromie
Date: Fri Jun 25 2021 - 23:40:35 EST


The extern-in-C rule has one important exception: the symbol is
defined in/by the linker script. By convention, these almost always
contain: _start, _stop, _end. Suppress the warning on such symbols.

Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
---
scripts/checkpatch.pl | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 4fe9fab20009..a8dfba53b593 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -6910,7 +6910,8 @@ sub process {
$stat =~ /^.\s*extern\s+/)
{
WARN("AVOID_EXTERNS",
- "externs should be avoided in .c files\n" . $herecurr);
+ "externs should be avoided in .c files\n($stat)\n" . $herecurr)
+ unless $stat =~ /_start|_stop|_end/;
}

# check for function declarations that have arguments without identifier names
--
2.31.1