[PATCH v3] scripts/deprecatd_terms: provide references

From: SeongJae Park
Date: Sat Jul 25 2020 - 19:14:48 EST


Deprecation of terms could have special rules. For example, 'slave' is
ok for existing usages. Same to 'master', but it's also ok unless it's
used with 'slave'. This commit provides the references for such rules.

Also, because the report became more verbose a little, this commit makes
the report to be made for only one instance of each deprecated term.

Signed-off-by: SeongJae Park <sjpark@xxxxxxxxx>
---
scripts/checkpatch.pl | 6 +++++-
scripts/deprecated_terms.txt | 6 ++++--
2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index e9fde28eb0de..abed47647fb0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -721,6 +721,7 @@ sub read_word_corrections {
my %deprecated_terms_fix;
read_word_corrections($deprecated_terms_file, \%deprecated_terms_fix);
my $deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
+my %deprecates_reported = map

# Load common spelling mistakes and build regular expression list.
my $misspellings;
@@ -2975,13 +2976,16 @@ sub process {
($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
while ($rawline =~ /(?:^|[^a-z@])($deprecated_terms)(?:\b|$|[^a-z@])/gi) {
my $deprecated_term = $1;
+ next if (exists($deprecates_reported{$deprecated_term}));
+ $deprecates_reported{$deprecated_term} = 1;
+
my $suggested = $deprecated_terms_fix{lc($deprecated_term)};
$suggested = ucfirst($suggested) if ($deprecated_term=~ /^[A-Z]/);
$suggested = uc($suggested) if ($deprecated_term =~ /^[A-Z]+$/);
my $msg_level = \&WARN;
$msg_level = \&CHK if ($file);
if (&{$msg_level}("DEPRECATED_TERM",
- "Use of '$deprecated_term' is deprecated, please '$suggested', instead.\n" . $herecurr) &&
+ "Use of '$deprecated_term' is controversial - if not required by specification, perhaps '$suggested' instead. See: scripts/deprecated_terms.txt\n" . $herecurr) &&
$fix) {
$fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($deprecated_term)($|[^A-Za-z@])/$1$suggested$3/;
}
diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
index 1be27a24187b..d92b9c896fce 100644
--- a/scripts/deprecated_terms.txt
+++ b/scripts/deprecated_terms.txt
@@ -3,8 +3,10 @@
# The format of each line is:
# deprecated||suggested
#
+# If special rules are applied on the terms, please comment those.
+#
+# Refer to "4) Naming" section of Documentation/process/coding-style.rst for
+# below three terms.
blacklist||(denylist|blocklist)
-# For other alternatives of 'slave', Please refer to
-# Documentation/process/coding-style.rst
slave||(secondary|target|...)
whitelist||(allowlist|passlist)
--
2.17.1