linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist
@ 2020-06-10  6:52 SeongJae Park
  2020-06-10  6:52 ` [PATCH v3 1/2] checkpatch: support deprecated terms checking SeongJae Park
                   ` (3 more replies)
  0 siblings, 4 replies; 10+ messages in thread
From: SeongJae Park @ 2020-06-10  6:52 UTC (permalink / raw)
  To: akpm, apw, joe; +Cc: colin.king, sj38.park, linux-kernel, SeongJae Park

From: SeongJae Park <sjpark@amazon.de>

This patchset 1) adds support of deprecated terms in the 'checkpatch.pl'
and 2) set the 'blacklist' and 'whitelist' as deprecated with
replacement suggestion of 'blocklist' and 'allowlist', because the
suggestions are incontrovertible, doesn't make people hurt, and more
self-explanatory.

The patches are based on latest 'next/master'.  You can get the complete
git tree at:

https://github.com/sjp38/linux/tree/patches/checkpatch/deprecate_blacklist_whitelist_on_next


Patch History
=============

Changes from v2
(https://lore.kernel.org/lkml/20200609122549.26304-1-sjpark@amazon.com/)
 - Implement and use deprecated terms check

Changes from v1
(https://lore.kernel.org/lkml/20200609121843.24147-1-sjpark@amazon.com/)
 - Remove unnecessary commit message

SeongJae Park (2):
  checkpatch: support deprecated terms checking
  scripts/deprecated_terms: Recommend blocklist/allowlist instead of
    blacklist/whitelist

 scripts/checkpatch.pl        | 44 ++++++++++++++++++++++++++++++++++++
 scripts/deprecated_terms.txt |  7 ++++++
 2 files changed, 51 insertions(+)
 create mode 100644 scripts/deprecated_terms.txt

-- 
2.17.1


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [PATCH v3 1/2] checkpatch: support deprecated terms checking
  2020-06-10  6:52 [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
@ 2020-06-10  6:52 ` SeongJae Park
  2020-06-10  7:13   ` Joe Perches
  2020-06-10  6:52 ` [PATCH v3 2/2] scripts/deprecated_terms: Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 10+ messages in thread
From: SeongJae Park @ 2020-06-10  6:52 UTC (permalink / raw)
  To: akpm, apw, joe; +Cc: colin.king, sj38.park, linux-kernel, SeongJae Park

From: SeongJae Park <sjpark@amazon.de>

Some terms could be deprecated for various reasons, but it is hard to
update the entire old usages.  That said, we could at least encourage
new patches to use the suggested replacements.  This commit adds check
of deprecated terms in the 'checkpatch.pl' for that.  The script will
get deprecated terms and suggested replacements of those from
'scripts/deprecated_terms.txt' file and warn if the deprecated terms are
used.  The mechanism and the format of the file are almost the same as
that of 'spelling.txt'.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
 scripts/checkpatch.pl        | 44 ++++++++++++++++++++++++++++++++++++
 scripts/deprecated_terms.txt |  5 ++++
 2 files changed, 49 insertions(+)
 create mode 100644 scripts/deprecated_terms.txt

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 524df88f9364..970e0444dc1f 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -57,6 +57,7 @@ my $max_line_length = 100;
 my $ignore_perl_version = 0;
 my $minimum_perl_version = 5.10.0;
 my $min_conf_desc_length = 4;
+my $deprecated_terms_file = "$D/deprecated_terms.txt";
 my $spelling_file = "$D/spelling.txt";
 my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
@@ -692,6 +693,31 @@ our $allowed_asm_includes = qr{(?x:
 )};
 # memory.h: ARM has a custom one
 
+# Load deprecated terms and build regular expression list.
+my $deprecated_terms;
+my %deprecated_terms_fix;
+
+if (open(my $deprecates, '<', $deprecated_terms_file)) {
+	while (<$deprecates>) {
+		my $line = $_;
+
+		$line =~ s/\s*\n?$//g;
+		$line =~ s/^\s*//g;
+
+		next if ($line =~ m/^\s*#/);
+		next if ($line =~ m/^\s*$/);
+
+		my ($suspect, $fix) = split(/\|\|/, $line);
+
+		$deprecated_terms_fix{$suspect} = $fix;
+	}
+	close($deprecates);
+} else {
+	warn "No deprecated term will be found - file '$deprecated_terms_file': $!\n";
+}
+
+$deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
+
 # Load common spelling mistakes and build regular expression list.
 my $misspellings;
 my %spelling_fix;
@@ -2957,6 +2983,24 @@ sub process {
 			}
 		}
 
+# Check for deprecated terms
+		if (defined($deprecated_terms) &&
+		    ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
+			while ($rawline =~ /(?:^|[^a-z@])($deprecated_terms)(?:\b|$|[^a-z@])/gi) {
+				my $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) &&
+				    $fix) {
+					$fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($deprecated_term)($|[^A-Za-z@])/$1$suggested$3/;
+				}
+			}
+		}
+
 # Check for various typo / spelling mistakes
 		if (defined($misspellings) &&
 		    ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
new file mode 100644
index 000000000000..6faa06451c3d
--- /dev/null
+++ b/scripts/deprecated_terms.txt
@@ -0,0 +1,5 @@
+# License: GPLv2
+#
+# The format of each line is:
+# deprecated||suggested
+#
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* [PATCH v3 2/2] scripts/deprecated_terms: Recommend blocklist/allowlist instead of blacklist/whitelist
  2020-06-10  6:52 [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
  2020-06-10  6:52 ` [PATCH v3 1/2] checkpatch: support deprecated terms checking SeongJae Park
@ 2020-06-10  6:52 ` SeongJae Park
  2020-06-10 13:54   ` SeongJae Park
  2020-06-10  7:06 ` [PATCH v3 0/2] " Joe Perches
  2020-06-14 21:15 ` Pavel Machek
  3 siblings, 1 reply; 10+ messages in thread
From: SeongJae Park @ 2020-06-10  6:52 UTC (permalink / raw)
  To: akpm, apw, joe; +Cc: colin.king, sj38.park, linux-kernel, SeongJae Park

From: SeongJae Park <sjpark@amazon.de>

This commit recommends the patches to replace 'blacklist' and
'whitelist' with the 'blocklist' and 'allowlist', because the new
suggestions are incontrovertible, doesn't make people hurt, and more
self-explanatory.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
 scripts/deprecated_terms.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
index 6faa06451c3d..102a0c82c6a0 100644
--- a/scripts/deprecated_terms.txt
+++ b/scripts/deprecated_terms.txt
@@ -3,3 +3,5 @@
 # The format of each line is:
 # deprecated||suggested
 #
+blacklist||blocklist
+whitelist||allowlist
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist
  2020-06-10  6:52 [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
  2020-06-10  6:52 ` [PATCH v3 1/2] checkpatch: support deprecated terms checking SeongJae Park
  2020-06-10  6:52 ` [PATCH v3 2/2] scripts/deprecated_terms: Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
@ 2020-06-10  7:06 ` Joe Perches
  2020-06-14 21:15 ` Pavel Machek
  3 siblings, 0 replies; 10+ messages in thread
From: Joe Perches @ 2020-06-10  7:06 UTC (permalink / raw)
  To: SeongJae Park, akpm, apw
  Cc: colin.king, sj38.park, linux-kernel, SeongJae Park

On Wed, 2020-06-10 at 08:52 +0200, SeongJae Park wrote:
> This patchset 1) adds support of deprecated terms in the 'checkpatch.pl'
> and 2) set the 'blacklist' and 'whitelist' as deprecated with
> replacement suggestion of 'blocklist' and 'allowlist', because the
> suggestions are incontrovertible, doesn't make people hurt, and more
> self-explanatory.

I don't care for the politics of the patch myself.

From a technical perspective, it may be better to
have a single routine for both spelling and whatever
this is called.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 1/2] checkpatch: support deprecated terms checking
  2020-06-10  6:52 ` [PATCH v3 1/2] checkpatch: support deprecated terms checking SeongJae Park
@ 2020-06-10  7:13   ` Joe Perches
  2020-06-10  8:01     ` SeongJae Park
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2020-06-10  7:13 UTC (permalink / raw)
  To: SeongJae Park, akpm, apw
  Cc: colin.king, sj38.park, linux-kernel, SeongJae Park

On Wed, 2020-06-10 at 08:52 +0200, SeongJae Park wrote:
> From: SeongJae Park <sjpark@amazon.de>
> 
> Some terms could be deprecated for various reasons, but it is hard to
> update the entire old usages.  That said, we could at least encourage
> new patches to use the suggested replacements.  This commit adds check
> of deprecated terms in the 'checkpatch.pl' for that.  The script will
> get deprecated terms and suggested replacements of those from
> 'scripts/deprecated_terms.txt' file and warn if the deprecated terms are
> used.  The mechanism and the format of the file are almost the same as
> that of 'spelling.txt'.
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
[]
> +# Load deprecated terms and build regular expression list.
> +my $deprecated_terms;
> +my %deprecated_terms_fix;
> +
> +if (open(my $deprecates, '<', $deprecated_terms_file)) {
> +	while (<$deprecates>) {
> +		my $line = $_;
> +
> +		$line =~ s/\s*\n?$//g;
> +		$line =~ s/^\s*//g;
> +
> +		next if ($line =~ m/^\s*#/);
> +		next if ($line =~ m/^\s*$/);
> +
> +		my ($suspect, $fix) = split(/\|\|/, $line);
> +
> +		$deprecated_terms_fix{$suspect} = $fix;
> +	}
> +	close($deprecates);
> +} else {
> +	warn "No deprecated term will be found - file '$deprecated_terms_file': $!\n";
> +}
> +
> +$deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
> +

This is a direct copy of the spelling dictionary
loading code, so maybe these could be consolidated.



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH v3 1/2] checkpatch: support deprecated terms checking
  2020-06-10  7:13   ` Joe Perches
@ 2020-06-10  8:01     ` SeongJae Park
  2020-06-10  8:45       ` Joe Perches
  0 siblings, 1 reply; 10+ messages in thread
From: SeongJae Park @ 2020-06-10  8:01 UTC (permalink / raw)
  To: Joe Perches
  Cc: SeongJae Park, akpm, apw, colin.king, sj38.park, linux-kernel,
	SeongJae Park

On Wed, 10 Jun 2020 00:13:42 -0700 Joe Perches <joe@perches.com> wrote:

> On Wed, 2020-06-10 at 08:52 +0200, SeongJae Park wrote:
> > From: SeongJae Park <sjpark@amazon.de>
> > 
> > Some terms could be deprecated for various reasons, but it is hard to
> > update the entire old usages.  That said, we could at least encourage
> > new patches to use the suggested replacements.  This commit adds check
> > of deprecated terms in the 'checkpatch.pl' for that.  The script will
> > get deprecated terms and suggested replacements of those from
> > 'scripts/deprecated_terms.txt' file and warn if the deprecated terms are
> > used.  The mechanism and the format of the file are almost the same as
> > that of 'spelling.txt'.
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
> > +# Load deprecated terms and build regular expression list.
> > +my $deprecated_terms;
> > +my %deprecated_terms_fix;
> > +
> > +if (open(my $deprecates, '<', $deprecated_terms_file)) {
> > +	while (<$deprecates>) {
> > +		my $line = $_;
> > +
> > +		$line =~ s/\s*\n?$//g;
> > +		$line =~ s/^\s*//g;
> > +
> > +		next if ($line =~ m/^\s*#/);
> > +		next if ($line =~ m/^\s*$/);
> > +
> > +		my ($suspect, $fix) = split(/\|\|/, $line);
> > +
> > +		$deprecated_terms_fix{$suspect} = $fix;
> > +	}
> > +	close($deprecates);
> > +} else {
> > +	warn "No deprecated term will be found - file '$deprecated_terms_file': $!\n";
> > +}
> > +
> > +$deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
> > +
> 
> This is a direct copy of the spelling dictionary
> loading code, so maybe these could be consolidated.

Agreed, how about below one?

============================= >8 ============================================
From 76987b0f062c981243b49b7bede8b68de30ac3e2 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sjpark@amazon.de>
Date: Wed, 10 Jun 2020 07:11:57 +0200
Subject: [PATCH] checkpatch: support deprecated terms checking

Some terms could be deprecated for various reasons, but it is hard to
update the entire old usages.  That said, we could at least encourage
new patches to use the suggested replacements.  This commit adds check
of deprecated terms in the 'checkpatch.pl' for that.  The script will
get deprecated terms and suggested replacements of those from
'scripts/deprecated_terms.txt' file and warn if the deprecated terms are
used.  The mechanism and the format of the file are almost the same as
that of 'spelling.txt'.  For the reason, this commit modularizes the
read of the 'spelling.txt' and reuses.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
 scripts/checkpatch.pl        | 61 +++++++++++++++++++++++++++---------
 scripts/deprecated_terms.txt |  5 +++
 2 files changed, 51 insertions(+), 15 deletions(-)
 create mode 100644 scripts/deprecated_terms.txt

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 524df88f9364..226f24e1f1f3 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -57,6 +57,7 @@ my $max_line_length = 100;
 my $ignore_perl_version = 0;
 my $minimum_perl_version = 5.10.0;
 my $min_conf_desc_length = 4;
+my $deprecated_terms_file = "$D/deprecated_terms.txt";
 my $spelling_file = "$D/spelling.txt";
 my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
@@ -692,29 +693,41 @@ our $allowed_asm_includes = qr{(?x:
 )};
 # memory.h: ARM has a custom one
 
-# Load common spelling mistakes and build regular expression list.
-my $misspellings;
-my %spelling_fix;
+sub read_word_corrections {
+	my ($file) = @_;
+	my $suspects;
+	my %fixes;
 
-if (open(my $spelling, '<', $spelling_file)) {
-	while (<$spelling>) {
-		my $line = $_;
+	if (open(my $corrections, '<', $file)) {
+		while (<$corrections>) {
+			my $line = $_;
 
-		$line =~ s/\s*\n?$//g;
-		$line =~ s/^\s*//g;
+			$line =~ s/\s*\n?$//g;
+			$line =~ s/^\s*//g;
 
-		next if ($line =~ m/^\s*#/);
-		next if ($line =~ m/^\s*$/);
+			next if ($line =~ m/^\s*#/);
+			next if ($line =~ m/^\s*$/);
 
-		my ($suspect, $fix) = split(/\|\|/, $line);
+			my ($suspect, $fix) = split(/\|\|/, $line);
 
-		$spelling_fix{$suspect} = $fix;
+			$fixes{$suspect} = $fix;
+		}
+		close($corrections);
+	} else {
+		warn "No correction will be found - file '$file': $!\n";
 	}
-	close($spelling);
-} else {
-	warn "No typos will be found - file '$spelling_file': $!\n";
+
+	return %fixes
 }
 
+# Load deprecated terms and build regular expression list.
+my %deprecated_terms_fix = read_word_corrections($deprecated_terms_file);
+my $deprecated_terms = join("|", sort keys %deprecated_terms_fix) if keys %deprecated_terms_fix;
+
+# Load common spelling mistakes and build regular expression list.
+my $misspellings;
+my %spelling_fix = read_word_corrections($spelling_file);
+
 if ($codespell) {
 	if (open(my $spelling, '<', $codespellfile)) {
 		while (<$spelling>) {
@@ -2957,6 +2970,24 @@ sub process {
 			}
 		}
 
+# Check for deprecated terms
+		if (defined($deprecated_terms) &&
+		    ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
+			while ($rawline =~ /(?:^|[^a-z@])($deprecated_terms)(?:\b|$|[^a-z@])/gi) {
+				my $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) &&
+				    $fix) {
+					$fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($deprecated_term)($|[^A-Za-z@])/$1$suggested$3/;
+				}
+			}
+		}
+
 # Check for various typo / spelling mistakes
 		if (defined($misspellings) &&
 		    ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
new file mode 100644
index 000000000000..6faa06451c3d
--- /dev/null
+++ b/scripts/deprecated_terms.txt
@@ -0,0 +1,5 @@
+# License: GPLv2
+#
+# The format of each line is:
+# deprecated||suggested
+#
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: Re: [PATCH v3 1/2] checkpatch: support deprecated terms checking
  2020-06-10  8:01     ` SeongJae Park
@ 2020-06-10  8:45       ` Joe Perches
  2020-06-10  9:09         ` SeongJae Park
  0 siblings, 1 reply; 10+ messages in thread
From: Joe Perches @ 2020-06-10  8:45 UTC (permalink / raw)
  To: SeongJae Park
  Cc: akpm, apw, colin.king, sj38.park, linux-kernel, SeongJae Park

On Wed, 2020-06-10 at 10:01 +0200, SeongJae Park wrote:
> On Wed, 10 Jun 2020 00:13:42 -0700 Joe Perches <joe@perches.com> wrote:
[]
> > This is a direct copy of the spelling dictionary
> > loading code, so maybe these could be consolidated.
> 
> Agreed, how about below one?
[]
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index 524df88f9364..226f24e1f1f3 100755
[]
> +sub read_word_corrections {
> +	my ($file) = @_;
> +	my $suspects;
> +	my %fixes;

Right.

But I think this should take a hash reference
as the second argument so the complete hash
isn't created and returned.

[]

> +# Load deprecated terms and build regular expression list.
> +my %deprecated_terms_fix = read_word_corrections($deprecated_terms_file);

So this might be something like:

my %deprecated_terms;
read_word_corrections($deprecated_terms_file, \%deprecated_terms);

etc...



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: Re: Re: [PATCH v3 1/2] checkpatch: support deprecated terms checking
  2020-06-10  8:45       ` Joe Perches
@ 2020-06-10  9:09         ` SeongJae Park
  0 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2020-06-10  9:09 UTC (permalink / raw)
  To: Joe Perches
  Cc: SeongJae Park, akpm, apw, colin.king, sj38.park, linux-kernel,
	SeongJae Park

On Wed, 10 Jun 2020 01:45:41 -0700 Joe Perches <joe@perches.com> wrote:

> On Wed, 2020-06-10 at 10:01 +0200, SeongJae Park wrote:
> > On Wed, 10 Jun 2020 00:13:42 -0700 Joe Perches <joe@perches.com> wrote:
> []
> > > This is a direct copy of the spelling dictionary
> > > loading code, so maybe these could be consolidated.
> > 
> > Agreed, how about below one?
> []
> > diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> > index 524df88f9364..226f24e1f1f3 100755
> []
> > +sub read_word_corrections {
> > +	my ($file) = @_;
> > +	my $suspects;
> > +	my %fixes;
> 
> Right.
> 
> But I think this should take a hash reference
> as the second argument so the complete hash
> isn't created and returned.
> 
> []
> 
> > +# Load deprecated terms and build regular expression list.
> > +my %deprecated_terms_fix = read_word_corrections($deprecated_terms_file);
> 
> So this might be something like:
> 
> my %deprecated_terms;
> read_word_corrections($deprecated_terms_file, \%deprecated_terms);
> 
> etc...

Appreciate your nice suggestion!  So, I updated the patch as below:

================================= >8 ==========================================
From 0bcba551f429b0ccec4183437098b3b961d0a724 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sjpark@amazon.de>
Date: Wed, 10 Jun 2020 07:11:57 +0200
Subject: [PATCH] checkpatch: support deprecated terms checking

Some terms could be deprecated for various reasons, but it is hard to
update the entire old usages.  That said, we could at least encourage
new patches to use the suggested replacements.  This commit adds check
of deprecated terms in the 'checkpatch.pl' for that.  The script will
get deprecated terms and suggested replacements of those from
'scripts/deprecated_terms.txt' file and warn if the deprecated terms are
used.  The mechanism and the format of the file are almost the same as
that of 'spelling.txt'.  For the reason, this commit modularizes the
read of the 'spelling.txt' and reuses.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
 scripts/checkpatch.pl        | 60 +++++++++++++++++++++++++++---------
 scripts/deprecated_terms.txt |  5 +++
 2 files changed, 50 insertions(+), 15 deletions(-)
 create mode 100644 scripts/deprecated_terms.txt

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 524df88f9364..c672091932bb 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -57,6 +57,7 @@ my $max_line_length = 100;
 my $ignore_perl_version = 0;
 my $minimum_perl_version = 5.10.0;
 my $min_conf_desc_length = 4;
+my $deprecated_terms_file = "$D/deprecated_terms.txt";
 my $spelling_file = "$D/spelling.txt";
 my $codespell = 0;
 my $codespellfile = "/usr/share/codespell/dictionary.txt";
@@ -692,29 +693,40 @@ our $allowed_asm_includes = qr{(?x:
 )};
 # memory.h: ARM has a custom one
 
-# Load common spelling mistakes and build regular expression list.
-my $misspellings;
-my %spelling_fix;
+sub read_word_corrections {
+	my ($file, $fixesRef) = @_;
+	my $suspects;
 
-if (open(my $spelling, '<', $spelling_file)) {
-	while (<$spelling>) {
-		my $line = $_;
+	if (open(my $corrections, '<', $file)) {
+		while (<$corrections>) {
+			my $line = $_;
 
-		$line =~ s/\s*\n?$//g;
-		$line =~ s/^\s*//g;
+			$line =~ s/\s*\n?$//g;
+			$line =~ s/^\s*//g;
 
-		next if ($line =~ m/^\s*#/);
-		next if ($line =~ m/^\s*$/);
+			next if ($line =~ m/^\s*#/);
+			next if ($line =~ m/^\s*$/);
 
-		my ($suspect, $fix) = split(/\|\|/, $line);
+			my ($suspect, $fix) = split(/\|\|/, $line);
 
-		$spelling_fix{$suspect} = $fix;
+			$fixesRef->{$suspect} = $fix;
+		}
+		close($corrections);
+	} else {
+		warn "No correction will be found - file '$file': $!\n";
 	}
-	close($spelling);
-} else {
-	warn "No typos will be found - file '$spelling_file': $!\n";
 }
 
+# Load deprecated terms and build regular expression list.
+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;
+
+# Load common spelling mistakes and build regular expression list.
+my $misspellings;
+my %spelling_fix;
+read_word_corrections($spelling_file, \%spelling_fix);
+
 if ($codespell) {
 	if (open(my $spelling, '<', $codespellfile)) {
 		while (<$spelling>) {
@@ -2957,6 +2969,24 @@ sub process {
 			}
 		}
 
+# Check for deprecated terms
+		if (defined($deprecated_terms) &&
+		    ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
+			while ($rawline =~ /(?:^|[^a-z@])($deprecated_terms)(?:\b|$|[^a-z@])/gi) {
+				my $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) &&
+				    $fix) {
+					$fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($deprecated_term)($|[^A-Za-z@])/$1$suggested$3/;
+				}
+			}
+		}
+
 # Check for various typo / spelling mistakes
 		if (defined($misspellings) &&
 		    ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
new file mode 100644
index 000000000000..6faa06451c3d
--- /dev/null
+++ b/scripts/deprecated_terms.txt
@@ -0,0 +1,5 @@
+# License: GPLv2
+#
+# The format of each line is:
+# deprecated||suggested
+#
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 2/2] scripts/deprecated_terms: Recommend blocklist/allowlist instead of blacklist/whitelist
  2020-06-10  6:52 ` [PATCH v3 2/2] scripts/deprecated_terms: Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
@ 2020-06-10 13:54   ` SeongJae Park
  0 siblings, 0 replies; 10+ messages in thread
From: SeongJae Park @ 2020-06-10 13:54 UTC (permalink / raw)
  To: SeongJae Park
  Cc: akpm, apw, joe, jslaby, colin.king, sj38.park, linux-kernel,
	SeongJae Park

Based on Jiri's feedback[1], I'm updating the replacement suggestion of blacklist
from blocklist to denylist, as the previous one might be confused to block
layer people.  Also, the new recommendation is more short ;)

[1] https://lore.kernel.org/lkml/20200610091655.4682-1-sjpark@amazon.com/

================================== >8 =========================================
From 1376e327de8316ef30c393507b29d70d38bffd05 Mon Sep 17 00:00:00 2001
From: SeongJae Park <sjpark@amazon.de>
Date: Wed, 10 Jun 2020 07:23:33 +0200
Subject: [PATCH v3.1] scripts/deprecated_terms: Recommend denylist/allowlist
 instead of blacklist/whitelist

This commit recommends the patches to replace 'blacklist' and
'whitelist' with the 'denylist' and 'allowlist', because the new
suggestions are incontrovertible, doesn't make people hurt, and more
self-explanatory.

Signed-off-by: SeongJae Park <sjpark@amazon.de>
---
 scripts/deprecated_terms.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/scripts/deprecated_terms.txt b/scripts/deprecated_terms.txt
index 6faa06451c3d..4512ef5d5ffa 100644
--- a/scripts/deprecated_terms.txt
+++ b/scripts/deprecated_terms.txt
@@ -3,3 +3,5 @@
 # The format of each line is:
 # deprecated||suggested
 #
+blacklist||denylist
+whitelist||allowlist
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 10+ messages in thread

* Re: [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist
  2020-06-10  6:52 [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
                   ` (2 preceding siblings ...)
  2020-06-10  7:06 ` [PATCH v3 0/2] " Joe Perches
@ 2020-06-14 21:15 ` Pavel Machek
  3 siblings, 0 replies; 10+ messages in thread
From: Pavel Machek @ 2020-06-14 21:15 UTC (permalink / raw)
  To: SeongJae Park
  Cc: akpm, apw, joe, colin.king, sj38.park, linux-kernel, SeongJae Park

[-- Attachment #1: Type: text/plain, Size: 591 bytes --]

On Wed 2020-06-10 08:52:21, SeongJae Park wrote:
> From: SeongJae Park <sjpark@amazon.de>
> 
> This patchset 1) adds support of deprecated terms in the 'checkpatch.pl'
> and 2) set the 'blacklist' and 'whitelist' as deprecated with
> replacement suggestion of 'blocklist' and 'allowlist', because the
> suggestions are incontrovertible, doesn't make people hurt, and more
> self-explanatory.

I don't think this is good idea.
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2020-06-14 21:15 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-10  6:52 [PATCH v3 0/2] Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
2020-06-10  6:52 ` [PATCH v3 1/2] checkpatch: support deprecated terms checking SeongJae Park
2020-06-10  7:13   ` Joe Perches
2020-06-10  8:01     ` SeongJae Park
2020-06-10  8:45       ` Joe Perches
2020-06-10  9:09         ` SeongJae Park
2020-06-10  6:52 ` [PATCH v3 2/2] scripts/deprecated_terms: Recommend blocklist/allowlist instead of blacklist/whitelist SeongJae Park
2020-06-10 13:54   ` SeongJae Park
2020-06-10  7:06 ` [PATCH v3 0/2] " Joe Perches
2020-06-14 21:15 ` Pavel Machek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).