checkpatch.pl: Warn on duplicate sysctl local variable
PATCH 1/1 checkpatch.pl: Warn on duplicate sysctl local variable
Commit 6a33853c5773 ("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
#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 #28: FILE: arch/arm/kernel/isa.c:49:
+ .extra2 = &int_max,
total: 0 errors, 2 warnings, 14 lines checked
--- scripts/checkpatch.pl | 7 +++++++ 1 file changed, 7 insertions(+)
scripts/checkpatch.pl +7 -0
@@ -6639,6 +6639,13 @@ sub process { "unknown module license " . $extracted_string . "\n" . $herecurr); } } + +# check for sysctl duplicate constants + if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max|max_int)\b/) { + my $extracted_string = get_quoted_string($line, $rawline); + WARN("DUPLICATED_SYSCTL_CONST", + "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h" . $extracted_string . "\n" . $herecurr); + } } # If we have no input at all, then there is nothing to report on
Signature · 1 line
2.21.0
Joe Perches
maintainerQuoted 4 lines · Matteo Croce
Commit
6a33853c5773("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 actl_tablestruct:
[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0
[]
scripts/checkpatch.pl sub process { · line 6648
Quoted 11 lines
scripts/checkpatch.pl +7
-0@@ -6639,6 +6639,13 @@ sub process { "unknown module license " . $extracted_string . "\n" . $herecurr); } } + +# check for sysctl duplicate constants + if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max|max_int)\b/) { + my $extracted_string = get_quoted_string($line, $rawline); + WARN("DUPLICATED_SYSCTL_CONST", + "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h" . $extracted_string . "\n" . $herecurr); + }
why is $extracted_string used here?
Quoted 9 lines · Joe Perches
Quoted 4 lines · Matteo Croce
Commit
6a33853c5773("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 actl_tablestruct:[]
scripts/checkpatch.pl
Quoted 1 line
scripts/checkpatch.pl +0
-0[]
Quoted 15 lines
scripts/checkpatch.pl sub process { · line 6648
Quoted 11 lines
scripts/checkpatch.pl +7
-0@@ -6639,6 +6639,13 @@ sub process { "unknown module license " . $extracted_string . "\n" . $herecurr); } } + +# check for sysctl duplicate constants + if ($line =~ /\.extra[12]\s*=\s*&(zero|one|int_max|max_int)\b/) { + my $extracted_string = get_quoted_string($line, $rawline); + WARN("DUPLICATED_SYSCTL_CONST", + "duplicated sysctl range checking value '$1', consider using the shared one in include/linux/sysctl.h" . $extracted_string . "\n" . $herecurr); + }why is $extracted_string used here?
Right, it's always empty. I'm sending a v2.
Regards,
Signature · 2 lines
Matteo Croce per aspera ad upstream