Skip to content

Commit 6a8d76c

Browse files
teknoravertorvalds
authored andcommitted
checkpatch.pl: warn on duplicate sysctl local variable
Commit d91bff3 ("proc/sysctl: add shared variables for range check") adds some shared const variables to be used instead of a local copy in each source file. Warn when a chunk duplicates one of these values in a ctl_table struct: $ scripts/checkpatch.pl 0001-test-commit.patch WARNING: duplicated sysctl range checking value 'zero', consider using the shared one in include/linux/sysctl.h thesofproject#27: FILE: arch/arm/kernel/isa.c:48: + .extra1 = &zero, WARNING: duplicated sysctl range checking value 'int_max', consider using the shared one in include/linux/sysctl.h thesofproject#28: FILE: arch/arm/kernel/isa.c:49: + .extra2 = &int_max, total: 0 errors, 2 warnings, 14 lines checked Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Matteo Croce <[email protected]> Reviewed-by: Kees Cook <[email protected]> Cc: Joe Perches <[email protected]> Cc: Aaron Tomlin <[email protected]> Cc: Matthew Wilcox <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
1 parent 9f973cb commit 6a8d76c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

scripts/checkpatch.pl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6639,6 +6639,12 @@ sub process {
66396639
"unknown module license " . $extracted_string . "\n" . $herecurr);
66406640
}
66416641
}
6642+
6643+
# check for sysctl duplicate constants
6644+
if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max)\b/) {
6645+
WARN("DUPLICATED_SYSCTL_CONST",
6646+
"duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h\n" . $herecurr);
6647+
}
66426648
}
66436649

66446650
# If we have no input at all, then there is nothing to report on

0 commit comments

Comments
 (0)