lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1408666251.22832.33.camel@joe-AO725>
Date:	Thu, 21 Aug 2014 17:10:51 -0700
From:	Joe Perches <joe@...ches.com>
To:	Kees Cook <keescook@...omium.org>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	Andy Whitcroft <apw@...onical.com>,
	Andrew Morton <akpm@...ux-foundation.org>,
	"David S. Miller" <davem@...emloft.net>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Mauro Carvalho Chehab <m.chehab@...sung.com>,
	Antti Palosaari <crope@....fi>,
	Masanari Iida <standby24x7@...il.com>,
	Geert Uytterhoeven <geert@...ux-m68k.org>,
	linux-doc <linux-doc@...r.kernel.org>
Subject: Re: [PATCH] checkpatch: look for common misspellings

On Thu, 2014-08-21 at 18:01 -0500, Kees Cook wrote:
> On Thu, Aug 21, 2014 at 12:18 PM, Joe Perches <joe@...ches.com> wrote:
> > On Thu, 2014-08-21 at 09:20 -0700, Kees Cook wrote:
> >> Check for misspellings, based on Debian's lintian list. Several false
> >> positives were removed, and several additional words added that were
> >> common in the kernel:
> > []
> >> diff --git a/MAINTAINERS b/MAINTAINERS
> > []
> >> @@ -2311,6 +2311,7 @@ M:      Andy Whitcroft <apw@...onical.com>
> >>  M:   Joe Perches <joe@...ches.com>
> >>  S:   Maintained
> >>  F:   scripts/checkpatch.pl
> >> +F:   scripts/spelling.txt
> >
> > I don't want to be responsible for misspellings.
> >
> > Maybe this should be moved to another section
> > and you could be added as a maintainer for that.
> 
> Okay, sure. Happy to do so. Or maybe some -docs folks want to join me? :)

Masanari Iida does a lot of these (added to cc)
Maybe he's interested in helping out or adding
his collection of misspellings to spelling.txt.

Maybe Geert Uytterhoeven too (also cc'd)

Maybe the lintian list should also be added if it's
around somewhere instead of trying to duplicate it.

http://anonscm.debian.org/cgit/lintian/lintian.git/tree/data/spelling/corrections

[]

> Cool, let me grok your suggested patch and reply. Thanks for looking this over!

A defect was it checked only for all lower-case uses.

Here's what I have now.  It:

o relocates the check above specific file extension tests
o checks lines in the commit log and any added lines
o checks case-insensitive misspellings
o does Proper case corrections for start of sentences
o adds a working --fix option.

Maybe you could merge it with your other changes.

You could add some tag like improved-by: / signed-off-by,
acked-by: for me if you want.

---
 scripts/checkpatch.pl | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b385bcb..9075ed5 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -9,7 +9,8 @@ use strict;
 use POSIX;
 
 my $P = $0;
-$P =~ s@.*/@@g;
+$P =~ s@(.*)/@@g;
+my $D = $1;
 
 my $V = '0.32';
 
@@ -43,6 +44,7 @@ my $configuration_file = ".checkpatch.conf";
 my $max_line_length = 80;
 my $ignore_perl_version = 0;
 my $minimum_perl_version = 5.10.0;
+my $spelling_file = "$D/spelling.txt";
 
 sub help {
 	my ($exitcode) = @_;
@@ -429,6 +431,29 @@ 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_list;
+my %spelling_fix;
+open(my $spelling, '<', $spelling_file)
+    or die "$P: Can't open $spelling_file for reading: $!\n";
+while (<$spelling>) {
+	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);
+
+	push(@spelling_list, $suspect);
+	$spelling_fix{$suspect} = $fix;
+}
+close($spelling);
+$misspellings = join("|", @spelling_list);
+
 sub build_types {
 	my $mods = "(?x:  \n" . join("|\n  ", @modifierList) . "\n)";
 	my $all = "(?x:  \n" . join("|\n  ", @typeList) . "\n)";
@@ -2337,6 +2362,20 @@ sub process {
 			}
 		}
 
+# Check for various spelling / typo mistakes
+		if ($in_commit_log || $line =~ /^\+/) {
+			while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\$|[^a-z@])/gi) {
+				my $typo = $1;
+				my $fixed = $spelling_fix{lc($typo)};
+				$fixed = ucfirst($fixed) if ($typo =~ /^[A-Z]/);
+				if (WARN("TYPO_SPELLING",
+					 "'$typo' may be misspelled - perhaps '$fixed'?\n" . $herecurr) &&
+				    $fix) {
+					$fixed[$fixlinenr] =~ s/(^|[^A-Za-z@])($typo)(\$|[^A-Za-z@])/$1$fixed$3/;
+				}
+			}
+		}
+
 # check we are in a valid source file if not then ignore this hunk
 		next if ($realfile !~ /\.(h|c|s|S|pl|sh)$/);
 


--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ