Re: [PATCH] checkpatch: look for common misspellings
From: Kees Cook
Date: Thu Aug 21 2014 - 19:01:18 EST
On Thu, Aug 21, 2014 at 12:18 PM, Joe Perches <joe@xxxxxxxxxxx> 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@xxxxxxxxxxxxx>
>> M: Joe Perches <joe@xxxxxxxxxxx>
>> 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? :)
>
>> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> []
>> +# Check for several spelling mistakes.
>> + if ($rawline =~ $spelling_re) {
>
> $spelling_re has a rather hidden ( ... ) use so I think
> it'd be better to not use spelling_re at all and have a
> variable like:
> our $misspellings = join('|', @spelling_list);
>
> and also use while so all misspellings are found so this
> could be:
>
> while ($rawline =~ /(?:^|$edge)($misspellings)(?:\$|$edge)/g) {
>
>> + my $typo = "The word '$1' may be misspelled";
>> + $typo .= " (perhaps you want '$spelling_fix{$1}'?)\n";
>> + WARN("TYPO_SPELLING", $typo . $herecurr);
>> + }
>> }
>
> Seems sensible, but this checks only .c and .h files.
> Any of the Kconfig/.txt files are skipped.
Oh, hm. Yes, seems like this should be relocated then.
> I'd probably leave out "The word "
Fair enough.
> Maybe add a $fix too?
>
> Maybe:
>
> while ($rawline =~ /(?:^|$edge)($misspellings)(?:\$|$edge)/g) {
> my $typo = $1;
> if (WARN("TYPO_SPELLING",
> "$typo may be misspelled - Use '$spelling_fix($typo)'?\n" . $herecurr) &&
> $fix) {
> $fixed[$fixlinenr] =~ s/(?:^|$edge)($typo)(?:\$|$edge)/$spelling_fix($typo)/;
> }
> }
>
>
Cool, let me grok your suggested patch and reply. Thanks for looking this over!
-Kees
--
Kees Cook
Chrome OS Security
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/