aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-06-08 14:31:16 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-06-08 14:31:16 -0400
commit3f17ea6dea8ba5668873afa54628a91aaa3fb1c0 (patch)
treeafbeb2accd4c2199ddd705ae943995b143a0af02 /scripts
parent1860e379875dfe7271c649058aeddffe5afd9d0d (diff)
parent1a5700bc2d10cd379a795fd2bb377a190af5acd4 (diff)
Merge branch 'next' (accumulated 3.16 merge window patches) into master
Now that 3.15 is released, this merges the 'next' branch into 'master', bringing us to the normal situation where my 'master' branch is the merge window. * accumulated work in next: (6809 commits) ufs: sb mutex merge + mutex_destroy powerpc: update comments for generic idle conversion cris: update comments for generic idle conversion idle: remove cpu_idle() forward declarations nbd: zero from and len fields in NBD_CMD_DISCONNECT. mm: convert some level-less printks to pr_* MAINTAINERS: adi-buildroot-devel is moderated MAINTAINERS: add linux-api for review of API/ABI changes mm/kmemleak-test.c: use pr_fmt for logging fs/dlm/debug_fs.c: replace seq_printf by seq_puts fs/dlm/lockspace.c: convert simple_str to kstr fs/dlm/config.c: convert simple_str to kstr mm: mark remap_file_pages() syscall as deprecated mm: memcontrol: remove unnecessary memcg argument from soft limit functions mm: memcontrol: clean up memcg zoneinfo lookup mm/memblock.c: call kmemleak directly from memblock_(alloc|free) mm/mempool.c: update the kmemleak stack trace for mempool allocations lib/radix-tree.c: update the kmemleak stack trace for radix tree allocations mm: introduce kmemleak_update_trace() mm/kmemleak.c: use %u to print ->checksum ...
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/checkpatch.pl136
-rw-r--r--scripts/mod/modpost.c2
-rw-r--r--scripts/recordmcount.c7
-rwxr-xr-xscripts/recordmcount.pl5
4 files changed, 135 insertions, 15 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 34eb2160489d..010b18ef4ea0 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -24,6 +24,7 @@ my $emacs = 0;
24my $terse = 0; 24my $terse = 0;
25my $file = 0; 25my $file = 0;
26my $check = 0; 26my $check = 0;
27my $check_orig = 0;
27my $summary = 1; 28my $summary = 1;
28my $mailback = 0; 29my $mailback = 0;
29my $summary_file = 0; 30my $summary_file = 0;
@@ -146,6 +147,7 @@ GetOptions(
146help(0) if ($help); 147help(0) if ($help);
147 148
148$fix = 1 if ($fix_inplace); 149$fix = 1 if ($fix_inplace);
150$check_orig = $check;
149 151
150my $exit = 0; 152my $exit = 0;
151 153
@@ -397,6 +399,11 @@ foreach my $entry (@mode_permission_funcs) {
397 $mode_perms_search .= $entry->[0]; 399 $mode_perms_search .= $entry->[0];
398} 400}
399 401
402our $declaration_macros = qr{(?x:
403 (?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(|
404 (?:$Storage\s+)?LIST_HEAD\s*\(
405)};
406
400our $allowed_asm_includes = qr{(?x: 407our $allowed_asm_includes = qr{(?x:
401 irq| 408 irq|
402 memory 409 memory
@@ -1808,11 +1815,13 @@ sub process {
1808 $here = "#$linenr: " if (!$file); 1815 $here = "#$linenr: " if (!$file);
1809 $here = "#$realline: " if ($file); 1816 $here = "#$realline: " if ($file);
1810 1817
1818 my $found_file = 0;
1811 # extract the filename as it passes 1819 # extract the filename as it passes
1812 if ($line =~ /^diff --git.*?(\S+)$/) { 1820 if ($line =~ /^diff --git.*?(\S+)$/) {
1813 $realfile = $1; 1821 $realfile = $1;
1814 $realfile =~ s@^([^/]*)/@@ if (!$file); 1822 $realfile =~ s@^([^/]*)/@@ if (!$file);
1815 $in_commit_log = 0; 1823 $in_commit_log = 0;
1824 $found_file = 1;
1816 } elsif ($line =~ /^\+\+\+\s+(\S+)/) { 1825 } elsif ($line =~ /^\+\+\+\s+(\S+)/) {
1817 $realfile = $1; 1826 $realfile = $1;
1818 $realfile =~ s@^([^/]*)/@@ if (!$file); 1827 $realfile =~ s@^([^/]*)/@@ if (!$file);
@@ -1829,6 +1838,15 @@ sub process {
1829 ERROR("MODIFIED_INCLUDE_ASM", 1838 ERROR("MODIFIED_INCLUDE_ASM",
1830 "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n"); 1839 "do not modify files in include/asm, change architecture specific files in include/asm-<architecture>\n" . "$here$rawline\n");
1831 } 1840 }
1841 $found_file = 1;
1842 }
1843
1844 if ($found_file) {
1845 if ($realfile =~ m@^(drivers/net/|net/)@) {
1846 $check = 1;
1847 } else {
1848 $check = $check_orig;
1849 }
1832 next; 1850 next;
1833 } 1851 }
1834 1852
@@ -1926,6 +1944,12 @@ sub process {
1926 } 1944 }
1927 } 1945 }
1928 1946
1947# Check for old stable address
1948 if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) {
1949 ERROR("STABLE_ADDRESS",
1950 "The 'stable' address should be 'stable\@vger.kernel.org'\n" . $herecurr);
1951 }
1952
1929# Check for unwanted Gerrit info 1953# Check for unwanted Gerrit info
1930 if ($in_commit_log && $line =~ /^\s*change-id:/i) { 1954 if ($in_commit_log && $line =~ /^\s*change-id:/i) {
1931 ERROR("GERRIT_CHANGE_ID", 1955 ERROR("GERRIT_CHANGE_ID",
@@ -2093,8 +2117,10 @@ sub process {
2093 2117
2094 foreach my $compat (@compats) { 2118 foreach my $compat (@compats) {
2095 my $compat2 = $compat; 2119 my $compat2 = $compat;
2096 $compat2 =~ s/\,[a-z]*\-/\,<\.\*>\-/; 2120 $compat2 =~ s/\,[a-zA-Z0-9]*\-/\,<\.\*>\-/;
2097 `grep -Erq "$compat|$compat2" $dt_path`; 2121 my $compat3 = $compat;
2122 $compat3 =~ s/\,([a-z]*)[0-9]*\-/\,$1<\.\*>\-/;
2123 `grep -Erq "$compat|$compat2|$compat3" $dt_path`;
2098 if ( $? >> 8 ) { 2124 if ( $? >> 8 ) {
2099 WARN("UNDOCUMENTED_DT_STRING", 2125 WARN("UNDOCUMENTED_DT_STRING",
2100 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr); 2126 "DT compatible string \"$compat\" appears un-documented -- check $dt_path\n" . $herecurr);
@@ -2266,18 +2292,37 @@ sub process {
2266 } 2292 }
2267 2293
2268# check for missing blank lines after declarations 2294# check for missing blank lines after declarations
2269 if ($realfile =~ m@^(drivers/net/|net/)@ && 2295 if ($sline =~ /^\+\s+\S/ && #Not at char 1
2270 $prevline =~ /^\+\s+$Declare\s+$Ident/ && 2296 # actual declarations
2271 !($prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ || 2297 ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
2272 $prevline =~ /(?:\{\s*|\\)$/) && #extended lines 2298 # foo bar; where foo is some local typedef or #define
2273 $sline =~ /^\+\s+/ && #Not at char 1 2299 $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
2274 !($sline =~ /^\+\s+$Declare/ || 2300 # known declaration macros
2275 $sline =~ /^\+\s+$Ident\s+$Ident/ || #eg: typedef foo 2301 $prevline =~ /^\+\s+$declaration_macros/) &&
2302 # for "else if" which can look like "$Ident $Ident"
2303 !($prevline =~ /^\+\s+$c90_Keywords\b/ ||
2304 # other possible extensions of declaration lines
2305 $prevline =~ /(?:$Compare|$Assignment|$Operators)\s*$/ ||
2306 # not starting a section or a macro "\" extended line
2307 $prevline =~ /(?:\{\s*|\\)$/) &&
2308 # looks like a declaration
2309 !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ ||
2310 # foo bar; where foo is some local typedef or #define
2311 $sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ ||
2312 # known declaration macros
2313 $sline =~ /^\+\s+$declaration_macros/ ||
2314 # start of struct or union or enum
2276 $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ || 2315 $sline =~ /^\+\s+(?:union|struct|enum|typedef)\b/ ||
2277 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(])/ || 2316 # start or end of block or continuation of declaration
2278 $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/)) { 2317 $sline =~ /^\+\s+(?:$|[\{\}\.\#\"\?\:\(\[])/ ||
2318 # bitfield continuation
2319 $sline =~ /^\+\s+$Ident\s*:\s*\d+\s*[,;]/ ||
2320 # other possible extensions of declaration lines
2321 $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) &&
2322 # indentation of previous and current line are the same
2323 (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) {
2279 WARN("SPACING", 2324 WARN("SPACING",
2280 "networking uses a blank line after declarations\n" . $hereprev); 2325 "Missing a blank line after declarations\n" . $hereprev);
2281 } 2326 }
2282 2327
2283# check for spaces at the beginning of a line. 2328# check for spaces at the beginning of a line.
@@ -3431,6 +3476,13 @@ sub process {
3431 } 3476 }
3432 } 3477 }
3433 3478
3479# unnecessary return in a void function? (a single leading tab, then return;)
3480 if ($sline =~ /^\+\treturn\s*;\s*$/ &&
3481 $prevline =~ /^\+/) {
3482 WARN("RETURN_VOID",
3483 "void function return statements are not generally useful\n" . $herecurr);
3484 }
3485
3434# if statements using unnecessary parentheses - ie: if ((foo == bar)) 3486# if statements using unnecessary parentheses - ie: if ((foo == bar))
3435 if ($^V && $^V ge 5.10.0 && 3487 if ($^V && $^V ge 5.10.0 &&
3436 $line =~ /\bif\s*((?:\(\s*){2,})/) { 3488 $line =~ /\bif\s*((?:\(\s*){2,})/) {
@@ -3782,6 +3834,17 @@ sub process {
3782 WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", 3834 WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON",
3783 "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); 3835 "do {} while (0) macros should not be semicolon terminated\n" . "$herectx");
3784 } 3836 }
3837 } elsif ($dstat =~ /^\+\s*#\s*define\s+$Ident.*;\s*$/) {
3838 $ctx =~ s/\n*$//;
3839 my $cnt = statement_rawlines($ctx);
3840 my $herectx = $here . "\n";
3841
3842 for (my $n = 0; $n < $cnt; $n++) {
3843 $herectx .= raw_line($linenr, $n) . "\n";
3844 }
3845
3846 WARN("TRAILING_SEMICOLON",
3847 "macros should not use a trailing semicolon\n" . "$herectx");
3785 } 3848 }
3786 } 3849 }
3787 3850
@@ -4264,6 +4327,27 @@ sub process {
4264 "unchecked sscanf return value\n" . "$here\n$stat_real\n"); 4327 "unchecked sscanf return value\n" . "$here\n$stat_real\n");
4265 } 4328 }
4266 4329
4330# check for simple sscanf that should be kstrto<foo>
4331 if ($^V && $^V ge 5.10.0 &&
4332 defined $stat &&
4333 $line =~ /\bsscanf\b/) {
4334 my $lc = $stat =~ tr@\n@@;
4335 $lc = $lc + $linenr;
4336 my $stat_real = raw_line($linenr, 0);
4337 for (my $count = $linenr + 1; $count <= $lc; $count++) {
4338 $stat_real = $stat_real . "\n" . raw_line($count, 0);
4339 }
4340 if ($stat_real =~ /\bsscanf\b\s*\(\s*$FuncArg\s*,\s*("[^"]+")/) {
4341 my $format = $6;
4342 my $count = $format =~ tr@%@%@;
4343 if ($count == 1 &&
4344 $format =~ /^"\%(?i:ll[udxi]|[udxi]ll|ll|[hl]h?[udxi]|[udxi][hl]h?|[hl]h?|[udxi])"$/) {
4345 WARN("SSCANF_TO_KSTRTO",
4346 "Prefer kstrto<type> to single variable sscanf\n" . "$here\n$stat_real\n");
4347 }
4348 }
4349 }
4350
4267# check for new externs in .h files. 4351# check for new externs in .h files.
4268 if ($realfile =~ /\.h$/ && 4352 if ($realfile =~ /\.h$/ &&
4269 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) { 4353 $line =~ /^\+\s*(extern\s+)$Type\s*$Ident\s*\(/s) {
@@ -4328,6 +4412,30 @@ sub process {
4328 "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr); 4412 "Prefer $3(sizeof(*$1)...) over $3($4...)\n" . $herecurr);
4329 } 4413 }
4330 4414
4415# check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc
4416 if ($^V && $^V ge 5.10.0 &&
4417 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/) {
4418 my $oldfunc = $3;
4419 my $a1 = $4;
4420 my $a2 = $10;
4421 my $newfunc = "kmalloc_array";
4422 $newfunc = "kcalloc" if ($oldfunc eq "kzalloc");
4423 if ($a1 =~ /^sizeof\s*\S/ || $a2 =~ /^sizeof\s*\S/) {
4424 if (WARN("ALLOC_WITH_MULTIPLY",
4425 "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) &&
4426 $fix) {
4427 my $r1 = $a1;
4428 my $r2 = $a2;
4429 if ($a1 =~ /^sizeof\s*\S/) {
4430 $r1 = $a2;
4431 $r2 = $a1;
4432 }
4433 $fixed[$linenr - 1] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e;
4434
4435 }
4436 }
4437 }
4438
4331# check for krealloc arg reuse 4439# check for krealloc arg reuse
4332 if ($^V && $^V ge 5.10.0 && 4440 if ($^V && $^V ge 5.10.0 &&
4333 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) { 4441 $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*krealloc\s*\(\s*\1\s*,/) {
@@ -4443,10 +4551,10 @@ sub process {
4443 "$1 is obsolete, use k$3 instead\n" . $herecurr); 4551 "$1 is obsolete, use k$3 instead\n" . $herecurr);
4444 } 4552 }
4445 4553
4446# check for __initcall(), use device_initcall() explicitly please 4554# check for __initcall(), use device_initcall() explicitly or more appropriate function please
4447 if ($line =~ /^.\s*__initcall\s*\(/) { 4555 if ($line =~ /^.\s*__initcall\s*\(/) {
4448 WARN("USE_DEVICE_INITCALL", 4556 WARN("USE_DEVICE_INITCALL",
4449 "please use device_initcall() instead of __initcall()\n" . $herecurr); 4557 "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr);
4450 } 4558 }
4451 4559
4452# check for various ops structs, ensure they are const. 4560# check for various ops structs, ensure they are const.
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 066355673930..ea7f9530afa2 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -316,7 +316,7 @@ static struct symbol *sym_add_exported(const char *name, struct module *mod,
316 s->module->name, 316 s->module->name,
317 is_vmlinux(s->module->name) ?"":".ko"); 317 is_vmlinux(s->module->name) ?"":".ko");
318 } else { 318 } else {
319 /* In case Modules.symvers was out of date */ 319 /* In case Module.symvers was out of date */
320 s->module = mod; 320 s->module = mod;
321 } 321 }
322 } 322 }
diff --git a/scripts/recordmcount.c b/scripts/recordmcount.c
index 9c22317778eb..e11aa4a156d2 100644
--- a/scripts/recordmcount.c
+++ b/scripts/recordmcount.c
@@ -40,6 +40,11 @@
40#define R_METAG_NONE 3 40#define R_METAG_NONE 3
41#endif 41#endif
42 42
43#ifndef EM_AARCH64
44#define EM_AARCH64 183
45#define R_AARCH64_ABS64 257
46#endif
47
43static int fd_map; /* File descriptor for file being modified. */ 48static int fd_map; /* File descriptor for file being modified. */
44static int mmap_failed; /* Boolean flag. */ 49static int mmap_failed; /* Boolean flag. */
45static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */ 50static void *ehdr_curr; /* current ElfXX_Ehdr * for resource cleanup */
@@ -347,6 +352,8 @@ do_file(char const *const fname)
347 case EM_ARM: reltype = R_ARM_ABS32; 352 case EM_ARM: reltype = R_ARM_ABS32;
348 altmcount = "__gnu_mcount_nc"; 353 altmcount = "__gnu_mcount_nc";
349 break; 354 break;
355 case EM_AARCH64:
356 reltype = R_AARCH64_ABS64; gpfx = '_'; break;
350 case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break; 357 case EM_IA_64: reltype = R_IA64_IMM64; gpfx = '_'; break;
351 case EM_METAG: reltype = R_METAG_ADDR32; 358 case EM_METAG: reltype = R_METAG_ADDR32;
352 altmcount = "_mcount_wrapper"; 359 altmcount = "_mcount_wrapper";
diff --git a/scripts/recordmcount.pl b/scripts/recordmcount.pl
index 91280b82da08..397b6b84e8c5 100755
--- a/scripts/recordmcount.pl
+++ b/scripts/recordmcount.pl
@@ -279,6 +279,11 @@ if ($arch eq "x86_64") {
279 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" . 279 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_ARM_(CALL|PC24|THM_CALL)" .
280 "\\s+(__gnu_mcount_nc|mcount)\$"; 280 "\\s+(__gnu_mcount_nc|mcount)\$";
281 281
282} elsif ($arch eq "arm64") {
283 $alignment = 3;
284 $section_type = '%progbits';
285 $mcount_regex = "^\\s*([0-9a-fA-F]+):\\s*R_AARCH64_CALL26\\s+_mcount\$";
286 $type = ".quad";
282} elsif ($arch eq "ia64") { 287} elsif ($arch eq "ia64") {
283 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$"; 288 $mcount_regex = "^\\s*([0-9a-fA-F]+):.*\\s_mcount\$";
284 $type = "data8"; 289 $type = "data8";