Skip to content

Commit 8c98248

Browse files
liu-song-6kernel-patches-bot
authored andcommitted
checkpatch: do not apply "initialise globals to 0" check to BPF progs
BPF programs explicitly initialise global variables to 0 to make sure clang (v10 or older) do not put the variables in the common section. Skip "initialise globals to 0" check for BPF programs to elimiate error messages like: ERROR: do not initialise globals to 0 #19: FILE: samples/bpf/tracex1_kern.c:21: Cc: Andy Whitcroft <[email protected]> Cc: Joe Perches <[email protected]> Signed-off-by: Song Liu <[email protected]>
1 parent a24dd8b commit 8c98248

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

scripts/checkpatch.pl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4330,7 +4330,11 @@ sub process {
43304330
}
43314331

43324332
# check for global initialisers.
4333-
if ($line =~ /^\+$Type\s*$Ident(?:\s+$Modifier)*\s*=\s*($zero_initializer)\s*;/) {
4333+
# Do not apply to BPF programs (tools/testing/selftests/bpf/progs/*.c, samples/bpf/*_kern.c, *.bpf.c).
4334+
if ($line =~ /^\+$Type\s*$Ident(?:\s+$Modifier)*\s*=\s*($zero_initializer)\s*;/ &&
4335+
$realfile !~ /^tools\/testing\/selftests\/bpf\/progs\/.*\.c/ &&
4336+
$realfile !~ /^samples\/bpf\/.*_kern.c/ &&
4337+
$realfile !~ /.bpf.c$/) {
43344338
if (ERROR("GLOBAL_INITIALISERS",
43354339
"do not initialise globals to $1\n" . $herecurr) &&
43364340
$fix) {

0 commit comments

Comments
 (0)