History

Merge branch 'akpm' (patches from Andrew)

Merge third patchbomb from Andrew Morton: - various misc things - a couple of lib/ optimisations - provide DIV_ROUND_CLOSEST_ULL() - checkpatch updates - rtc tree - befs, nilfs2, hfs, hfsplus, fatfs, adfs, affs, bfs - ptrace fixes - fork() fixes - seccomp cleanups - more mmap_sem hold time reductions from Davidlohr * emailed patches from Andrew Morton <akpm@linux-foundation.org>: (138 commits) proc: show locks in /proc/pid/fdinfo/X docs: add missing and new /proc/PID/status file entries, fix typos drivers/rtc/rtc-at91rm9200.c: make IO endian agnostic Documentation/spi/spidev_test.c: fix warning drivers/rtc/rtc-s5m.c: allow usage on device type different than main MFD type .gitignore: ignore *.tar MAINTAINERS: add Mediatek SoC mailing list tomoyo: reduce mmap_sem hold for mm->exe_file powerpc/oprofile: reduce mmap_sem hold for exe_file oprofile: reduce mmap_sem hold for mm->exe_file mips: ip32: add platform data hooks to use DS1685 driver lib/Kconfig: fix up HAVE_ARCH_BITREVERSE help text x86: switch to using asm-generic for seccomp.h sparc: switch to using asm-generic for seccomp.h powerpc: switch to using asm-generic for seccomp.h parisc: switch to using asm-generic for seccomp.h mips: switch to using asm-generic for seccomp.h microblaze: use asm-generic for seccomp.h arm: use asm-generic for seccomp.h seccomp: allow COMPAT sigreturn overrides ...

Linus Torvalds committed 11 years ago

Commit 54e514b2 parents 4fc8adc 6c8c903158 files · +2190 −1551Browse files

Showing the changes to scripts (3 of 158 files). Show all

Unified · Split

3 files
  1. scripts/Makefile.kasan +6 −2
  2. scripts/checkpatch.pl +141 −23
  3. scripts/spelling.txt +1 −0
scripts/Makefile.kasan+6−2
@@ -13,12 +13,16 @@ CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \ · 12 unmodified lines
1313 --param asan-instrumentation-with-call-threshold=$(call_threshold))
1414
1515 ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),)
16+ ifneq ($(CONFIG_COMPILE_TEST),y)
1617 $(warning Cannot use CONFIG_KASAN: \
1718 -fsanitize=kernel-address is not supported by compiler)
19+ endif
1820 else
1921 ifeq ($(CFLAGS_KASAN),)
20− $(warning CONFIG_KASAN: compiler does not support all options.\
21− Trying minimal configuration)
22+ ifneq ($(CONFIG_COMPILE_TEST),y)
23+ $(warning CONFIG_KASAN: compiler does not support all options.\
24+ Trying minimal configuration)
25+ endif
2226 CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
2327 endif
2428 endif
scripts/checkpatch.pl+141−23
@@ -47,6 +47,8 @@ my $ignore_perl_version = 0; · 46 unmodified lines
4747 my $minimum_perl_version = 5.10.0;
4848 my $min_conf_desc_length = 4;
4949 my $spelling_file = "$D/spelling.txt";
50+my $codespell = 0;
51+my $codespellfile = "/usr/local/share/codespell/dictionary.txt";
5052
5153 sub help {
5254 my ($exitcode) = @_;
@@ -88,6 +90,9 @@ Options: · 35 unmodified lines
8890 file. It's your fault if there's no backup or git
8991 --ignore-perl-version override checking of perl version. expect
9092 runtime errors.
93+ --codespell Use the codespell dictionary for spelling/typos
94+ (default:/usr/local/share/codespell/dictionary.txt)
95+ --codespellfile Use this codespell dictionary
9196 -h, --help, --version display this help and exit
9297
9398 When FILE is - read standard input.
@@ -146,6 +151,8 @@ GetOptions( · 52 unmodified lines
146151 'ignore-perl-version!' => \$ignore_perl_version,
147152 'debug=s' => \%debug,
148153 'test-only=s' => \$tst_only,
154+ 'codespell!' => \$codespell,
155+ 'codespellfile=s' => \$codespellfile,
149156 'h|help' => \$help,
150157 'version' => \$help
151158 ) or help(1);
@@ -316,6 +323,7 @@ our $Operators = qr{ · 164 unmodified lines
316323
317324 our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x;
318325
326+our $BasicType;
319327 our $NonptrType;
320328 our $NonptrTypeMisordered;
321329 our $NonptrTypeWithAttr;
@@ -436,6 +444,14 @@ foreach my $entry (@mode_permission_funcs) { · 114 unmodified lines
436444 $mode_perms_search .= $entry->[0];
437445 }
438446
447+our $mode_perms_world_writable = qr{
448+ S_IWUGO |
449+ S_IWOTH |
450+ S_IRWXUGO |
451+ S_IALLUGO |
452+ 0[0-7][0-7][2367]
453+}x;
454+
439455 our $allowed_asm_includes = qr{(?x:
440456 irq|
441457 memory|
@@ -449,7 +465,6 @@ my $misspellings; · 7 unmodified lines
449465 my %spelling_fix;
450466
451467 if (open(my $spelling, '<', $spelling_file)) {
452− my @spelling_list;
453468 while (<$spelling>) {
454469 my $line = $_;
455470
@@ -461,21 +476,50 @@ if (open(my $spelling, '<', $spelling_file)) { · 5 unmodified lines
461476
462477 my ($suspect, $fix) = split(/\|\|/, $line);
463478
464− push(@spelling_list, $suspect);
465479 $spelling_fix{$suspect} = $fix;
466480 }
467481 close($spelling);
468− $misspellings = join("|", @spelling_list);
469482 } else {
470483 warn "No typos will be found - file '$spelling_file': $!\n";
471484 }
472485
486+if ($codespell) {
487+ if (open(my $spelling, '<', $codespellfile)) {
488+ while (<$spelling>) {
489+ my $line = $_;
490+
491+ $line =~ s/\s*\n?$//g;
492+ $line =~ s/^\s*//g;
493+
494+ next if ($line =~ m/^\s*#/);
495+ next if ($line =~ m/^\s*$/);
496+ next if ($line =~ m/, disabled/i);
497+
498+ $line =~ s/,.*$//;
499+
500+ my ($suspect, $fix) = split(/->/, $line);
501+
502+ $spelling_fix{$suspect} = $fix;
503+ }
504+ close($spelling);
505+ } else {
506+ warn "No codespell typos will be found - file '$codespellfile': $!\n";
507+ }
508+}
509+
510+$misspellings = join("|", sort keys %spelling_fix) if keys %spelling_fix;
511+
473512 sub build_types {
474513 my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)";
475514 my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)";
476515 my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)";
477516 my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)";
478517 $Modifier = qr{(?:$Attribute|$Sparse|$mods)};
518+ $BasicType = qr{
519+ (?:$typeOtherOSTypedefs\b)|
520+ (?:$typeTypedefs\b)|
521+ (?:${all}\b)
522+ }x;
479523 $NonptrType = qr{
480524 (?:$Modifier\s+|const\s+)*
481525 (?:
@@ -1646,7 +1690,7 @@ sub fix_inserted_deleted_lines { · 1164 unmodified lines
16461690 foreach my $old_line (@{$linesRef}) {
16471691 my $save_line = 1;
16481692 my $line = $old_line; #don't modify the array
1649− if ($line =~ /^(?:\+\+\+\|\-\-\-)\s+\S+/) { #new filename
1693+ if ($line =~ /^(?:\+\+\+|\-\-\-)\s+\S+/) { #new filename
16501694 $delta_offset = 0;
16511695 } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk
16521696 $range_last_linenr = $new_linenr;
@@ -1854,6 +1898,7 @@ sub process { · 201 unmodified lines
18541898
18551899 my $in_header_lines = $file ? 0 : 1;
18561900 my $in_commit_log = 0; #Scanning lines before patch
1901+ my $commit_log_long_line = 0;
18571902 my $reported_maintainer_file = 0;
18581903 my $non_utf8_charset = 0;
18591904
@@ -2189,6 +2234,14 @@ sub process { · 329 unmodified lines
21892234 "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr);
21902235 }
21912236
2237+# Check for line lengths > 75 in commit log, warn once
2238+ if ($in_commit_log && !$commit_log_long_line &&
2239+ length($line) > 75) {
2240+ WARN("COMMIT_LOG_LONG_LINE",
2241+ "Possible unwrapped commit description (prefer a maximum 75 chars per line)\n" . $herecurr);
2242+ $commit_log_long_line = 1;
2243+ }
2244+
21922245 # Check for git id commit length and improperly formed commit descriptions
21932246 if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) {
21942247 my $init_char = $1;
@@ -2303,8 +2356,9 @@ sub process { · 108 unmodified lines
23032356 }
23042357
23052358 # Check for various typo / spelling mistakes
2306− if (defined($misspellings) && ($in_commit_log || $line =~ /^\+/)) {
2307− while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:$|[^a-z@])/gi) {
2359+ if (defined($misspellings) &&
2360+ ($in_commit_log || $line =~ /^(?:\+|Subject:)/i)) {
2361+ while ($rawline =~ /(?:^|[^a-z@])($misspellings)(?:\b|$|[^a-z@])/gi) {
23082362 my $typo = $1;
23092363 my $typo_fix = $spelling_fix{lc($typo)};
23102364 $typo_fix = ucfirst($typo_fix) if ($typo =~ /^[A-Z]/);
@@ -2459,8 +2513,9 @@ sub process { · 148 unmodified lines
24592513 #line length limit
24602514 if ($line =~ /^\+/ && $prevrawline !~ /\/\*\*/ &&
24612515 $rawline !~ /^.\s*\*\s*\@$Ident\s/ &&
2462− !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?"[X\t]*"\s*(?:|,|\)\s*;)\s*$/ ||
2463− $line =~ /^\+\s*"[^"]*"\s*(?:\s*|,|\)\s*;)\s*$/) &&
2516+ !($line =~ /^\+\s*$logFunctions\s*\(\s*(?:(KERN_\S+\s*|[^"]*))?$String\s*(?:|,|\)\s*;)\s*$/ ||
2517+ $line =~ /^\+\s*$String\s*(?:\s*|,|\)\s*;)\s*$/ ||
2518+ $line =~ /^\+\s*#\s*define\s+\w+\s+$String$/) &&
24642519 $length > $max_line_length)
24652520 {
24662521 WARN("LONG_LINE",
@@ -2552,8 +2607,15 @@ sub process { · 85 unmodified lines
25522607 }
25532608 }
25542609
2555− if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;:\?\(\{\}\[\<\>]|&&|\|\||\\$)/ &&
2556− (!defined($1) || $1 !~ /sizeof\s*/)) {
2610+# check for space after cast like "(int) foo" or "(struct foo) bar"
2611+# avoid checking a few false positives:
2612+# "sizeof(<type>)" or "__alignof__(<type>)"
2613+# function pointer declarations like "(*foo)(int) = bar;"
2614+# structure definitions like "(struct foo) { 0 };"
2615+# multiline macros that define functions
2616+# known attributes or the __attribute__ keyword
2617+ if ($line =~ /^\+(.*)\(\s*$Type\s*\)([ \t]++)((?![={]|\\$|$Attribute|__attribute__))/ &&
2618+ (!defined($1) || $1 !~ /\b(?:sizeof|__alignof__)\s*$/)) {
25572619 if (CHK("SPACING",
25582620 "No space is necessary after a cast\n" . $herecurr) &&
25592621 $fix) {
@@ -3146,6 +3208,18 @@ sub process { · 586 unmodified lines
31463208 $herecurr);
31473209 }
31483210
3211+# check for const <foo> const where <foo> is not a pointer or array type
3212+ if ($sline =~ /\bconst\s+($BasicType)\s+const\b/) {
3213+ my $found = $1;
3214+ if ($sline =~ /\bconst\s+\Q$found\E\s+const\b\s*\*/) {
3215+ WARN("CONST_CONST",
3216+ "'const $found const *' should probably be 'const $found * const'\n" . $herecurr);
3217+ } elsif ($sline !~ /\bconst\s+\Q$found\E\s+const\s+\w+\s*\[/) {
3218+ WARN("CONST_CONST",
3219+ "'const $found const' should probably be 'const $found'\n" . $herecurr);
3220+ }
3221+ }
3222+
31493223 # check for non-global char *foo[] = {"bar", ...} declarations.
31503224 if ($line =~ /^.\s+(?:static\s+|const\s+)?char\s+\*\s*\w+\s*\[\s*\]\s*=\s*\{/) {
31513225 WARN("STATIC_CONST_CHAR_ARRAY",
@@ -3153,6 +3227,19 @@ sub process { · 1 unmodified line
31533227 $herecurr);
31543228 }
31553229
3230+# check for sizeof(foo)/sizeof(foo[0]) that could be ARRAY_SIZE(foo)
3231+ if ($line =~ m@\bsizeof\s*\(\s*($Lval)\s*\)@) {
3232+ my $array = $1;
3233+ if ($line =~ m@\b(sizeof\s*\(\s*\Q$array\E\s*\)\s*/\s*sizeof\s*\(\s*\Q$array\E\s*\[\s*0\s*\]\s*\))@) {
3234+ my $array_div = $1;
3235+ if (WARN("ARRAY_SIZE",
3236+ "Prefer ARRAY_SIZE($array)\n" . $herecurr) &&
3237+ $fix) {
3238+ $fixed[$fixlinenr] =~ s/\Q$array_div\E/ARRAY_SIZE($array)/;
3239+ }
3240+ }
3241+ }
3242+
31563243 # check for function declarations without arguments like "int foo()"
31573244 if ($line =~ /(\b$Type\s+$Ident)\s*\(\s*\)/) {
31583245 if (ERROR("FUNCTION_WITHOUT_ARGS",
@@ -3309,6 +3396,14 @@ sub process { · 150 unmodified lines
33093396 "Prefer dev_$level(... to dev_printk(KERN_$orig, ...\n" . $herecurr);
33103397 }
33113398
3399+# ENOSYS means "bad syscall nr" and nothing else. This will have a small
3400+# number of false positives, but assembly files are not checked, so at
3401+# least the arch entry code will not trigger this warning.
3402+ if ($line =~ /\bENOSYS\b/) {
3403+ WARN("ENOSYS",
3404+ "ENOSYS means 'invalid syscall nr' and nothing else\n" . $herecurr);
3405+ }
3406+
33123407 # function brace can't be on same line, except for #defines of do while,
33133408 # or if closed on same line
33143409 if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and
@@ -3565,7 +3660,7 @@ sub process { · 250 unmodified lines
35653660
35663661 # Ignore operators passed as parameters.
35673662 if ($op_type ne 'V' &&
3568− $ca =~ /\s$/ && $cc =~ /^\s*,/) {
3663+ $ca =~ /\s$/ && $cc =~ /^\s*[,\)]/) {
35693664
35703665 # # Ignore comments
35713666 # } elsif ($op =~ /^$;+$/) {
@@ -3750,6 +3845,14 @@ sub process { · 178 unmodified lines
37503845 $ok = 1;
37513846 }
37523847
3848+ # for asm volatile statements
3849+ # ignore a colon with another
3850+ # colon immediately before or after
3851+ if (($op eq ':') &&
3852+ ($ca =~ /:$/ || $cc =~ /^:/)) {
3853+ $ok = 1;
3854+ }
3855+
37533856 # messages are ERROR, but ?: are CHK
37543857 if ($ok == 0) {
37553858 my $msg_type = \&ERROR;
@@ -3963,12 +4066,12 @@ sub process { · 207 unmodified lines
39634066 }
39644067 }
39654068
3966−# Return of what appears to be an errno should normally be -'ve
3967− if ($line =~ /^.\s*return\s*(E[A-Z]*)\s*;/) {
4069+# Return of what appears to be an errno should normally be negative
4070+ if ($sline =~ /\breturn(?:\s*\(+\s*|\s+)(E[A-Z]+)(?:\s*\)+\s*|\s*)[;:,]/) {
39684071 my $name = $1;
39694072 if ($name ne 'EOF' && $name ne 'ERROR') {
39704073 WARN("USE_NEGATIVE_ERRNO",
3971− "return of an errno should typically be -ve (return -$1)\n" . $herecurr);
4074+ "return of an errno should typically be negative (ie: return -$1)\n" . $herecurr);
39724075 }
39734076 }
39744077
@@ -4178,7 +4281,8 @@ sub process { · 203 unmodified lines
41784281 }
41794282 }
41804283
4181−#warn if <asm/foo.h> is #included and <linux/foo.h> is available (uses RAW line)
4284+# warn if <asm/foo.h> is #included and <linux/foo.h> is available and includes
4285+# itself <asm/foo.h> (uses RAW line)
41824286 if ($tree && $rawline =~ m{^.\s*\#\s*include\s*\<asm\/(.*)\.h\>}) {
41834287 my $file = "$1.h";
41844288 my $checkfile = "include/linux/$file";
@@ -4186,12 +4290,15 @@ sub process { · 1 unmodified line
41864290 $realfile ne $checkfile &&
41874291 $1 !~ /$allowed_asm_includes/)
41884292 {
4189− if ($realfile =~ m{^arch/}) {
4190− CHK("ARCH_INCLUDE_LINUX",
4191− "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
4192− } else {
4193− WARN("INCLUDE_LINUX",
4194− "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
4293+ my $asminclude = `grep -Ec "#include\\s+<asm/$file>" $root/$checkfile`;
4294+ if ($asminclude > 0) {
4295+ if ($realfile =~ m{^arch/}) {
4296+ CHK("ARCH_INCLUDE_LINUX",
4297+ "Consider using #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
4298+ } else {
4299+ WARN("INCLUDE_LINUX",
4300+ "Use #include <linux/$file> instead of <asm/$file>\n" . $herecurr);
4301+ }
41954302 }
41964303 }
41974304 }
@@ -4700,6 +4807,16 @@ sub process { · 502 unmodified lines
47004807 }
47014808 }
47024809
4810+# check for __read_mostly with const non-pointer (should just be const)
4811+ if ($line =~ /\b__read_mostly\b/ &&
4812+ $line =~ /($Type)\s*$Ident/ && $1 !~ /\*\s*$/ && $1 =~ /\bconst\b/) {
4813+ if (ERROR("CONST_READ_MOSTLY",
4814+ "Invalid use of __read_mostly with const type\n" . $herecurr) &&
4815+ $fix) {
4816+ $fixed[$fixlinenr] =~ s/\s+__read_mostly\b//;
4817+ }
4818+ }
4819+
47034820 # don't use __constant_<foo> functions outside of include/uapi/
47044821 if ($realfile !~ m@^include/uapi/@ &&
47054822 $line =~ /(__constant_(?:htons|ntohs|[bl]e(?:16|32|64)_to_cpu|cpu_to_[bl]e(?:16|32|64)))\s*\(/) {
@@ -5261,6 +5378,7 @@ sub process { · 555 unmodified lines
52615378 stacktrace_ops|
52625379 sysfs_ops|
52635380 tty_operations|
5381+ uart_ops|
52645382 usb_mon_operations|
52655383 wd_ops}x;
52665384 if ($line !~ /\bconst\b/ &&
@@ -5318,8 +5436,8 @@ sub process { · 51 unmodified lines
53185436 }
53195437 }
53205438
5321− if ($line =~ /debugfs_create_file.*S_IWUGO/ ||
5322− $line =~ /DEVICE_ATTR.*S_IWUGO/ ) {
5439+ if ($line =~ /debugfs_create_\w+.*\b$mode_perms_world_writable\b/ ||
5440+ $line =~ /DEVICE_ATTR.*\b$mode_perms_world_writable\b/) {
53235441 WARN("EXPORTED_WORLD_WRITABLE",
53245442 "Exporting world writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr);
53255443 }
scripts/spelling.txt+1−0
@@ -825,6 +825,7 @@ retreived||retrieved · 824 unmodified lines
825825 retreive||retrieve
826826 retrive||retrieve
827827 retuned||returned
828+reudce||reduce
828829 reuest||request
829830 reuqest||request
830831 reutnred||returned