diff options
| author | Joe Perches <joe@perches.com> | 2014-12-10 18:51:43 -0500 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-12-10 20:41:11 -0500 |
| commit | 36061e380618201a558e01d2c2ac6217ea331523 (patch) | |
| tree | 591b36c9f3e929646b3624664186dad9fa39b40a /scripts | |
| parent | 15160f90b8640b7d83ec8cdac64c65403355faa6 (diff) | |
checkpatch: fix use via symlink, make missing spelling file non-fatal
Commit 66b47b4a9dad ("checkpatch: look for common misspellings") made it
difficult to use checkpatch via a symlink.
Fix that and make a missing spelling.txt file non-fatal. Emit a warning
when the spelling.txt file can not be opened.
Reference: http://xkcd.com/1172/
Signed-off-by: Joe Perches <joe@perches.com>
Reported-by: Jani Nikula <jani.nikula@intel.com>
Tested-by: Jani Nikula <jani.nikula@intel.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Acked-by: Andy Whitcroft <apw@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 10ad5ab571dc..853dc7f9f751 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -7,10 +7,11 @@ | |||
| 7 | 7 | ||
| 8 | use strict; | 8 | use strict; |
| 9 | use POSIX; | 9 | use POSIX; |
| 10 | use File::Basename; | ||
| 11 | use Cwd 'abs_path'; | ||
| 10 | 12 | ||
| 11 | my $P = $0; | 13 | my $P = $0; |
| 12 | $P =~ s@(.*)/@@g; | 14 | my $D = dirname(abs_path($P)); |
| 13 | my $D = $1; | ||
| 14 | 15 | ||
| 15 | my $V = '0.32'; | 16 | my $V = '0.32'; |
| 16 | 17 | ||
| @@ -438,26 +439,29 @@ our $allowed_asm_includes = qr{(?x: | |||
| 438 | 439 | ||
| 439 | # Load common spelling mistakes and build regular expression list. | 440 | # Load common spelling mistakes and build regular expression list. |
| 440 | my $misspellings; | 441 | my $misspellings; |
| 441 | my @spelling_list; | ||
| 442 | my %spelling_fix; | 442 | my %spelling_fix; |
| 443 | open(my $spelling, '<', $spelling_file) | ||
| 444 | or die "$P: Can't open $spelling_file for reading: $!\n"; | ||
| 445 | while (<$spelling>) { | ||
| 446 | my $line = $_; | ||
| 447 | 443 | ||
| 448 | $line =~ s/\s*\n?$//g; | 444 | if (open(my $spelling, '<', $spelling_file)) { |
| 449 | $line =~ s/^\s*//g; | 445 | my @spelling_list; |
| 446 | while (<$spelling>) { | ||
| 447 | my $line = $_; | ||
| 450 | 448 | ||
| 451 | next if ($line =~ m/^\s*#/); | 449 | $line =~ s/\s*\n?$//g; |
| 452 | next if ($line =~ m/^\s*$/); | 450 | $line =~ s/^\s*//g; |
| 453 | 451 | ||
| 454 | my ($suspect, $fix) = split(/\|\|/, $line); | 452 | next if ($line =~ m/^\s*#/); |
| 453 | next if ($line =~ m/^\s*$/); | ||
| 454 | |||
| 455 | my ($suspect, $fix) = split(/\|\|/, $line); | ||
| 455 | 456 | ||
| 456 | push(@spelling_list, $suspect); | 457 | push(@spelling_list, $suspect); |
| 457 | $spelling_fix{$suspect} = $fix; | 458 | $spelling_fix{$suspect} = $fix; |
| 459 | } | ||
| 460 | close($spelling); | ||
| 461 | $misspellings = join("|", @spelling_list); | ||
| 462 | } else { | ||
| 463 | warn "No typos will be found - file '$spelling_file': $!\n"; | ||
| 458 | } | 464 | } |
| 459 | close($spelling); | ||
| 460 | $misspellings = join("|", @spelling_list); | ||
| 461 | 465 | ||
| 462 | sub build_types { | 466 | sub build_types { |
| 463 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; | 467 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
| @@ -2246,7 +2250,7 @@ sub process { | |||
| 2246 | } | 2250 | } |
| 2247 | 2251 | ||
| 2248 | # Check for various typo / spelling mistakes | 2252 | # Check for various typo / spelling mistakes |
| 2249 | if ($in_commit_log || $line =~ /^\+/) { | 2253 | if (defined($misspellings) && ($in_commit_log || $line =~ /^\+/)) { |
| 2250 | while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) { | 2254 | while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) { |
| 2251 | my $typo = $1; | 2255 | my $typo = $1; |
| 2252 | my $typo_fix = $spelling_fix{lc($typo)}; | 2256 | my $typo_fix = $spelling_fix{lc($typo)}; |
