diff options
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/.gitignore | 1 | ||||
-rw-r--r-- | scripts/Makefile | 1 | ||||
-rw-r--r-- | scripts/Makefile.modinst | 2 | ||||
-rw-r--r-- | scripts/basic/.gitignore | 1 | ||||
-rw-r--r-- | scripts/basic/Makefile | 1 | ||||
-rw-r--r-- | scripts/basic/bin2c.c (renamed from scripts/bin2c.c) | 7 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 581 | ||||
-rwxr-xr-x | scripts/checkstack.pl | 12 | ||||
-rw-r--r-- | scripts/coccinelle/api/devm_ioremap_resource.cocci | 90 | ||||
-rw-r--r-- | scripts/coccinelle/free/ifnullfree.cocci | 53 | ||||
-rwxr-xr-x | scripts/get_maintainer.pl | 22 | ||||
-rw-r--r-- | scripts/mod/modpost.c | 58 | ||||
-rw-r--r-- | scripts/selinux/genheaders/Makefile | 1 | ||||
-rw-r--r-- | scripts/selinux/mdp/Makefile | 2 | ||||
-rwxr-xr-x | scripts/tags.sh | 2 |
15 files changed, 572 insertions, 262 deletions
diff --git a/scripts/.gitignore b/scripts/.gitignore index fb070fa1038f..5ecfe93f2028 100644 --- a/scripts/.gitignore +++ b/scripts/.gitignore | |||
@@ -4,7 +4,6 @@ | |||
4 | conmakehash | 4 | conmakehash |
5 | kallsyms | 5 | kallsyms |
6 | pnmtologo | 6 | pnmtologo |
7 | bin2c | ||
8 | unifdef | 7 | unifdef |
9 | ihex2fw | 8 | ihex2fw |
10 | recordmcount | 9 | recordmcount |
diff --git a/scripts/Makefile b/scripts/Makefile index 890df5c6adfb..72902b5f2721 100644 --- a/scripts/Makefile +++ b/scripts/Makefile | |||
@@ -13,7 +13,6 @@ HOST_EXTRACFLAGS += -I$(srctree)/tools/include | |||
13 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms | 13 | hostprogs-$(CONFIG_KALLSYMS) += kallsyms |
14 | hostprogs-$(CONFIG_LOGO) += pnmtologo | 14 | hostprogs-$(CONFIG_LOGO) += pnmtologo |
15 | hostprogs-$(CONFIG_VT) += conmakehash | 15 | hostprogs-$(CONFIG_VT) += conmakehash |
16 | hostprogs-$(CONFIG_IKCONFIG) += bin2c | ||
17 | hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount | 16 | hostprogs-$(BUILD_C_RECORDMCOUNT) += recordmcount |
18 | hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable | 17 | hostprogs-$(CONFIG_BUILDTIME_EXTABLE_SORT) += sortextable |
19 | hostprogs-$(CONFIG_ASN1) += asn1_compiler | 18 | hostprogs-$(CONFIG_ASN1) += asn1_compiler |
diff --git a/scripts/Makefile.modinst b/scripts/Makefile.modinst index ecbb44797e28..95ec7b35e8b6 100644 --- a/scripts/Makefile.modinst +++ b/scripts/Makefile.modinst | |||
@@ -31,6 +31,6 @@ $(modules): | |||
31 | 31 | ||
32 | 32 | ||
33 | # Declare the contents of the .PHONY variable as phony. We keep that | 33 | # Declare the contents of the .PHONY variable as phony. We keep that |
34 | # information in a variable se we can use it in if_changed and friends. | 34 | # information in a variable so we can use it in if_changed and friends. |
35 | 35 | ||
36 | .PHONY: $(PHONY) | 36 | .PHONY: $(PHONY) |
diff --git a/scripts/basic/.gitignore b/scripts/basic/.gitignore index a776371a3502..9528ec9e5adc 100644 --- a/scripts/basic/.gitignore +++ b/scripts/basic/.gitignore | |||
@@ -1 +1,2 @@ | |||
1 | fixdep | 1 | fixdep |
2 | bin2c | ||
diff --git a/scripts/basic/Makefile b/scripts/basic/Makefile index 4fcef87bb875..ec10d9345bc2 100644 --- a/scripts/basic/Makefile +++ b/scripts/basic/Makefile | |||
@@ -9,6 +9,7 @@ | |||
9 | # fixdep: Used to generate dependency information during build process | 9 | # fixdep: Used to generate dependency information during build process |
10 | 10 | ||
11 | hostprogs-y := fixdep | 11 | hostprogs-y := fixdep |
12 | hostprogs-$(CONFIG_BUILD_BIN2C) += bin2c | ||
12 | always := $(hostprogs-y) | 13 | always := $(hostprogs-y) |
13 | 14 | ||
14 | # fixdep is needed to compile other host programs | 15 | # fixdep is needed to compile other host programs |
diff --git a/scripts/bin2c.c b/scripts/basic/bin2c.c index 96dd2bcbb407..af187e695345 100644 --- a/scripts/bin2c.c +++ b/scripts/basic/bin2c.c | |||
@@ -11,7 +11,7 @@ | |||
11 | 11 | ||
12 | int main(int argc, char *argv[]) | 12 | int main(int argc, char *argv[]) |
13 | { | 13 | { |
14 | int ch, total=0; | 14 | int ch, total = 0; |
15 | 15 | ||
16 | if (argc > 1) | 16 | if (argc > 1) |
17 | printf("const char %s[] %s=\n", | 17 | printf("const char %s[] %s=\n", |
@@ -19,10 +19,9 @@ int main(int argc, char *argv[]) | |||
19 | 19 | ||
20 | do { | 20 | do { |
21 | printf("\t\""); | 21 | printf("\t\""); |
22 | while ((ch = getchar()) != EOF) | 22 | while ((ch = getchar()) != EOF) { |
23 | { | ||
24 | total++; | 23 | total++; |
25 | printf("\\x%02x",ch); | 24 | printf("\\x%02x", ch); |
26 | if (total % 16 == 0) | 25 | if (total % 16 == 0) |
27 | break; | 26 | break; |
28 | } | 27 | } |
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index 182be0f12407..31a731e06f50 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -309,9 +309,12 @@ our $Operators = qr{ | |||
309 | our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x; | 309 | our $c90_Keywords = qr{do|for|while|if|else|return|goto|continue|switch|default|case|break}x; |
310 | 310 | ||
311 | our $NonptrType; | 311 | our $NonptrType; |
312 | our $NonptrTypeMisordered; | ||
312 | our $NonptrTypeWithAttr; | 313 | our $NonptrTypeWithAttr; |
313 | our $Type; | 314 | our $Type; |
315 | our $TypeMisordered; | ||
314 | our $Declare; | 316 | our $Declare; |
317 | our $DeclareMisordered; | ||
315 | 318 | ||
316 | our $NON_ASCII_UTF8 = qr{ | 319 | our $NON_ASCII_UTF8 = qr{ |
317 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | 320 | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte |
@@ -353,16 +356,36 @@ our $signature_tags = qr{(?xi: | |||
353 | Cc: | 356 | Cc: |
354 | )}; | 357 | )}; |
355 | 358 | ||
359 | our @typeListMisordered = ( | ||
360 | qr{char\s+(?:un)?signed}, | ||
361 | qr{int\s+(?:(?:un)?signed\s+)?short\s}, | ||
362 | qr{int\s+short(?:\s+(?:un)?signed)}, | ||
363 | qr{short\s+int(?:\s+(?:un)?signed)}, | ||
364 | qr{(?:un)?signed\s+int\s+short}, | ||
365 | qr{short\s+(?:un)?signed}, | ||
366 | qr{long\s+int\s+(?:un)?signed}, | ||
367 | qr{int\s+long\s+(?:un)?signed}, | ||
368 | qr{long\s+(?:un)?signed\s+int}, | ||
369 | qr{int\s+(?:un)?signed\s+long}, | ||
370 | qr{int\s+(?:un)?signed}, | ||
371 | qr{int\s+long\s+long\s+(?:un)?signed}, | ||
372 | qr{long\s+long\s+int\s+(?:un)?signed}, | ||
373 | qr{long\s+long\s+(?:un)?signed\s+int}, | ||
374 | qr{long\s+long\s+(?:un)?signed}, | ||
375 | qr{long\s+(?:un)?signed}, | ||
376 | ); | ||
377 | |||
356 | our @typeList = ( | 378 | our @typeList = ( |
357 | qr{void}, | 379 | qr{void}, |
358 | qr{(?:unsigned\s+)?char}, | 380 | qr{(?:(?:un)?signed\s+)?char}, |
359 | qr{(?:unsigned\s+)?short}, | 381 | qr{(?:(?:un)?signed\s+)?short\s+int}, |
360 | qr{(?:unsigned\s+)?int}, | 382 | qr{(?:(?:un)?signed\s+)?short}, |
361 | qr{(?:unsigned\s+)?long}, | 383 | qr{(?:(?:un)?signed\s+)?int}, |
362 | qr{(?:unsigned\s+)?long\s+int}, | 384 | qr{(?:(?:un)?signed\s+)?long\s+int}, |
363 | qr{(?:unsigned\s+)?long\s+long}, | 385 | qr{(?:(?:un)?signed\s+)?long\s+long\s+int}, |
364 | qr{(?:unsigned\s+)?long\s+long\s+int}, | 386 | qr{(?:(?:un)?signed\s+)?long\s+long}, |
365 | qr{unsigned}, | 387 | qr{(?:(?:un)?signed\s+)?long}, |
388 | qr{(?:un)?signed}, | ||
366 | qr{float}, | 389 | qr{float}, |
367 | qr{double}, | 390 | qr{double}, |
368 | qr{bool}, | 391 | qr{bool}, |
@@ -372,6 +395,7 @@ our @typeList = ( | |||
372 | qr{${Ident}_t}, | 395 | qr{${Ident}_t}, |
373 | qr{${Ident}_handler}, | 396 | qr{${Ident}_handler}, |
374 | qr{${Ident}_handler_fn}, | 397 | qr{${Ident}_handler_fn}, |
398 | @typeListMisordered, | ||
375 | ); | 399 | ); |
376 | our @typeListWithAttr = ( | 400 | our @typeListWithAttr = ( |
377 | @typeList, | 401 | @typeList, |
@@ -399,11 +423,6 @@ foreach my $entry (@mode_permission_funcs) { | |||
399 | $mode_perms_search .= $entry->[0]; | 423 | $mode_perms_search .= $entry->[0]; |
400 | } | 424 | } |
401 | 425 | ||
402 | our $declaration_macros = qr{(?x: | ||
403 | (?:$Storage\s+)?(?:DECLARE|DEFINE)_[A-Z]+\s*\(| | ||
404 | (?:$Storage\s+)?LIST_HEAD\s*\( | ||
405 | )}; | ||
406 | |||
407 | our $allowed_asm_includes = qr{(?x: | 426 | our $allowed_asm_includes = qr{(?x: |
408 | irq| | 427 | irq| |
409 | memory | 428 | memory |
@@ -413,6 +432,7 @@ our $allowed_asm_includes = qr{(?x: | |||
413 | sub build_types { | 432 | sub build_types { |
414 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; | 433 | my $mods = "(?x: \n" . join("|\n ", @modifierList) . "\n)"; |
415 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; | 434 | my $all = "(?x: \n" . join("|\n ", @typeList) . "\n)"; |
435 | my $Misordered = "(?x: \n" . join("|\n ", @typeListMisordered) . "\n)"; | ||
416 | my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; | 436 | my $allWithAttr = "(?x: \n" . join("|\n ", @typeListWithAttr) . "\n)"; |
417 | $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; | 437 | $Modifier = qr{(?:$Attribute|$Sparse|$mods)}; |
418 | $NonptrType = qr{ | 438 | $NonptrType = qr{ |
@@ -424,6 +444,13 @@ sub build_types { | |||
424 | ) | 444 | ) |
425 | (?:\s+$Modifier|\s+const)* | 445 | (?:\s+$Modifier|\s+const)* |
426 | }x; | 446 | }x; |
447 | $NonptrTypeMisordered = qr{ | ||
448 | (?:$Modifier\s+|const\s+)* | ||
449 | (?: | ||
450 | (?:${Misordered}\b) | ||
451 | ) | ||
452 | (?:\s+$Modifier|\s+const)* | ||
453 | }x; | ||
427 | $NonptrTypeWithAttr = qr{ | 454 | $NonptrTypeWithAttr = qr{ |
428 | (?:$Modifier\s+|const\s+)* | 455 | (?:$Modifier\s+|const\s+)* |
429 | (?: | 456 | (?: |
@@ -435,10 +462,16 @@ sub build_types { | |||
435 | }x; | 462 | }x; |
436 | $Type = qr{ | 463 | $Type = qr{ |
437 | $NonptrType | 464 | $NonptrType |
438 | (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*|\[\])+|(?:\s*\[\s*\])+)? | 465 | (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)? |
466 | (?:\s+$Inline|\s+$Modifier)* | ||
467 | }x; | ||
468 | $TypeMisordered = qr{ | ||
469 | $NonptrTypeMisordered | ||
470 | (?:(?:\s|\*|\[\])+\s*const|(?:\s|\*\s*(?:const\s*)?|\[\])+|(?:\s*\[\s*\])+)? | ||
439 | (?:\s+$Inline|\s+$Modifier)* | 471 | (?:\s+$Inline|\s+$Modifier)* |
440 | }x; | 472 | }x; |
441 | $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type}; | 473 | $Declare = qr{(?:$Storage\s+(?:$Inline\s+)?)?$Type}; |
474 | $DeclareMisordered = qr{(?:$Storage\s+(?:$Inline\s+)?)?$TypeMisordered}; | ||
442 | } | 475 | } |
443 | build_types(); | 476 | build_types(); |
444 | 477 | ||
@@ -452,6 +485,12 @@ our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; | |||
452 | our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*}; | 485 | our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*}; |
453 | our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; | 486 | our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; |
454 | 487 | ||
488 | our $declaration_macros = qr{(?x: | ||
489 | (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(| | ||
490 | (?:$Storage\s+)?LIST_HEAD\s*\(| | ||
491 | (?:$Storage\s+)?${Type}\s+uninitialized_var\s*\( | ||
492 | )}; | ||
493 | |||
455 | sub deparenthesize { | 494 | sub deparenthesize { |
456 | my ($string) = @_; | 495 | my ($string) = @_; |
457 | return "" if (!defined($string)); | 496 | return "" if (!defined($string)); |
@@ -550,11 +589,43 @@ sub seed_camelcase_includes { | |||
550 | } | 589 | } |
551 | } | 590 | } |
552 | 591 | ||
592 | sub git_commit_info { | ||
593 | my ($commit, $id, $desc) = @_; | ||
594 | |||
595 | return ($id, $desc) if ((which("git") eq "") || !(-e ".git")); | ||
596 | |||
597 | my $output = `git log --no-color --format='%H %s' -1 $commit 2>&1`; | ||
598 | $output =~ s/^\s*//gm; | ||
599 | my @lines = split("\n", $output); | ||
600 | |||
601 | if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { | ||
602 | # Maybe one day convert this block of bash into something that returns | ||
603 | # all matching commit ids, but it's very slow... | ||
604 | # | ||
605 | # echo "checking commits $1..." | ||
606 | # git rev-list --remotes | grep -i "^$1" | | ||
607 | # while read line ; do | ||
608 | # git log --format='%H %s' -1 $line | | ||
609 | # echo "commit $(cut -c 1-12,41-)" | ||
610 | # done | ||
611 | } elsif ($lines[0] =~ /^fatal: ambiguous argument '$commit': unknown revision or path not in the working tree\./) { | ||
612 | } else { | ||
613 | $id = substr($lines[0], 0, 12); | ||
614 | $desc = substr($lines[0], 41); | ||
615 | } | ||
616 | |||
617 | return ($id, $desc); | ||
618 | } | ||
619 | |||
553 | $chk_signoff = 0 if ($file); | 620 | $chk_signoff = 0 if ($file); |
554 | 621 | ||
555 | my @rawlines = (); | 622 | my @rawlines = (); |
556 | my @lines = (); | 623 | my @lines = (); |
557 | my @fixed = (); | 624 | my @fixed = (); |
625 | my @fixed_inserted = (); | ||
626 | my @fixed_deleted = (); | ||
627 | my $fixlinenr = -1; | ||
628 | |||
558 | my $vname; | 629 | my $vname; |
559 | for my $filename (@ARGV) { | 630 | for my $filename (@ARGV) { |
560 | my $FILE; | 631 | my $FILE; |
@@ -583,6 +654,9 @@ for my $filename (@ARGV) { | |||
583 | @rawlines = (); | 654 | @rawlines = (); |
584 | @lines = (); | 655 | @lines = (); |
585 | @fixed = (); | 656 | @fixed = (); |
657 | @fixed_inserted = (); | ||
658 | @fixed_deleted = (); | ||
659 | $fixlinenr = -1; | ||
586 | } | 660 | } |
587 | 661 | ||
588 | exit($exit); | 662 | exit($exit); |
@@ -674,6 +748,18 @@ sub format_email { | |||
674 | return $formatted_email; | 748 | return $formatted_email; |
675 | } | 749 | } |
676 | 750 | ||
751 | sub which { | ||
752 | my ($bin) = @_; | ||
753 | |||
754 | foreach my $path (split(/:/, $ENV{PATH})) { | ||
755 | if (-e "$path/$bin") { | ||
756 | return "$path/$bin"; | ||
757 | } | ||
758 | } | ||
759 | |||
760 | return ""; | ||
761 | } | ||
762 | |||
677 | sub which_conf { | 763 | sub which_conf { |
678 | my ($conf) = @_; | 764 | my ($conf) = @_; |
679 | 765 | ||
@@ -1483,6 +1569,90 @@ sub report_dump { | |||
1483 | our @report; | 1569 | our @report; |
1484 | } | 1570 | } |
1485 | 1571 | ||
1572 | sub fixup_current_range { | ||
1573 | my ($lineRef, $offset, $length) = @_; | ||
1574 | |||
1575 | if ($$lineRef =~ /^\@\@ -\d+,\d+ \+(\d+),(\d+) \@\@/) { | ||
1576 | my $o = $1; | ||
1577 | my $l = $2; | ||
1578 | my $no = $o + $offset; | ||
1579 | my $nl = $l + $length; | ||
1580 | $$lineRef =~ s/\+$o,$l \@\@/\+$no,$nl \@\@/; | ||
1581 | } | ||
1582 | } | ||
1583 | |||
1584 | sub fix_inserted_deleted_lines { | ||
1585 | my ($linesRef, $insertedRef, $deletedRef) = @_; | ||
1586 | |||
1587 | my $range_last_linenr = 0; | ||
1588 | my $delta_offset = 0; | ||
1589 | |||
1590 | my $old_linenr = 0; | ||
1591 | my $new_linenr = 0; | ||
1592 | |||
1593 | my $next_insert = 0; | ||
1594 | my $next_delete = 0; | ||
1595 | |||
1596 | my @lines = (); | ||
1597 | |||
1598 | my $inserted = @{$insertedRef}[$next_insert++]; | ||
1599 | my $deleted = @{$deletedRef}[$next_delete++]; | ||
1600 | |||
1601 | foreach my $old_line (@{$linesRef}) { | ||
1602 | my $save_line = 1; | ||
1603 | my $line = $old_line; #don't modify the array | ||
1604 | if ($line =~ /^(?:\+\+\+\|\-\-\-)\s+\S+/) { #new filename | ||
1605 | $delta_offset = 0; | ||
1606 | } elsif ($line =~ /^\@\@ -\d+,\d+ \+\d+,\d+ \@\@/) { #new hunk | ||
1607 | $range_last_linenr = $new_linenr; | ||
1608 | fixup_current_range(\$line, $delta_offset, 0); | ||
1609 | } | ||
1610 | |||
1611 | while (defined($deleted) && ${$deleted}{'LINENR'} == $old_linenr) { | ||
1612 | $deleted = @{$deletedRef}[$next_delete++]; | ||
1613 | $save_line = 0; | ||
1614 | fixup_current_range(\$lines[$range_last_linenr], $delta_offset--, -1); | ||
1615 | } | ||
1616 | |||
1617 | while (defined($inserted) && ${$inserted}{'LINENR'} == $old_linenr) { | ||
1618 | push(@lines, ${$inserted}{'LINE'}); | ||
1619 | $inserted = @{$insertedRef}[$next_insert++]; | ||
1620 | $new_linenr++; | ||
1621 | fixup_current_range(\$lines[$range_last_linenr], $delta_offset++, 1); | ||
1622 | } | ||
1623 | |||
1624 | if ($save_line) { | ||
1625 | push(@lines, $line); | ||
1626 | $new_linenr++; | ||
1627 | } | ||
1628 | |||
1629 | $old_linenr++; | ||
1630 | } | ||
1631 | |||
1632 | return @lines; | ||
1633 | } | ||
1634 | |||
1635 | sub fix_insert_line { | ||
1636 | my ($linenr, $line) = @_; | ||
1637 | |||
1638 | my $inserted = { | ||
1639 | LINENR => $linenr, | ||
1640 | LINE => $line, | ||
1641 | }; | ||
1642 | push(@fixed_inserted, $inserted); | ||
1643 | } | ||
1644 | |||
1645 | sub fix_delete_line { | ||
1646 | my ($linenr, $line) = @_; | ||
1647 | |||
1648 | my $deleted = { | ||
1649 | LINENR => $linenr, | ||
1650 | LINE => $line, | ||
1651 | }; | ||
1652 | |||
1653 | push(@fixed_deleted, $deleted); | ||
1654 | } | ||
1655 | |||
1486 | sub ERROR { | 1656 | sub ERROR { |
1487 | my ($type, $msg) = @_; | 1657 | my ($type, $msg) = @_; |
1488 | 1658 | ||
@@ -1637,11 +1807,13 @@ sub process { | |||
1637 | my $signoff = 0; | 1807 | my $signoff = 0; |
1638 | my $is_patch = 0; | 1808 | my $is_patch = 0; |
1639 | 1809 | ||
1640 | my $in_header_lines = 1; | 1810 | my $in_header_lines = $file ? 0 : 1; |
1641 | my $in_commit_log = 0; #Scanning lines before patch | 1811 | my $in_commit_log = 0; #Scanning lines before patch |
1642 | 1812 | my $reported_maintainer_file = 0; | |
1643 | my $non_utf8_charset = 0; | 1813 | my $non_utf8_charset = 0; |
1644 | 1814 | ||
1815 | my $last_blank_line = 0; | ||
1816 | |||
1645 | our @report = (); | 1817 | our @report = (); |
1646 | our $cnt_lines = 0; | 1818 | our $cnt_lines = 0; |
1647 | our $cnt_error = 0; | 1819 | our $cnt_error = 0; |
@@ -1759,8 +1931,10 @@ sub process { | |||
1759 | 1931 | ||
1760 | $realcnt = 0; | 1932 | $realcnt = 0; |
1761 | $linenr = 0; | 1933 | $linenr = 0; |
1934 | $fixlinenr = -1; | ||
1762 | foreach my $line (@lines) { | 1935 | foreach my $line (@lines) { |
1763 | $linenr++; | 1936 | $linenr++; |
1937 | $fixlinenr++; | ||
1764 | my $sline = $line; #copy of $line | 1938 | my $sline = $line; #copy of $line |
1765 | $sline =~ s/$;/ /g; #with comments as spaces | 1939 | $sline =~ s/$;/ /g; #with comments as spaces |
1766 | 1940 | ||
@@ -1891,7 +2065,7 @@ sub process { | |||
1891 | if (WARN("BAD_SIGN_OFF", | 2065 | if (WARN("BAD_SIGN_OFF", |
1892 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr) && | 2066 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr) && |
1893 | $fix) { | 2067 | $fix) { |
1894 | $fixed[$linenr - 1] = | 2068 | $fixed[$fixlinenr] = |
1895 | "$ucfirst_sign_off $email"; | 2069 | "$ucfirst_sign_off $email"; |
1896 | } | 2070 | } |
1897 | } | 2071 | } |
@@ -1899,7 +2073,7 @@ sub process { | |||
1899 | if (WARN("BAD_SIGN_OFF", | 2073 | if (WARN("BAD_SIGN_OFF", |
1900 | "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr) && | 2074 | "'$ucfirst_sign_off' is the preferred signature form\n" . $herecurr) && |
1901 | $fix) { | 2075 | $fix) { |
1902 | $fixed[$linenr - 1] = | 2076 | $fixed[$fixlinenr] = |
1903 | "$ucfirst_sign_off $email"; | 2077 | "$ucfirst_sign_off $email"; |
1904 | } | 2078 | } |
1905 | 2079 | ||
@@ -1908,7 +2082,7 @@ sub process { | |||
1908 | if (WARN("BAD_SIGN_OFF", | 2082 | if (WARN("BAD_SIGN_OFF", |
1909 | "Use a single space after $ucfirst_sign_off\n" . $herecurr) && | 2083 | "Use a single space after $ucfirst_sign_off\n" . $herecurr) && |
1910 | $fix) { | 2084 | $fix) { |
1911 | $fixed[$linenr - 1] = | 2085 | $fixed[$fixlinenr] = |
1912 | "$ucfirst_sign_off $email"; | 2086 | "$ucfirst_sign_off $email"; |
1913 | } | 2087 | } |
1914 | } | 2088 | } |
@@ -1956,6 +2130,31 @@ sub process { | |||
1956 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); | 2130 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); |
1957 | } | 2131 | } |
1958 | 2132 | ||
2133 | # Check for improperly formed commit descriptions | ||
2134 | if ($in_commit_log && | ||
2135 | $line =~ /\bcommit\s+[0-9a-f]{5,}/i && | ||
2136 | $line !~ /\b[Cc]ommit [0-9a-f]{12,16} \("/) { | ||
2137 | $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i; | ||
2138 | my $init_char = $1; | ||
2139 | my $orig_commit = lc($2); | ||
2140 | my $id = '01234567890ab'; | ||
2141 | my $desc = 'commit description'; | ||
2142 | ($id, $desc) = git_commit_info($orig_commit, $id, $desc); | ||
2143 | ERROR("GIT_COMMIT_ID", | ||
2144 | "Please use 12 to 16 chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr); | ||
2145 | } | ||
2146 | |||
2147 | # Check for added, moved or deleted files | ||
2148 | if (!$reported_maintainer_file && !$in_commit_log && | ||
2149 | ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || | ||
2150 | $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || | ||
2151 | ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && | ||
2152 | (defined($1) || defined($2))))) { | ||
2153 | $reported_maintainer_file = 1; | ||
2154 | WARN("FILE_PATH_CHANGES", | ||
2155 | "added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); | ||
2156 | } | ||
2157 | |||
1959 | # Check for wrappage within a valid hunk of the file | 2158 | # Check for wrappage within a valid hunk of the file |
1960 | if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) { | 2159 | if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) { |
1961 | ERROR("CORRUPTED_PATCH", | 2160 | ERROR("CORRUPTED_PATCH", |
@@ -1993,7 +2192,8 @@ sub process { | |||
1993 | # Check if it's the start of a commit log | 2192 | # Check if it's the start of a commit log |
1994 | # (not a header line and we haven't seen the patch filename) | 2193 | # (not a header line and we haven't seen the patch filename) |
1995 | if ($in_header_lines && $realfile =~ /^$/ && | 2194 | if ($in_header_lines && $realfile =~ /^$/ && |
1996 | $rawline !~ /^(commit\b|from\b|[\w-]+:).+$/i) { | 2195 | !($rawline =~ /^\s+\S/ || |
2196 | $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) { | ||
1997 | $in_header_lines = 0; | 2197 | $in_header_lines = 0; |
1998 | $in_commit_log = 1; | 2198 | $in_commit_log = 1; |
1999 | } | 2199 | } |
@@ -2021,14 +2221,14 @@ sub process { | |||
2021 | if (ERROR("DOS_LINE_ENDINGS", | 2221 | if (ERROR("DOS_LINE_ENDINGS", |
2022 | "DOS line endings\n" . $herevet) && | 2222 | "DOS line endings\n" . $herevet) && |
2023 | $fix) { | 2223 | $fix) { |
2024 | $fixed[$linenr - 1] =~ s/[\s\015]+$//; | 2224 | $fixed[$fixlinenr] =~ s/[\s\015]+$//; |
2025 | } | 2225 | } |
2026 | } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { | 2226 | } elsif ($rawline =~ /^\+.*\S\s+$/ || $rawline =~ /^\+\s+$/) { |
2027 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; | 2227 | my $herevet = "$here\n" . cat_vet($rawline) . "\n"; |
2028 | if (ERROR("TRAILING_WHITESPACE", | 2228 | if (ERROR("TRAILING_WHITESPACE", |
2029 | "trailing whitespace\n" . $herevet) && | 2229 | "trailing whitespace\n" . $herevet) && |
2030 | $fix) { | 2230 | $fix) { |
2031 | $fixed[$linenr - 1] =~ s/\s+$//; | 2231 | $fixed[$fixlinenr] =~ s/\s+$//; |
2032 | } | 2232 | } |
2033 | 2233 | ||
2034 | $rpt_cleaners = 1; | 2234 | $rpt_cleaners = 1; |
@@ -2049,7 +2249,7 @@ sub process { | |||
2049 | # Only applies when adding the entry originally, after that we do not have | 2249 | # Only applies when adding the entry originally, after that we do not have |
2050 | # sufficient context to determine whether it is indeed long enough. | 2250 | # sufficient context to determine whether it is indeed long enough. |
2051 | if ($realfile =~ /Kconfig/ && | 2251 | if ($realfile =~ /Kconfig/ && |
2052 | $line =~ /.\s*config\s+/) { | 2252 | $line =~ /^\+\s*config\s+/) { |
2053 | my $length = 0; | 2253 | my $length = 0; |
2054 | my $cnt = $realcnt; | 2254 | my $cnt = $realcnt; |
2055 | my $ln = $linenr + 1; | 2255 | my $ln = $linenr + 1; |
@@ -2062,10 +2262,11 @@ sub process { | |||
2062 | $is_end = $lines[$ln - 1] =~ /^\+/; | 2262 | $is_end = $lines[$ln - 1] =~ /^\+/; |
2063 | 2263 | ||
2064 | next if ($f =~ /^-/); | 2264 | next if ($f =~ /^-/); |
2265 | last if (!$file && $f =~ /^\@\@/); | ||
2065 | 2266 | ||
2066 | if ($lines[$ln - 1] =~ /.\s*(?:bool|tristate)\s*\"/) { | 2267 | if ($lines[$ln - 1] =~ /^\+\s*(?:bool|tristate)\s*\"/) { |
2067 | $is_start = 1; | 2268 | $is_start = 1; |
2068 | } elsif ($lines[$ln - 1] =~ /.\s*(?:---)?help(?:---)?$/) { | 2269 | } elsif ($lines[$ln - 1] =~ /^\+\s*(?:---)?help(?:---)?$/) { |
2069 | $length = -1; | 2270 | $length = -1; |
2070 | } | 2271 | } |
2071 | 2272 | ||
@@ -2161,12 +2362,18 @@ sub process { | |||
2161 | "quoted string split across lines\n" . $hereprev); | 2362 | "quoted string split across lines\n" . $hereprev); |
2162 | } | 2363 | } |
2163 | 2364 | ||
2365 | # check for missing a space in a string concatination | ||
2366 | if ($prevrawline =~ /[^\\]\w"$/ && $rawline =~ /^\+[\t ]+"\w/) { | ||
2367 | WARN('MISSING_SPACE', | ||
2368 | "break quoted strings at a space character\n" . $hereprev); | ||
2369 | } | ||
2370 | |||
2164 | # check for spaces before a quoted newline | 2371 | # check for spaces before a quoted newline |
2165 | if ($rawline =~ /^.*\".*\s\\n/) { | 2372 | if ($rawline =~ /^.*\".*\s\\n/) { |
2166 | if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", | 2373 | if (WARN("QUOTED_WHITESPACE_BEFORE_NEWLINE", |
2167 | "unnecessary whitespace before a quoted newline\n" . $herecurr) && | 2374 | "unnecessary whitespace before a quoted newline\n" . $herecurr) && |
2168 | $fix) { | 2375 | $fix) { |
2169 | $fixed[$linenr - 1] =~ s/^(\+.*\".*)\s+\\n/$1\\n/; | 2376 | $fixed[$fixlinenr] =~ s/^(\+.*\".*)\s+\\n/$1\\n/; |
2170 | } | 2377 | } |
2171 | 2378 | ||
2172 | } | 2379 | } |
@@ -2203,7 +2410,7 @@ sub process { | |||
2203 | if (ERROR("CODE_INDENT", | 2410 | if (ERROR("CODE_INDENT", |
2204 | "code indent should use tabs where possible\n" . $herevet) && | 2411 | "code indent should use tabs where possible\n" . $herevet) && |
2205 | $fix) { | 2412 | $fix) { |
2206 | $fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e; | 2413 | $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e; |
2207 | } | 2414 | } |
2208 | } | 2415 | } |
2209 | 2416 | ||
@@ -2213,9 +2420,9 @@ sub process { | |||
2213 | if (WARN("SPACE_BEFORE_TAB", | 2420 | if (WARN("SPACE_BEFORE_TAB", |
2214 | "please, no space before tabs\n" . $herevet) && | 2421 | "please, no space before tabs\n" . $herevet) && |
2215 | $fix) { | 2422 | $fix) { |
2216 | while ($fixed[$linenr - 1] =~ | 2423 | while ($fixed[$fixlinenr] =~ |
2217 | s/(^\+.*) {8,8}+\t/$1\t\t/) {} | 2424 | s/(^\+.*) {8,8}+\t/$1\t\t/) {} |
2218 | while ($fixed[$linenr - 1] =~ | 2425 | while ($fixed[$fixlinenr] =~ |
2219 | s/(^\+.*) +\t/$1\t/) {} | 2426 | s/(^\+.*) +\t/$1\t/) {} |
2220 | } | 2427 | } |
2221 | } | 2428 | } |
@@ -2249,19 +2456,19 @@ sub process { | |||
2249 | if (CHK("PARENTHESIS_ALIGNMENT", | 2456 | if (CHK("PARENTHESIS_ALIGNMENT", |
2250 | "Alignment should match open parenthesis\n" . $hereprev) && | 2457 | "Alignment should match open parenthesis\n" . $hereprev) && |
2251 | $fix && $line =~ /^\+/) { | 2458 | $fix && $line =~ /^\+/) { |
2252 | $fixed[$linenr - 1] =~ | 2459 | $fixed[$fixlinenr] =~ |
2253 | s/^\+[ \t]*/\+$goodtabindent/; | 2460 | s/^\+[ \t]*/\+$goodtabindent/; |
2254 | } | 2461 | } |
2255 | } | 2462 | } |
2256 | } | 2463 | } |
2257 | } | 2464 | } |
2258 | 2465 | ||
2259 | if ($line =~ /^\+.*\*[ \t]*\)[ \t]+(?!$Assignment|$Arithmetic)/) { | 2466 | if ($line =~ /^\+.*\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|{)/) { |
2260 | if (CHK("SPACING", | 2467 | if (CHK("SPACING", |
2261 | "No space is necessary after a cast\n" . $hereprev) && | 2468 | "No space is necessary after a cast\n" . $herecurr) && |
2262 | $fix) { | 2469 | $fix) { |
2263 | $fixed[$linenr - 1] =~ | 2470 | $fixed[$fixlinenr] =~ |
2264 | s/^(\+.*\*[ \t]*\))[ \t]+/$1/; | 2471 | s/(\(\s*$Type\s*\))[ \t]+/$1/; |
2265 | } | 2472 | } |
2266 | } | 2473 | } |
2267 | 2474 | ||
@@ -2291,10 +2498,44 @@ sub process { | |||
2291 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); | 2498 | "networking block comments put the trailing */ on a separate line\n" . $herecurr); |
2292 | } | 2499 | } |
2293 | 2500 | ||
2501 | # check for missing blank lines after struct/union declarations | ||
2502 | # with exceptions for various attributes and macros | ||
2503 | if ($prevline =~ /^[\+ ]};?\s*$/ && | ||
2504 | $line =~ /^\+/ && | ||
2505 | !($line =~ /^\+\s*$/ || | ||
2506 | $line =~ /^\+\s*EXPORT_SYMBOL/ || | ||
2507 | $line =~ /^\+\s*MODULE_/i || | ||
2508 | $line =~ /^\+\s*\#\s*(?:end|elif|else)/ || | ||
2509 | $line =~ /^\+[a-z_]*init/ || | ||
2510 | $line =~ /^\+\s*(?:static\s+)?[A-Z_]*ATTR/ || | ||
2511 | $line =~ /^\+\s*DECLARE/ || | ||
2512 | $line =~ /^\+\s*__setup/)) { | ||
2513 | if (CHK("LINE_SPACING", | ||
2514 | "Please use a blank line after function/struct/union/enum declarations\n" . $hereprev) && | ||
2515 | $fix) { | ||
2516 | fix_insert_line($fixlinenr, "\+"); | ||
2517 | } | ||
2518 | } | ||
2519 | |||
2520 | # check for multiple consecutive blank lines | ||
2521 | if ($prevline =~ /^[\+ ]\s*$/ && | ||
2522 | $line =~ /^\+\s*$/ && | ||
2523 | $last_blank_line != ($linenr - 1)) { | ||
2524 | if (CHK("LINE_SPACING", | ||
2525 | "Please don't use multiple blank lines\n" . $hereprev) && | ||
2526 | $fix) { | ||
2527 | fix_delete_line($fixlinenr, $rawline); | ||
2528 | } | ||
2529 | |||
2530 | $last_blank_line = $linenr; | ||
2531 | } | ||
2532 | |||
2294 | # check for missing blank lines after declarations | 2533 | # check for missing blank lines after declarations |
2295 | if ($sline =~ /^\+\s+\S/ && #Not at char 1 | 2534 | if ($sline =~ /^\+\s+\S/ && #Not at char 1 |
2296 | # actual declarations | 2535 | # actual declarations |
2297 | ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || | 2536 | ($prevline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
2537 | # function pointer declarations | ||
2538 | $prevline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ || | ||
2298 | # foo bar; where foo is some local typedef or #define | 2539 | # foo bar; where foo is some local typedef or #define |
2299 | $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || | 2540 | $prevline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
2300 | # known declaration macros | 2541 | # known declaration macros |
@@ -2307,6 +2548,8 @@ sub process { | |||
2307 | $prevline =~ /(?:\{\s*|\\)$/) && | 2548 | $prevline =~ /(?:\{\s*|\\)$/) && |
2308 | # looks like a declaration | 2549 | # looks like a declaration |
2309 | !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || | 2550 | !($sline =~ /^\+\s+$Declare\s*$Ident\s*[=,;:\[]/ || |
2551 | # function pointer declarations | ||
2552 | $sline =~ /^\+\s+$Declare\s*\(\s*\*\s*$Ident\s*\)\s*[=,;:\[\(]/ || | ||
2310 | # foo bar; where foo is some local typedef or #define | 2553 | # foo bar; where foo is some local typedef or #define |
2311 | $sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || | 2554 | $sline =~ /^\+\s+$Ident(?:\s+|\s*\*\s*)$Ident\s*[=,;\[]/ || |
2312 | # known declaration macros | 2555 | # known declaration macros |
@@ -2321,8 +2564,11 @@ sub process { | |||
2321 | $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) && | 2564 | $sline =~ /^\+\s+\(?\s*(?:$Compare|$Assignment|$Operators)/) && |
2322 | # indentation of previous and current line are the same | 2565 | # indentation of previous and current line are the same |
2323 | (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) { | 2566 | (($prevline =~ /\+(\s+)\S/) && $sline =~ /^\+$1\S/)) { |
2324 | WARN("SPACING", | 2567 | if (WARN("LINE_SPACING", |
2325 | "Missing a blank line after declarations\n" . $hereprev); | 2568 | "Missing a blank line after declarations\n" . $hereprev) && |
2569 | $fix) { | ||
2570 | fix_insert_line($fixlinenr, "\+"); | ||
2571 | } | ||
2326 | } | 2572 | } |
2327 | 2573 | ||
2328 | # check for spaces at the beginning of a line. | 2574 | # check for spaces at the beginning of a line. |
@@ -2335,13 +2581,33 @@ sub process { | |||
2335 | if (WARN("LEADING_SPACE", | 2581 | if (WARN("LEADING_SPACE", |
2336 | "please, no spaces at the start of a line\n" . $herevet) && | 2582 | "please, no spaces at the start of a line\n" . $herevet) && |
2337 | $fix) { | 2583 | $fix) { |
2338 | $fixed[$linenr - 1] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e; | 2584 | $fixed[$fixlinenr] =~ s/^\+([ \t]+)/"\+" . tabify($1)/e; |
2339 | } | 2585 | } |
2340 | } | 2586 | } |
2341 | 2587 | ||
2342 | # check we are in a valid C source file if not then ignore this hunk | 2588 | # check we are in a valid C source file if not then ignore this hunk |
2343 | next if ($realfile !~ /\.(h|c)$/); | 2589 | next if ($realfile !~ /\.(h|c)$/); |
2344 | 2590 | ||
2591 | # check indentation of any line with a bare else | ||
2592 | # if the previous line is a break or return and is indented 1 tab more... | ||
2593 | if ($sline =~ /^\+([\t]+)(?:}[ \t]*)?else(?:[ \t]*{)?\s*$/) { | ||
2594 | my $tabs = length($1) + 1; | ||
2595 | if ($prevline =~ /^\+\t{$tabs,$tabs}(?:break|return)\b/) { | ||
2596 | WARN("UNNECESSARY_ELSE", | ||
2597 | "else is not generally useful after a break or return\n" . $hereprev); | ||
2598 | } | ||
2599 | } | ||
2600 | |||
2601 | # check indentation of a line with a break; | ||
2602 | # if the previous line is a goto or return and is indented the same # of tabs | ||
2603 | if ($sline =~ /^\+([\t]+)break\s*;\s*$/) { | ||
2604 | my $tabs = $1; | ||
2605 | if ($prevline =~ /^\+$tabs(?:goto|return)\b/) { | ||
2606 | WARN("UNNECESSARY_BREAK", | ||
2607 | "break is not useful after a goto or return\n" . $hereprev); | ||
2608 | } | ||
2609 | } | ||
2610 | |||
2345 | # discourage the addition of CONFIG_EXPERIMENTAL in #if(def). | 2611 | # discourage the addition of CONFIG_EXPERIMENTAL in #if(def). |
2346 | if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) { | 2612 | if ($line =~ /^\+\s*\#\s*if.*\bCONFIG_EXPERIMENTAL\b/) { |
2347 | WARN("CONFIG_EXPERIMENTAL", | 2613 | WARN("CONFIG_EXPERIMENTAL", |
@@ -2477,7 +2743,7 @@ sub process { | |||
2477 | 2743 | ||
2478 | # if/while/etc brace do not go on next line, unless defining a do while loop, | 2744 | # if/while/etc brace do not go on next line, unless defining a do while loop, |
2479 | # or if that brace on the next line is for something else | 2745 | # or if that brace on the next line is for something else |
2480 | if ($line =~ /(.*)\b((?:if|while|for|switch)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) { | 2746 | if ($line =~ /(.*)\b((?:if|while|for|switch|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b|else\b)/ && $line !~ /^.\s*\#/) { |
2481 | my $pre_ctx = "$1$2"; | 2747 | my $pre_ctx = "$1$2"; |
2482 | 2748 | ||
2483 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); | 2749 | my ($level, @ctx) = ctx_statement_level($linenr, $realcnt, 0); |
@@ -2504,7 +2770,7 @@ sub process { | |||
2504 | #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; | 2770 | #print "realcnt<$realcnt> ctx_cnt<$ctx_cnt>\n"; |
2505 | #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; | 2771 | #print "pre<$pre_ctx>\nline<$line>\nctx<$ctx>\nnext<$lines[$ctx_ln - 1]>\n"; |
2506 | 2772 | ||
2507 | if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln -1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { | 2773 | if ($ctx !~ /{\s*/ && defined($lines[$ctx_ln - 1]) && $lines[$ctx_ln - 1] =~ /^\+\s*{/) { |
2508 | ERROR("OPEN_BRACE", | 2774 | ERROR("OPEN_BRACE", |
2509 | "that open brace { should be on the previous line\n" . | 2775 | "that open brace { should be on the previous line\n" . |
2510 | "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); | 2776 | "$here\n$ctx\n$rawlines[$ctx_ln - 1]\n"); |
@@ -2523,7 +2789,7 @@ sub process { | |||
2523 | } | 2789 | } |
2524 | 2790 | ||
2525 | # Check relative indent for conditionals and blocks. | 2791 | # Check relative indent for conditionals and blocks. |
2526 | if ($line =~ /\b(?:(?:if|while|for)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { | 2792 | if ($line =~ /\b(?:(?:if|while|for|(?:[a-z_]+|)for_each[a-z_]+)\s*\(|do\b)/ && $line !~ /^.\s*#/ && $line !~ /\}\s*while\s*/) { |
2527 | ($stat, $cond, $line_nr_next, $remain_next, $off_next) = | 2793 | ($stat, $cond, $line_nr_next, $remain_next, $off_next) = |
2528 | ctx_statement_block($linenr, $realcnt, 0) | 2794 | ctx_statement_block($linenr, $realcnt, 0) |
2529 | if (!defined $stat); | 2795 | if (!defined $stat); |
@@ -2654,8 +2920,18 @@ sub process { | |||
2654 | # check for initialisation to aggregates open brace on the next line | 2920 | # check for initialisation to aggregates open brace on the next line |
2655 | if ($line =~ /^.\s*{/ && | 2921 | if ($line =~ /^.\s*{/ && |
2656 | $prevline =~ /(?:^|[^=])=\s*$/) { | 2922 | $prevline =~ /(?:^|[^=])=\s*$/) { |
2657 | ERROR("OPEN_BRACE", | 2923 | if (ERROR("OPEN_BRACE", |
2658 | "that open brace { should be on the previous line\n" . $hereprev); | 2924 | "that open brace { should be on the previous line\n" . $hereprev) && |
2925 | $fix && $prevline =~ /^\+/ && $line =~ /^\+/) { | ||
2926 | fix_delete_line($fixlinenr - 1, $prevrawline); | ||
2927 | fix_delete_line($fixlinenr, $rawline); | ||
2928 | my $fixedline = $prevrawline; | ||
2929 | $fixedline =~ s/\s*=\s*$/ = {/; | ||
2930 | fix_insert_line($fixlinenr, $fixedline); | ||
2931 | $fixedline = $line; | ||
2932 | $fixedline =~ s/^(.\s*){\s*/$1/; | ||
2933 | fix_insert_line($fixlinenr, $fixedline); | ||
2934 | } | ||
2659 | } | 2935 | } |
2660 | 2936 | ||
2661 | # | 2937 | # |
@@ -2680,10 +2956,10 @@ sub process { | |||
2680 | if (ERROR("C99_COMMENTS", | 2956 | if (ERROR("C99_COMMENTS", |
2681 | "do not use C99 // comments\n" . $herecurr) && | 2957 | "do not use C99 // comments\n" . $herecurr) && |
2682 | $fix) { | 2958 | $fix) { |
2683 | my $line = $fixed[$linenr - 1]; | 2959 | my $line = $fixed[$fixlinenr]; |
2684 | if ($line =~ /\/\/(.*)$/) { | 2960 | if ($line =~ /\/\/(.*)$/) { |
2685 | my $comment = trim($1); | 2961 | my $comment = trim($1); |
2686 | $fixed[$linenr - 1] =~ s@\/\/(.*)$@/\* $comment \*/@; | 2962 | $fixed[$fixlinenr] =~ s@\/\/(.*)$@/\* $comment \*/@; |
2687 | } | 2963 | } |
2688 | } | 2964 | } |
2689 | } | 2965 | } |
@@ -2742,7 +3018,7 @@ sub process { | |||
2742 | "do not initialise globals to 0 or NULL\n" . | 3018 | "do not initialise globals to 0 or NULL\n" . |
2743 | $herecurr) && | 3019 | $herecurr) && |
2744 | $fix) { | 3020 | $fix) { |
2745 | $fixed[$linenr - 1] =~ s/($Type\s*$Ident\s*(?:\s+$Modifier))*\s*=\s*(0|NULL|false)\s*;/$1;/; | 3021 | $fixed[$fixlinenr] =~ s/($Type\s*$Ident\s*(?:\s+$Modifier))*\s*=\s*(0|NULL|false)\s*;/$1;/; |
2746 | } | 3022 | } |
2747 | } | 3023 | } |
2748 | # check for static initialisers. | 3024 | # check for static initialisers. |
@@ -2751,10 +3027,17 @@ sub process { | |||
2751 | "do not initialise statics to 0 or NULL\n" . | 3027 | "do not initialise statics to 0 or NULL\n" . |
2752 | $herecurr) && | 3028 | $herecurr) && |
2753 | $fix) { | 3029 | $fix) { |
2754 | $fixed[$linenr - 1] =~ s/(\bstatic\s.*?)\s*=\s*(0|NULL|false)\s*;/$1;/; | 3030 | $fixed[$fixlinenr] =~ s/(\bstatic\s.*?)\s*=\s*(0|NULL|false)\s*;/$1;/; |
2755 | } | 3031 | } |
2756 | } | 3032 | } |
2757 | 3033 | ||
3034 | # check for misordered declarations of char/short/int/long with signed/unsigned | ||
3035 | while ($sline =~ m{(\b$TypeMisordered\b)}g) { | ||
3036 | my $tmp = trim($1); | ||
3037 | WARN("MISORDERED_TYPE", | ||
3038 | "type '$tmp' should be specified in [[un]signed] [short|int|long|long long] order\n" . $herecurr); | ||
3039 | } | ||
3040 | |||
2758 | # check for static const char * arrays. | 3041 | # check for static const char * arrays. |
2759 | if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { | 3042 | if ($line =~ /\bstatic\s+const\s+char\s*\*\s*(\w+)\s*\[\s*\]\s*=\s*/) { |
2760 | WARN("STATIC_CONST_CHAR_ARRAY", | 3043 | WARN("STATIC_CONST_CHAR_ARRAY", |
@@ -2781,7 +3064,7 @@ sub process { | |||
2781 | if (ERROR("FUNCTION_WITHOUT_ARGS", | 3064 | if (ERROR("FUNCTION_WITHOUT_ARGS", |
2782 | "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) && | 3065 | "Bad function definition - $1() should probably be $1(void)\n" . $herecurr) && |
2783 | $fix) { | 3066 | $fix) { |
2784 | $fixed[$linenr - 1] =~ s/(\b($Type)\s+($Ident))\s*\(\s*\)/$2 $3(void)/; | 3067 | $fixed[$fixlinenr] =~ s/(\b($Type)\s+($Ident))\s*\(\s*\)/$2 $3(void)/; |
2785 | } | 3068 | } |
2786 | } | 3069 | } |
2787 | 3070 | ||
@@ -2790,7 +3073,7 @@ sub process { | |||
2790 | if (WARN("DEFINE_PCI_DEVICE_TABLE", | 3073 | if (WARN("DEFINE_PCI_DEVICE_TABLE", |
2791 | "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) && | 3074 | "Prefer struct pci_device_id over deprecated DEFINE_PCI_DEVICE_TABLE\n" . $herecurr) && |
2792 | $fix) { | 3075 | $fix) { |
2793 | $fixed[$linenr - 1] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /; | 3076 | $fixed[$fixlinenr] =~ s/\b(?:static\s+|)DEFINE_PCI_DEVICE_TABLE\s*\(\s*(\w+)\s*\)\s*=\s*/static const struct pci_device_id $1\[\] = /; |
2794 | } | 3077 | } |
2795 | } | 3078 | } |
2796 | 3079 | ||
@@ -2827,7 +3110,7 @@ sub process { | |||
2827 | my $sub_from = $ident; | 3110 | my $sub_from = $ident; |
2828 | my $sub_to = $ident; | 3111 | my $sub_to = $ident; |
2829 | $sub_to =~ s/\Q$from\E/$to/; | 3112 | $sub_to =~ s/\Q$from\E/$to/; |
2830 | $fixed[$linenr - 1] =~ | 3113 | $fixed[$fixlinenr] =~ |
2831 | s@\Q$sub_from\E@$sub_to@; | 3114 | s@\Q$sub_from\E@$sub_to@; |
2832 | } | 3115 | } |
2833 | } | 3116 | } |
@@ -2855,7 +3138,7 @@ sub process { | |||
2855 | my $sub_from = $match; | 3138 | my $sub_from = $match; |
2856 | my $sub_to = $match; | 3139 | my $sub_to = $match; |
2857 | $sub_to =~ s/\Q$from\E/$to/; | 3140 | $sub_to =~ s/\Q$from\E/$to/; |
2858 | $fixed[$linenr - 1] =~ | 3141 | $fixed[$fixlinenr] =~ |
2859 | s@\Q$sub_from\E@$sub_to@; | 3142 | s@\Q$sub_from\E@$sub_to@; |
2860 | } | 3143 | } |
2861 | } | 3144 | } |
@@ -2917,7 +3200,7 @@ sub process { | |||
2917 | if (WARN("PREFER_PR_LEVEL", | 3200 | if (WARN("PREFER_PR_LEVEL", |
2918 | "Prefer pr_warn(... to pr_warning(...\n" . $herecurr) && | 3201 | "Prefer pr_warn(... to pr_warning(...\n" . $herecurr) && |
2919 | $fix) { | 3202 | $fix) { |
2920 | $fixed[$linenr - 1] =~ | 3203 | $fixed[$fixlinenr] =~ |
2921 | s/\bpr_warning\b/pr_warn/; | 3204 | s/\bpr_warning\b/pr_warn/; |
2922 | } | 3205 | } |
2923 | } | 3206 | } |
@@ -2933,17 +3216,40 @@ sub process { | |||
2933 | 3216 | ||
2934 | # function brace can't be on same line, except for #defines of do while, | 3217 | # function brace can't be on same line, except for #defines of do while, |
2935 | # or if closed on same line | 3218 | # or if closed on same line |
2936 | if (($line=~/$Type\s*$Ident\(.*\).*\s{/) and | 3219 | if (($line=~/$Type\s*$Ident\(.*\).*\s*{/) and |
2937 | !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) { | 3220 | !($line=~/\#\s*define.*do\s{/) and !($line=~/}/)) { |
2938 | ERROR("OPEN_BRACE", | 3221 | if (ERROR("OPEN_BRACE", |
2939 | "open brace '{' following function declarations go on the next line\n" . $herecurr); | 3222 | "open brace '{' following function declarations go on the next line\n" . $herecurr) && |
3223 | $fix) { | ||
3224 | fix_delete_line($fixlinenr, $rawline); | ||
3225 | my $fixed_line = $rawline; | ||
3226 | $fixed_line =~ /(^..*$Type\s*$Ident\(.*\)\s*){(.*)$/; | ||
3227 | my $line1 = $1; | ||
3228 | my $line2 = $2; | ||
3229 | fix_insert_line($fixlinenr, ltrim($line1)); | ||
3230 | fix_insert_line($fixlinenr, "\+{"); | ||
3231 | if ($line2 !~ /^\s*$/) { | ||
3232 | fix_insert_line($fixlinenr, "\+\t" . trim($line2)); | ||
3233 | } | ||
3234 | } | ||
2940 | } | 3235 | } |
2941 | 3236 | ||
2942 | # open braces for enum, union and struct go on the same line. | 3237 | # open braces for enum, union and struct go on the same line. |
2943 | if ($line =~ /^.\s*{/ && | 3238 | if ($line =~ /^.\s*{/ && |
2944 | $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) { | 3239 | $prevline =~ /^.\s*(?:typedef\s+)?(enum|union|struct)(?:\s+$Ident)?\s*$/) { |
2945 | ERROR("OPEN_BRACE", | 3240 | if (ERROR("OPEN_BRACE", |
2946 | "open brace '{' following $1 go on the same line\n" . $hereprev); | 3241 | "open brace '{' following $1 go on the same line\n" . $hereprev) && |
3242 | $fix && $prevline =~ /^\+/ && $line =~ /^\+/) { | ||
3243 | fix_delete_line($fixlinenr - 1, $prevrawline); | ||
3244 | fix_delete_line($fixlinenr, $rawline); | ||
3245 | my $fixedline = rtrim($prevrawline) . " {"; | ||
3246 | fix_insert_line($fixlinenr, $fixedline); | ||
3247 | $fixedline = $rawline; | ||
3248 | $fixedline =~ s/^(.\s*){\s*/$1\t/; | ||
3249 | if ($fixedline !~ /^\+\s*$/) { | ||
3250 | fix_insert_line($fixlinenr, $fixedline); | ||
3251 | } | ||
3252 | } | ||
2947 | } | 3253 | } |
2948 | 3254 | ||
2949 | # missing space after union, struct or enum definition | 3255 | # missing space after union, struct or enum definition |
@@ -2951,7 +3257,7 @@ sub process { | |||
2951 | if (WARN("SPACING", | 3257 | if (WARN("SPACING", |
2952 | "missing space after $1 definition\n" . $herecurr) && | 3258 | "missing space after $1 definition\n" . $herecurr) && |
2953 | $fix) { | 3259 | $fix) { |
2954 | $fixed[$linenr - 1] =~ | 3260 | $fixed[$fixlinenr] =~ |
2955 | s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/; | 3261 | s/^(.\s*(?:typedef\s+)?(?:enum|union|struct)(?:\s+$Ident){1,2})([=\{])/$1 $2/; |
2956 | } | 3262 | } |
2957 | } | 3263 | } |
@@ -3021,7 +3327,7 @@ sub process { | |||
3021 | } | 3327 | } |
3022 | 3328 | ||
3023 | if (show_type("SPACING") && $fix) { | 3329 | if (show_type("SPACING") && $fix) { |
3024 | $fixed[$linenr - 1] =~ | 3330 | $fixed[$fixlinenr] =~ |
3025 | s/^(.\s*)$Declare\s*\(\s*\*\s*$Ident\s*\)\s*\(/$1 . $declare . $post_declare_space . '(*' . $funcname . ')('/ex; | 3331 | s/^(.\s*)$Declare\s*\(\s*\*\s*$Ident\s*\)\s*\(/$1 . $declare . $post_declare_space . '(*' . $funcname . ')('/ex; |
3026 | } | 3332 | } |
3027 | } | 3333 | } |
@@ -3038,7 +3344,7 @@ sub process { | |||
3038 | if (ERROR("BRACKET_SPACE", | 3344 | if (ERROR("BRACKET_SPACE", |
3039 | "space prohibited before open square bracket '['\n" . $herecurr) && | 3345 | "space prohibited before open square bracket '['\n" . $herecurr) && |
3040 | $fix) { | 3346 | $fix) { |
3041 | $fixed[$linenr - 1] =~ | 3347 | $fixed[$fixlinenr] =~ |
3042 | s/^(\+.*?)\s+\[/$1\[/; | 3348 | s/^(\+.*?)\s+\[/$1\[/; |
3043 | } | 3349 | } |
3044 | } | 3350 | } |
@@ -3073,7 +3379,7 @@ sub process { | |||
3073 | if (WARN("SPACING", | 3379 | if (WARN("SPACING", |
3074 | "space prohibited between function name and open parenthesis '('\n" . $herecurr) && | 3380 | "space prohibited between function name and open parenthesis '('\n" . $herecurr) && |
3075 | $fix) { | 3381 | $fix) { |
3076 | $fixed[$linenr - 1] =~ | 3382 | $fixed[$fixlinenr] =~ |
3077 | s/\b$name\s+\(/$name\(/; | 3383 | s/\b$name\s+\(/$name\(/; |
3078 | } | 3384 | } |
3079 | } | 3385 | } |
@@ -3341,8 +3647,8 @@ sub process { | |||
3341 | $fixed_line = $fixed_line . $fix_elements[$#elements]; | 3647 | $fixed_line = $fixed_line . $fix_elements[$#elements]; |
3342 | } | 3648 | } |
3343 | 3649 | ||
3344 | if ($fix && $line_fixed && $fixed_line ne $fixed[$linenr - 1]) { | 3650 | if ($fix && $line_fixed && $fixed_line ne $fixed[$fixlinenr]) { |
3345 | $fixed[$linenr - 1] = $fixed_line; | 3651 | $fixed[$fixlinenr] = $fixed_line; |
3346 | } | 3652 | } |
3347 | 3653 | ||
3348 | 3654 | ||
@@ -3353,7 +3659,7 @@ sub process { | |||
3353 | if (WARN("SPACING", | 3659 | if (WARN("SPACING", |
3354 | "space prohibited before semicolon\n" . $herecurr) && | 3660 | "space prohibited before semicolon\n" . $herecurr) && |
3355 | $fix) { | 3661 | $fix) { |
3356 | 1 while $fixed[$linenr - 1] =~ | 3662 | 1 while $fixed[$fixlinenr] =~ |
3357 | s/^(\+.*\S)\s+;/$1;/; | 3663 | s/^(\+.*\S)\s+;/$1;/; |
3358 | } | 3664 | } |
3359 | } | 3665 | } |
@@ -3386,7 +3692,7 @@ sub process { | |||
3386 | if (ERROR("SPACING", | 3692 | if (ERROR("SPACING", |
3387 | "space required before the open brace '{'\n" . $herecurr) && | 3693 | "space required before the open brace '{'\n" . $herecurr) && |
3388 | $fix) { | 3694 | $fix) { |
3389 | $fixed[$linenr - 1] =~ s/^(\+.*(?:do|\))){/$1 {/; | 3695 | $fixed[$fixlinenr] =~ s/^(\+.*(?:do|\))){/$1 {/; |
3390 | } | 3696 | } |
3391 | } | 3697 | } |
3392 | 3698 | ||
@@ -3404,7 +3710,7 @@ sub process { | |||
3404 | if (ERROR("SPACING", | 3710 | if (ERROR("SPACING", |
3405 | "space required after that close brace '}'\n" . $herecurr) && | 3711 | "space required after that close brace '}'\n" . $herecurr) && |
3406 | $fix) { | 3712 | $fix) { |
3407 | $fixed[$linenr - 1] =~ | 3713 | $fixed[$fixlinenr] =~ |
3408 | s/}((?!(?:,|;|\)))\S)/} $1/; | 3714 | s/}((?!(?:,|;|\)))\S)/} $1/; |
3409 | } | 3715 | } |
3410 | } | 3716 | } |
@@ -3414,7 +3720,7 @@ sub process { | |||
3414 | if (ERROR("SPACING", | 3720 | if (ERROR("SPACING", |
3415 | "space prohibited after that open square bracket '['\n" . $herecurr) && | 3721 | "space prohibited after that open square bracket '['\n" . $herecurr) && |
3416 | $fix) { | 3722 | $fix) { |
3417 | $fixed[$linenr - 1] =~ | 3723 | $fixed[$fixlinenr] =~ |
3418 | s/\[\s+/\[/; | 3724 | s/\[\s+/\[/; |
3419 | } | 3725 | } |
3420 | } | 3726 | } |
@@ -3422,7 +3728,7 @@ sub process { | |||
3422 | if (ERROR("SPACING", | 3728 | if (ERROR("SPACING", |
3423 | "space prohibited before that close square bracket ']'\n" . $herecurr) && | 3729 | "space prohibited before that close square bracket ']'\n" . $herecurr) && |
3424 | $fix) { | 3730 | $fix) { |
3425 | $fixed[$linenr - 1] =~ | 3731 | $fixed[$fixlinenr] =~ |
3426 | s/\s+\]/\]/; | 3732 | s/\s+\]/\]/; |
3427 | } | 3733 | } |
3428 | } | 3734 | } |
@@ -3433,7 +3739,7 @@ sub process { | |||
3433 | if (ERROR("SPACING", | 3739 | if (ERROR("SPACING", |
3434 | "space prohibited after that open parenthesis '('\n" . $herecurr) && | 3740 | "space prohibited after that open parenthesis '('\n" . $herecurr) && |
3435 | $fix) { | 3741 | $fix) { |
3436 | $fixed[$linenr - 1] =~ | 3742 | $fixed[$fixlinenr] =~ |
3437 | s/\(\s+/\(/; | 3743 | s/\(\s+/\(/; |
3438 | } | 3744 | } |
3439 | } | 3745 | } |
@@ -3443,18 +3749,27 @@ sub process { | |||
3443 | if (ERROR("SPACING", | 3749 | if (ERROR("SPACING", |
3444 | "space prohibited before that close parenthesis ')'\n" . $herecurr) && | 3750 | "space prohibited before that close parenthesis ')'\n" . $herecurr) && |
3445 | $fix) { | 3751 | $fix) { |
3446 | $fixed[$linenr - 1] =~ | 3752 | print("fixlinenr: <$fixlinenr> fixed[fixlinenr]: <$fixed[$fixlinenr]>\n"); |
3753 | $fixed[$fixlinenr] =~ | ||
3447 | s/\s+\)/\)/; | 3754 | s/\s+\)/\)/; |
3448 | } | 3755 | } |
3449 | } | 3756 | } |
3450 | 3757 | ||
3758 | # check unnecessary parentheses around addressof/dereference single $Lvals | ||
3759 | # ie: &(foo->bar) should be &foo->bar and *(foo->bar) should be *foo->bar | ||
3760 | |||
3761 | while ($line =~ /(?:[^&]&\s*|\*)\(\s*($Ident\s*(?:$Member\s*)+)\s*\)/g) { | ||
3762 | CHK("UNNECESSARY_PARENTHESES", | ||
3763 | "Unnecessary parentheses around $1\n" . $herecurr); | ||
3764 | } | ||
3765 | |||
3451 | #goto labels aren't indented, allow a single space however | 3766 | #goto labels aren't indented, allow a single space however |
3452 | if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and | 3767 | if ($line=~/^.\s+[A-Za-z\d_]+:(?![0-9]+)/ and |
3453 | !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { | 3768 | !($line=~/^. [A-Za-z\d_]+:/) and !($line=~/^.\s+default:/)) { |
3454 | if (WARN("INDENTED_LABEL", | 3769 | if (WARN("INDENTED_LABEL", |
3455 | "labels should not be indented\n" . $herecurr) && | 3770 | "labels should not be indented\n" . $herecurr) && |
3456 | $fix) { | 3771 | $fix) { |
3457 | $fixed[$linenr - 1] =~ | 3772 | $fixed[$fixlinenr] =~ |
3458 | s/^(.)\s+/$1/; | 3773 | s/^(.)\s+/$1/; |
3459 | } | 3774 | } |
3460 | } | 3775 | } |
@@ -3516,7 +3831,7 @@ sub process { | |||
3516 | if (ERROR("SPACING", | 3831 | if (ERROR("SPACING", |
3517 | "space required before the open parenthesis '('\n" . $herecurr) && | 3832 | "space required before the open parenthesis '('\n" . $herecurr) && |
3518 | $fix) { | 3833 | $fix) { |
3519 | $fixed[$linenr - 1] =~ | 3834 | $fixed[$fixlinenr] =~ |
3520 | s/\b(if|while|for|switch)\(/$1 \(/; | 3835 | s/\b(if|while|for|switch)\(/$1 \(/; |
3521 | } | 3836 | } |
3522 | } | 3837 | } |
@@ -3606,7 +3921,7 @@ sub process { | |||
3606 | # if should not continue a brace | 3921 | # if should not continue a brace |
3607 | if ($line =~ /}\s*if\b/) { | 3922 | if ($line =~ /}\s*if\b/) { |
3608 | ERROR("TRAILING_STATEMENTS", | 3923 | ERROR("TRAILING_STATEMENTS", |
3609 | "trailing statements should be on next line\n" . | 3924 | "trailing statements should be on next line (or did you mean 'else if'?)\n" . |
3610 | $herecurr); | 3925 | $herecurr); |
3611 | } | 3926 | } |
3612 | # case and default should not have general statements after them | 3927 | # case and default should not have general statements after them |
@@ -3622,14 +3937,26 @@ sub process { | |||
3622 | 3937 | ||
3623 | # Check for }<nl>else {, these must be at the same | 3938 | # Check for }<nl>else {, these must be at the same |
3624 | # indent level to be relevant to each other. | 3939 | # indent level to be relevant to each other. |
3625 | if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ and | 3940 | if ($prevline=~/}\s*$/ and $line=~/^.\s*else\s*/ && |
3626 | $previndent == $indent) { | 3941 | $previndent == $indent) { |
3627 | ERROR("ELSE_AFTER_BRACE", | 3942 | if (ERROR("ELSE_AFTER_BRACE", |
3628 | "else should follow close brace '}'\n" . $hereprev); | 3943 | "else should follow close brace '}'\n" . $hereprev) && |
3944 | $fix && $prevline =~ /^\+/ && $line =~ /^\+/) { | ||
3945 | fix_delete_line($fixlinenr - 1, $prevrawline); | ||
3946 | fix_delete_line($fixlinenr, $rawline); | ||
3947 | my $fixedline = $prevrawline; | ||
3948 | $fixedline =~ s/}\s*$//; | ||
3949 | if ($fixedline !~ /^\+\s*$/) { | ||
3950 | fix_insert_line($fixlinenr, $fixedline); | ||
3951 | } | ||
3952 | $fixedline = $rawline; | ||
3953 | $fixedline =~ s/^(.\s*)else/$1} else/; | ||
3954 | fix_insert_line($fixlinenr, $fixedline); | ||
3955 | } | ||
3629 | } | 3956 | } |
3630 | 3957 | ||
3631 | if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ and | 3958 | if ($prevline=~/}\s*$/ and $line=~/^.\s*while\s*/ && |
3632 | $previndent == $indent) { | 3959 | $previndent == $indent) { |
3633 | my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); | 3960 | my ($s, $c) = ctx_statement_block($linenr, $realcnt, 0); |
3634 | 3961 | ||
3635 | # Find out what is on the end of the line after the | 3962 | # Find out what is on the end of the line after the |
@@ -3638,8 +3965,18 @@ sub process { | |||
3638 | $s =~ s/\n.*//g; | 3965 | $s =~ s/\n.*//g; |
3639 | 3966 | ||
3640 | if ($s =~ /^\s*;/) { | 3967 | if ($s =~ /^\s*;/) { |
3641 | ERROR("WHILE_AFTER_BRACE", | 3968 | if (ERROR("WHILE_AFTER_BRACE", |
3642 | "while should follow close brace '}'\n" . $hereprev); | 3969 | "while should follow close brace '}'\n" . $hereprev) && |
3970 | $fix && $prevline =~ /^\+/ && $line =~ /^\+/) { | ||
3971 | fix_delete_line($fixlinenr - 1, $prevrawline); | ||
3972 | fix_delete_line($fixlinenr, $rawline); | ||
3973 | my $fixedline = $prevrawline; | ||
3974 | my $trailing = $rawline; | ||
3975 | $trailing =~ s/^\+//; | ||
3976 | $trailing = trim($trailing); | ||
3977 | $fixedline =~ s/}\s*$/} $trailing/; | ||
3978 | fix_insert_line($fixlinenr, $fixedline); | ||
3979 | } | ||
3643 | } | 3980 | } |
3644 | } | 3981 | } |
3645 | 3982 | ||
@@ -3653,7 +3990,7 @@ sub process { | |||
3653 | "Avoid gcc v4.3+ binary constant extension: <$var>\n" . $herecurr) && | 3990 | "Avoid gcc v4.3+ binary constant extension: <$var>\n" . $herecurr) && |
3654 | $fix) { | 3991 | $fix) { |
3655 | my $hexval = sprintf("0x%x", oct($var)); | 3992 | my $hexval = sprintf("0x%x", oct($var)); |
3656 | $fixed[$linenr - 1] =~ | 3993 | $fixed[$fixlinenr] =~ |
3657 | s/\b$var\b/$hexval/; | 3994 | s/\b$var\b/$hexval/; |
3658 | } | 3995 | } |
3659 | } | 3996 | } |
@@ -3689,7 +4026,7 @@ sub process { | |||
3689 | if (WARN("WHITESPACE_AFTER_LINE_CONTINUATION", | 4026 | if (WARN("WHITESPACE_AFTER_LINE_CONTINUATION", |
3690 | "Whitespace after \\ makes next lines useless\n" . $herecurr) && | 4027 | "Whitespace after \\ makes next lines useless\n" . $herecurr) && |
3691 | $fix) { | 4028 | $fix) { |
3692 | $fixed[$linenr - 1] =~ s/\s+$//; | 4029 | $fixed[$fixlinenr] =~ s/\s+$//; |
3693 | } | 4030 | } |
3694 | } | 4031 | } |
3695 | 4032 | ||
@@ -3762,7 +4099,7 @@ sub process { | |||
3762 | $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), | 4099 | $dstat !~ /^(?:$Ident|-?$Constant),$/ && # 10, // foo(), |
3763 | $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo(); | 4100 | $dstat !~ /^(?:$Ident|-?$Constant);$/ && # foo(); |
3764 | $dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo // foo->bar // foo.bar->baz | 4101 | $dstat !~ /^[!~-]?(?:$Lval|$Constant)$/ && # 10 // foo() // !foo // ~foo // -foo // foo->bar // foo.bar->baz |
3765 | $dstat !~ /^'X'$/ && # character constants | 4102 | $dstat !~ /^'X'$/ && $dstat !~ /^'XX'$/ && # character constants |
3766 | $dstat !~ /$exceptions/ && | 4103 | $dstat !~ /$exceptions/ && |
3767 | $dstat !~ /^\.$Ident\s*=/ && # .foo = | 4104 | $dstat !~ /^\.$Ident\s*=/ && # .foo = |
3768 | $dstat !~ /^(?:\#\s*$Ident|\#\s*$Constant)\s*$/ && # stringification #foo | 4105 | $dstat !~ /^(?:\#\s*$Ident|\#\s*$Constant)\s*$/ && # stringification #foo |
@@ -4014,6 +4351,23 @@ sub process { | |||
4014 | } | 4351 | } |
4015 | } | 4352 | } |
4016 | 4353 | ||
4354 | # check for unnecessary "Out of Memory" messages | ||
4355 | if ($line =~ /^\+.*\b$logFunctions\s*\(/ && | ||
4356 | $prevline =~ /^[ \+]\s*if\s*\(\s*(\!\s*|NULL\s*==\s*)?($Lval)(\s*==\s*NULL\s*)?\s*\)/ && | ||
4357 | (defined $1 || defined $3) && | ||
4358 | $linenr > 3) { | ||
4359 | my $testval = $2; | ||
4360 | my $testline = $lines[$linenr - 3]; | ||
4361 | |||
4362 | my ($s, $c) = ctx_statement_block($linenr - 3, $realcnt, 0); | ||
4363 | # print("line: <$line>\nprevline: <$prevline>\ns: <$s>\nc: <$c>\n\n\n"); | ||
4364 | |||
4365 | if ($c =~ /(?:^|\n)[ \+]\s*(?:$Type\s*)?\Q$testval\E\s*=\s*(?:\([^\)]*\)\s*)?\s*(?:devm_)?(?:[kv][czm]alloc(?:_node|_array)?\b|kstrdup|(?:dev_)?alloc_skb)/) { | ||
4366 | WARN("OOM_MESSAGE", | ||
4367 | "Possible unnecessary 'out of memory' message\n" . $hereprev); | ||
4368 | } | ||
4369 | } | ||
4370 | |||
4017 | # check for bad placement of section $InitAttribute (e.g.: __initdata) | 4371 | # check for bad placement of section $InitAttribute (e.g.: __initdata) |
4018 | if ($line =~ /(\b$InitAttribute\b)/) { | 4372 | if ($line =~ /(\b$InitAttribute\b)/) { |
4019 | my $attr = $1; | 4373 | my $attr = $1; |
@@ -4027,7 +4381,7 @@ sub process { | |||
4027 | WARN("MISPLACED_INIT", | 4381 | WARN("MISPLACED_INIT", |
4028 | "$attr should be placed after $var\n" . $herecurr))) && | 4382 | "$attr should be placed after $var\n" . $herecurr))) && |
4029 | $fix) { | 4383 | $fix) { |
4030 | $fixed[$linenr - 1] =~ s/(\bstatic\s+(?:const\s+)?)(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*([=;])\s*/"$1" . trim(string_find_replace($2, "\\s*$attr\\s*", " ")) . " " . trim(string_find_replace($3, "\\s*$attr\\s*", "")) . " $attr" . ("$4" eq ";" ? ";" : " = ")/e; | 4384 | $fixed[$fixlinenr] =~ s/(\bstatic\s+(?:const\s+)?)(?:$attr\s+)?($NonptrTypeWithAttr)\s+(?:$attr\s+)?($Ident(?:\[[^]]*\])?)\s*([=;])\s*/"$1" . trim(string_find_replace($2, "\\s*$attr\\s*", " ")) . " " . trim(string_find_replace($3, "\\s*$attr\\s*", "")) . " $attr" . ("$4" eq ";" ? ";" : " = ")/e; |
4031 | } | 4385 | } |
4032 | } | 4386 | } |
4033 | } | 4387 | } |
@@ -4041,7 +4395,7 @@ sub process { | |||
4041 | if (ERROR("INIT_ATTRIBUTE", | 4395 | if (ERROR("INIT_ATTRIBUTE", |
4042 | "Use of const init definition must use ${attr_prefix}initconst\n" . $herecurr) && | 4396 | "Use of const init definition must use ${attr_prefix}initconst\n" . $herecurr) && |
4043 | $fix) { | 4397 | $fix) { |
4044 | $fixed[$linenr - 1] =~ | 4398 | $fixed[$fixlinenr] =~ |
4045 | s/$InitAttributeData/${attr_prefix}initconst/; | 4399 | s/$InitAttributeData/${attr_prefix}initconst/; |
4046 | } | 4400 | } |
4047 | } | 4401 | } |
@@ -4052,12 +4406,12 @@ sub process { | |||
4052 | if (ERROR("INIT_ATTRIBUTE", | 4406 | if (ERROR("INIT_ATTRIBUTE", |
4053 | "Use of $attr requires a separate use of const\n" . $herecurr) && | 4407 | "Use of $attr requires a separate use of const\n" . $herecurr) && |
4054 | $fix) { | 4408 | $fix) { |
4055 | my $lead = $fixed[$linenr - 1] =~ | 4409 | my $lead = $fixed[$fixlinenr] =~ |
4056 | /(^\+\s*(?:static\s+))/; | 4410 | /(^\+\s*(?:static\s+))/; |
4057 | $lead = rtrim($1); | 4411 | $lead = rtrim($1); |
4058 | $lead = "$lead " if ($lead !~ /^\+$/); | 4412 | $lead = "$lead " if ($lead !~ /^\+$/); |
4059 | $lead = "${lead}const "; | 4413 | $lead = "${lead}const "; |
4060 | $fixed[$linenr - 1] =~ s/(^\+\s*(?:static\s+))/$lead/; | 4414 | $fixed[$fixlinenr] =~ s/(^\+\s*(?:static\s+))/$lead/; |
4061 | } | 4415 | } |
4062 | } | 4416 | } |
4063 | 4417 | ||
@@ -4070,7 +4424,7 @@ sub process { | |||
4070 | if (WARN("CONSTANT_CONVERSION", | 4424 | if (WARN("CONSTANT_CONVERSION", |
4071 | "$constant_func should be $func\n" . $herecurr) && | 4425 | "$constant_func should be $func\n" . $herecurr) && |
4072 | $fix) { | 4426 | $fix) { |
4073 | $fixed[$linenr - 1] =~ s/\b$constant_func\b/$func/g; | 4427 | $fixed[$fixlinenr] =~ s/\b$constant_func\b/$func/g; |
4074 | } | 4428 | } |
4075 | } | 4429 | } |
4076 | 4430 | ||
@@ -4120,7 +4474,7 @@ sub process { | |||
4120 | if (ERROR("SPACING", | 4474 | if (ERROR("SPACING", |
4121 | "exactly one space required after that #$1\n" . $herecurr) && | 4475 | "exactly one space required after that #$1\n" . $herecurr) && |
4122 | $fix) { | 4476 | $fix) { |
4123 | $fixed[$linenr - 1] =~ | 4477 | $fixed[$fixlinenr] =~ |
4124 | s/^(.\s*\#\s*(ifdef|ifndef|elif))\s{2,}/$1 /; | 4478 | s/^(.\s*\#\s*(ifdef|ifndef|elif))\s{2,}/$1 /; |
4125 | } | 4479 | } |
4126 | 4480 | ||
@@ -4168,7 +4522,7 @@ sub process { | |||
4168 | if (WARN("INLINE", | 4522 | if (WARN("INLINE", |
4169 | "plain inline is preferred over $1\n" . $herecurr) && | 4523 | "plain inline is preferred over $1\n" . $herecurr) && |
4170 | $fix) { | 4524 | $fix) { |
4171 | $fixed[$linenr - 1] =~ s/\b(__inline__|__inline)\b/inline/; | 4525 | $fixed[$fixlinenr] =~ s/\b(__inline__|__inline)\b/inline/; |
4172 | 4526 | ||
4173 | } | 4527 | } |
4174 | } | 4528 | } |
@@ -4193,7 +4547,7 @@ sub process { | |||
4193 | if (WARN("PREFER_PRINTF", | 4547 | if (WARN("PREFER_PRINTF", |
4194 | "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) && | 4548 | "__printf(string-index, first-to-check) is preferred over __attribute__((format(printf, string-index, first-to-check)))\n" . $herecurr) && |
4195 | $fix) { | 4549 | $fix) { |
4196 | $fixed[$linenr - 1] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.*)\)\s*\)\s*\)/"__printf(" . trim($1) . ")"/ex; | 4550 | $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.*)\)\s*\)\s*\)/"__printf(" . trim($1) . ")"/ex; |
4197 | 4551 | ||
4198 | } | 4552 | } |
4199 | } | 4553 | } |
@@ -4204,7 +4558,7 @@ sub process { | |||
4204 | if (WARN("PREFER_SCANF", | 4558 | if (WARN("PREFER_SCANF", |
4205 | "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) && | 4559 | "__scanf(string-index, first-to-check) is preferred over __attribute__((format(scanf, string-index, first-to-check)))\n" . $herecurr) && |
4206 | $fix) { | 4560 | $fix) { |
4207 | $fixed[$linenr - 1] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\s*,\s*(.*)\)\s*\)\s*\)/"__scanf(" . trim($1) . ")"/ex; | 4561 | $fixed[$fixlinenr] =~ s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*scanf\s*,\s*(.*)\)\s*\)\s*\)/"__scanf(" . trim($1) . ")"/ex; |
4208 | } | 4562 | } |
4209 | } | 4563 | } |
4210 | 4564 | ||
@@ -4219,7 +4573,7 @@ sub process { | |||
4219 | if (WARN("SIZEOF_PARENTHESIS", | 4573 | if (WARN("SIZEOF_PARENTHESIS", |
4220 | "sizeof $1 should be sizeof($1)\n" . $herecurr) && | 4574 | "sizeof $1 should be sizeof($1)\n" . $herecurr) && |
4221 | $fix) { | 4575 | $fix) { |
4222 | $fixed[$linenr - 1] =~ s/\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/"sizeof(" . trim($1) . ")"/ex; | 4576 | $fixed[$fixlinenr] =~ s/\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/"sizeof(" . trim($1) . ")"/ex; |
4223 | } | 4577 | } |
4224 | } | 4578 | } |
4225 | 4579 | ||
@@ -4242,7 +4596,7 @@ sub process { | |||
4242 | if (WARN("PREFER_SEQ_PUTS", | 4596 | if (WARN("PREFER_SEQ_PUTS", |
4243 | "Prefer seq_puts to seq_printf\n" . $herecurr) && | 4597 | "Prefer seq_puts to seq_printf\n" . $herecurr) && |
4244 | $fix) { | 4598 | $fix) { |
4245 | $fixed[$linenr - 1] =~ s/\bseq_printf\b/seq_puts/; | 4599 | $fixed[$fixlinenr] =~ s/\bseq_printf\b/seq_puts/; |
4246 | } | 4600 | } |
4247 | } | 4601 | } |
4248 | } | 4602 | } |
@@ -4271,7 +4625,7 @@ sub process { | |||
4271 | if (WARN("PREFER_ETHER_ADDR_COPY", | 4625 | if (WARN("PREFER_ETHER_ADDR_COPY", |
4272 | "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . $herecurr) && | 4626 | "Prefer ether_addr_copy() over memcpy() if the Ethernet addresses are __aligned(2)\n" . $herecurr) && |
4273 | $fix) { | 4627 | $fix) { |
4274 | $fixed[$linenr - 1] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/; | 4628 | $fixed[$fixlinenr] =~ s/\bmemcpy\s*\(\s*$FuncArg\s*,\s*$FuncArg\s*\,\s*ETH_ALEN\s*\)/ether_addr_copy($2, $7)/; |
4275 | } | 4629 | } |
4276 | } | 4630 | } |
4277 | 4631 | ||
@@ -4359,7 +4713,7 @@ sub process { | |||
4359 | if (CHK("AVOID_EXTERNS", | 4713 | if (CHK("AVOID_EXTERNS", |
4360 | "extern prototypes should be avoided in .h files\n" . $herecurr) && | 4714 | "extern prototypes should be avoided in .h files\n" . $herecurr) && |
4361 | $fix) { | 4715 | $fix) { |
4362 | $fixed[$linenr - 1] =~ s/(.*)\bextern\b\s*(.*)/$1$2/; | 4716 | $fixed[$fixlinenr] =~ s/(.*)\bextern\b\s*(.*)/$1$2/; |
4363 | } | 4717 | } |
4364 | } | 4718 | } |
4365 | 4719 | ||
@@ -4419,23 +4773,24 @@ sub process { | |||
4419 | 4773 | ||
4420 | # check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc | 4774 | # check for k[mz]alloc with multiplies that could be kmalloc_array/kcalloc |
4421 | if ($^V && $^V ge 5.10.0 && | 4775 | if ($^V && $^V ge 5.10.0 && |
4422 | $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/) { | 4776 | $line =~ /\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)\s*,/) { |
4423 | my $oldfunc = $3; | 4777 | my $oldfunc = $3; |
4424 | my $a1 = $4; | 4778 | my $a1 = $4; |
4425 | my $a2 = $10; | 4779 | my $a2 = $10; |
4426 | my $newfunc = "kmalloc_array"; | 4780 | my $newfunc = "kmalloc_array"; |
4427 | $newfunc = "kcalloc" if ($oldfunc eq "kzalloc"); | 4781 | $newfunc = "kcalloc" if ($oldfunc eq "kzalloc"); |
4428 | if ($a1 =~ /^sizeof\s*\S/ || $a2 =~ /^sizeof\s*\S/) { | 4782 | my $r1 = $a1; |
4783 | my $r2 = $a2; | ||
4784 | if ($a1 =~ /^sizeof\s*\S/) { | ||
4785 | $r1 = $a2; | ||
4786 | $r2 = $a1; | ||
4787 | } | ||
4788 | if ($r1 !~ /^sizeof\b/ && $r2 =~ /^sizeof\s*\S/ && | ||
4789 | !($r1 =~ /^$Constant$/ || $r1 =~ /^[A-Z_][A-Z0-9_]*$/)) { | ||
4429 | if (WARN("ALLOC_WITH_MULTIPLY", | 4790 | if (WARN("ALLOC_WITH_MULTIPLY", |
4430 | "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) && | 4791 | "Prefer $newfunc over $oldfunc with multiply\n" . $herecurr) && |
4431 | $fix) { | 4792 | $fix) { |
4432 | my $r1 = $a1; | 4793 | $fixed[$fixlinenr] =~ s/\b($Lval)\s*\=\s*(?:$balanced_parens)?\s*(k[mz]alloc)\s*\(\s*($FuncArg)\s*\*\s*($FuncArg)/$1 . ' = ' . "$newfunc(" . trim($r1) . ', ' . trim($r2)/e; |
4433 | my $r2 = $a2; | ||
4434 | if ($a1 =~ /^sizeof\s*\S/) { | ||
4435 | $r1 = $a2; | ||
4436 | $r2 = $a1; | ||
4437 | } | ||
4438 | $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; | ||
4439 | 4794 | ||
4440 | } | 4795 | } |
4441 | } | 4796 | } |
@@ -4459,17 +4814,17 @@ sub process { | |||
4459 | if (WARN("ONE_SEMICOLON", | 4814 | if (WARN("ONE_SEMICOLON", |
4460 | "Statements terminations use 1 semicolon\n" . $herecurr) && | 4815 | "Statements terminations use 1 semicolon\n" . $herecurr) && |
4461 | $fix) { | 4816 | $fix) { |
4462 | $fixed[$linenr - 1] =~ s/(\s*;\s*){2,}$/;/g; | 4817 | $fixed[$fixlinenr] =~ s/(\s*;\s*){2,}$/;/g; |
4463 | } | 4818 | } |
4464 | } | 4819 | } |
4465 | 4820 | ||
4466 | # check for case / default statements not preceeded by break/fallthrough/switch | 4821 | # check for case / default statements not preceded by break/fallthrough/switch |
4467 | if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { | 4822 | if ($line =~ /^.\s*(?:case\s+(?:$Ident|$Constant)\s*|default):/) { |
4468 | my $has_break = 0; | 4823 | my $has_break = 0; |
4469 | my $has_statement = 0; | 4824 | my $has_statement = 0; |
4470 | my $count = 0; | 4825 | my $count = 0; |
4471 | my $prevline = $linenr; | 4826 | my $prevline = $linenr; |
4472 | while ($prevline > 1 && $count < 3 && !$has_break) { | 4827 | while ($prevline > 1 && ($file || $count < 3) && !$has_break) { |
4473 | $prevline--; | 4828 | $prevline--; |
4474 | my $rline = $rawlines[$prevline - 1]; | 4829 | my $rline = $rawlines[$prevline - 1]; |
4475 | my $fline = $lines[$prevline - 1]; | 4830 | my $fline = $lines[$prevline - 1]; |
@@ -4507,7 +4862,7 @@ sub process { | |||
4507 | if (WARN("USE_FUNC", | 4862 | if (WARN("USE_FUNC", |
4508 | "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr) && | 4863 | "__func__ should be used instead of gcc specific __FUNCTION__\n" . $herecurr) && |
4509 | $fix) { | 4864 | $fix) { |
4510 | $fixed[$linenr - 1] =~ s/\b__FUNCTION__\b/__func__/g; | 4865 | $fixed[$fixlinenr] =~ s/\b__FUNCTION__\b/__func__/g; |
4511 | } | 4866 | } |
4512 | } | 4867 | } |
4513 | 4868 | ||
@@ -4750,12 +5105,16 @@ sub process { | |||
4750 | hash_show_words(\%use_type, "Used"); | 5105 | hash_show_words(\%use_type, "Used"); |
4751 | hash_show_words(\%ignore_type, "Ignored"); | 5106 | hash_show_words(\%ignore_type, "Ignored"); |
4752 | 5107 | ||
4753 | if ($clean == 0 && $fix && "@rawlines" ne "@fixed") { | 5108 | if ($clean == 0 && $fix && |
5109 | ("@rawlines" ne "@fixed" || | ||
5110 | $#fixed_inserted >= 0 || $#fixed_deleted >= 0)) { | ||
4754 | my $newfile = $filename; | 5111 | my $newfile = $filename; |
4755 | $newfile .= ".EXPERIMENTAL-checkpatch-fixes" if (!$fix_inplace); | 5112 | $newfile .= ".EXPERIMENTAL-checkpatch-fixes" if (!$fix_inplace); |
4756 | my $linecount = 0; | 5113 | my $linecount = 0; |
4757 | my $f; | 5114 | my $f; |
4758 | 5115 | ||
5116 | @fixed = fix_inserted_deleted_lines(\@fixed, \@fixed_inserted, \@fixed_deleted); | ||
5117 | |||
4759 | open($f, '>', $newfile) | 5118 | open($f, '>', $newfile) |
4760 | or die "$P: Can't open $newfile for write\n"; | 5119 | or die "$P: Can't open $newfile for write\n"; |
4761 | foreach my $fixed_line (@fixed) { | 5120 | foreach my $fixed_line (@fixed) { |
@@ -4763,7 +5122,7 @@ sub process { | |||
4763 | if ($file) { | 5122 | if ($file) { |
4764 | if ($linecount > 3) { | 5123 | if ($linecount > 3) { |
4765 | $fixed_line =~ s/^\+//; | 5124 | $fixed_line =~ s/^\+//; |
4766 | print $f $fixed_line. "\n"; | 5125 | print $f $fixed_line . "\n"; |
4767 | } | 5126 | } |
4768 | } else { | 5127 | } else { |
4769 | print $f $fixed_line . "\n"; | 5128 | print $f $fixed_line . "\n"; |
diff --git a/scripts/checkstack.pl b/scripts/checkstack.pl index c05d586b1fee..899b4230320e 100755 --- a/scripts/checkstack.pl +++ b/scripts/checkstack.pl | |||
@@ -52,14 +52,12 @@ my (@stack, $re, $dre, $x, $xs, $funcre); | |||
52 | #8000008a: 20 1d sub sp,4 | 52 | #8000008a: 20 1d sub sp,4 |
53 | #80000ca8: fa cd 05 b0 sub sp,sp,1456 | 53 | #80000ca8: fa cd 05 b0 sub sp,sp,1456 |
54 | $re = qr/^.*sub.*sp.*,([0-9]{1,8})/o; | 54 | $re = qr/^.*sub.*sp.*,([0-9]{1,8})/o; |
55 | } elsif ($arch =~ /^i[3456]86$/) { | 55 | } elsif ($arch =~ /^x86(_64)?$/ || $arch =~ /^i[3456]86$/) { |
56 | #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp | 56 | #c0105234: 81 ec ac 05 00 00 sub $0x5ac,%esp |
57 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%esp$/o; | 57 | # or |
58 | $dre = qr/^.*[as][du][db] (%.*),\%esp$/o; | 58 | # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp |
59 | } elsif ($arch eq 'x86_64') { | 59 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%(e|r)sp$/o; |
60 | # 2f60: 48 81 ec e8 05 00 00 sub $0x5e8,%rsp | 60 | $dre = qr/^.*[as][du][db] (%.*),\%(e|r)sp$/o; |
61 | $re = qr/^.*[as][du][db] \$(0x$x{1,8}),\%rsp$/o; | ||
62 | $dre = qr/^.*[as][du][db] (\%.*),\%rsp$/o; | ||
63 | } elsif ($arch eq 'ia64') { | 61 | } elsif ($arch eq 'ia64') { |
64 | #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12 | 62 | #e0000000044011fc: 01 0f fc 8c adds r12=-384,r12 |
65 | $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o; | 63 | $re = qr/.*adds.*r12=-(([0-9]{2}|[3-9])[0-9]{2}),r12/o; |
diff --git a/scripts/coccinelle/api/devm_ioremap_resource.cocci b/scripts/coccinelle/api/devm_ioremap_resource.cocci deleted file mode 100644 index 495daa3dbf77..000000000000 --- a/scripts/coccinelle/api/devm_ioremap_resource.cocci +++ /dev/null | |||
@@ -1,90 +0,0 @@ | |||
1 | virtual patch | ||
2 | virtual report | ||
3 | |||
4 | @depends on patch@ | ||
5 | expression base, dev, res; | ||
6 | @@ | ||
7 | |||
8 | -base = devm_request_and_ioremap(dev, res); | ||
9 | +base = devm_ioremap_resource(dev, res); | ||
10 | ... | ||
11 | if ( | ||
12 | -base == NULL | ||
13 | +IS_ERR(base) | ||
14 | || ...) { | ||
15 | <... | ||
16 | - return ...; | ||
17 | + return PTR_ERR(base); | ||
18 | ...> | ||
19 | } | ||
20 | |||
21 | @depends on patch@ | ||
22 | expression e, E, ret; | ||
23 | identifier l; | ||
24 | @@ | ||
25 | |||
26 | e = devm_ioremap_resource(...); | ||
27 | ... | ||
28 | if (IS_ERR(e) || ...) { | ||
29 | ... when any | ||
30 | - ret = E; | ||
31 | + ret = PTR_ERR(e); | ||
32 | ... | ||
33 | ( | ||
34 | return ret; | ||
35 | | | ||
36 | goto l; | ||
37 | ) | ||
38 | } | ||
39 | |||
40 | @depends on patch@ | ||
41 | expression e; | ||
42 | @@ | ||
43 | |||
44 | e = devm_ioremap_resource(...); | ||
45 | ... | ||
46 | if (IS_ERR(e) || ...) { | ||
47 | ... | ||
48 | - \(dev_dbg\|dev_err\|pr_debug\|pr_err\|DRM_ERROR\)(...); | ||
49 | ... | ||
50 | } | ||
51 | |||
52 | @depends on patch@ | ||
53 | expression e; | ||
54 | identifier l; | ||
55 | @@ | ||
56 | |||
57 | e = devm_ioremap_resource(...); | ||
58 | ... | ||
59 | if (IS_ERR(e) || ...) | ||
60 | -{ | ||
61 | ( | ||
62 | return ...; | ||
63 | | | ||
64 | goto l; | ||
65 | ) | ||
66 | -} | ||
67 | |||
68 | @r depends on report@ | ||
69 | expression e; | ||
70 | identifier l; | ||
71 | position p1; | ||
72 | @@ | ||
73 | |||
74 | *e = devm_request_and_ioremap@p1(...); | ||
75 | ... | ||
76 | if (e == NULL || ...) { | ||
77 | ... | ||
78 | ( | ||
79 | return ...; | ||
80 | | | ||
81 | goto l; | ||
82 | ) | ||
83 | } | ||
84 | |||
85 | @script:python depends on r@ | ||
86 | p1 << r.p1; | ||
87 | @@ | ||
88 | |||
89 | msg = "ERROR: deprecated devm_request_and_ioremap() API used on line %s" % (p1[0].line) | ||
90 | coccilib.report.print_report(p1[0], msg) | ||
diff --git a/scripts/coccinelle/free/ifnullfree.cocci b/scripts/coccinelle/free/ifnullfree.cocci new file mode 100644 index 000000000000..a42d70bf88b3 --- /dev/null +++ b/scripts/coccinelle/free/ifnullfree.cocci | |||
@@ -0,0 +1,53 @@ | |||
1 | /// NULL check before some freeing functions is not needed. | ||
2 | /// | ||
3 | /// Based on checkpatch warning | ||
4 | /// "kfree(NULL) is safe this check is probably not required" | ||
5 | /// and kfreeaddr.cocci by Julia Lawall. | ||
6 | /// | ||
7 | // Copyright: (C) 2014 Fabian Frederick. GPLv2. | ||
8 | // Comments: - | ||
9 | // Options: --no-includes --include-headers | ||
10 | |||
11 | virtual patch | ||
12 | virtual org | ||
13 | virtual report | ||
14 | virtual context | ||
15 | |||
16 | @r2 depends on patch@ | ||
17 | expression E; | ||
18 | @@ | ||
19 | - if (E) | ||
20 | ( | ||
21 | - kfree(E); | ||
22 | + kfree(E); | ||
23 | | | ||
24 | - debugfs_remove(E); | ||
25 | + debugfs_remove(E); | ||
26 | | | ||
27 | - debugfs_remove_recursive(E); | ||
28 | + debugfs_remove_recursive(E); | ||
29 | | | ||
30 | - usb_free_urb(E); | ||
31 | + usb_free_urb(E); | ||
32 | ) | ||
33 | |||
34 | @r depends on context || report || org @ | ||
35 | expression E; | ||
36 | position p; | ||
37 | @@ | ||
38 | |||
39 | * if (E) | ||
40 | * \(kfree@p\|debugfs_remove@p\|debugfs_remove_recursive@p\|usb_free_urb\)(E); | ||
41 | |||
42 | @script:python depends on org@ | ||
43 | p << r.p; | ||
44 | @@ | ||
45 | |||
46 | cocci.print_main("NULL check before that freeing function is not needed", p) | ||
47 | |||
48 | @script:python depends on report@ | ||
49 | p << r.p; | ||
50 | @@ | ||
51 | |||
52 | msg = "WARNING: NULL check before freeing functions like kfree, debugfs_remove, debugfs_remove_recursive or usb_free_urb is not needed. Maybe consider reorganizing relevant code to avoid passing NULL values." | ||
53 | coccilib.report.print_report(p[0], msg) | ||
diff --git a/scripts/get_maintainer.pl b/scripts/get_maintainer.pl index 41987885bd31..d7016279ec2b 100755 --- a/scripts/get_maintainer.pl +++ b/scripts/get_maintainer.pl | |||
@@ -21,6 +21,7 @@ my $lk_path = "./"; | |||
21 | my $email = 1; | 21 | my $email = 1; |
22 | my $email_usename = 1; | 22 | my $email_usename = 1; |
23 | my $email_maintainer = 1; | 23 | my $email_maintainer = 1; |
24 | my $email_reviewer = 1; | ||
24 | my $email_list = 1; | 25 | my $email_list = 1; |
25 | my $email_subscriber_list = 0; | 26 | my $email_subscriber_list = 0; |
26 | my $email_git_penguin_chiefs = 0; | 27 | my $email_git_penguin_chiefs = 0; |
@@ -202,6 +203,7 @@ if (!GetOptions( | |||
202 | 'remove-duplicates!' => \$email_remove_duplicates, | 203 | 'remove-duplicates!' => \$email_remove_duplicates, |
203 | 'mailmap!' => \$email_use_mailmap, | 204 | 'mailmap!' => \$email_use_mailmap, |
204 | 'm!' => \$email_maintainer, | 205 | 'm!' => \$email_maintainer, |
206 | 'r!' => \$email_reviewer, | ||
205 | 'n!' => \$email_usename, | 207 | 'n!' => \$email_usename, |
206 | 'l!' => \$email_list, | 208 | 'l!' => \$email_list, |
207 | 's!' => \$email_subscriber_list, | 209 | 's!' => \$email_subscriber_list, |
@@ -260,7 +262,8 @@ if ($sections) { | |||
260 | } | 262 | } |
261 | 263 | ||
262 | if ($email && | 264 | if ($email && |
263 | ($email_maintainer + $email_list + $email_subscriber_list + | 265 | ($email_maintainer + $email_reviewer + |
266 | $email_list + $email_subscriber_list + | ||
264 | $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { | 267 | $email_git + $email_git_penguin_chiefs + $email_git_blame) == 0) { |
265 | die "$P: Please select at least 1 email option\n"; | 268 | die "$P: Please select at least 1 email option\n"; |
266 | } | 269 | } |
@@ -750,6 +753,7 @@ MAINTAINER field selection options: | |||
750 | --hg-since => hg history to use (default: $email_hg_since) | 753 | --hg-since => hg history to use (default: $email_hg_since) |
751 | --interactive => display a menu (mostly useful if used with the --git option) | 754 | --interactive => display a menu (mostly useful if used with the --git option) |
752 | --m => include maintainer(s) if any | 755 | --m => include maintainer(s) if any |
756 | --r => include reviewer(s) if any | ||
753 | --n => include name 'Full Name <addr\@domain.tld>' | 757 | --n => include name 'Full Name <addr\@domain.tld>' |
754 | --l => include list(s) if any | 758 | --l => include list(s) if any |
755 | --s => include subscriber only list(s) if any | 759 | --s => include subscriber only list(s) if any |
@@ -1064,6 +1068,22 @@ sub add_categories { | |||
1064 | my $role = get_maintainer_role($i); | 1068 | my $role = get_maintainer_role($i); |
1065 | push_email_addresses($pvalue, $role); | 1069 | push_email_addresses($pvalue, $role); |
1066 | } | 1070 | } |
1071 | } elsif ($ptype eq "R") { | ||
1072 | my ($name, $address) = parse_email($pvalue); | ||
1073 | if ($name eq "") { | ||
1074 | if ($i > 0) { | ||
1075 | my $tv = $typevalue[$i - 1]; | ||
1076 | if ($tv =~ m/^(\C):\s*(.*)/) { | ||
1077 | if ($1 eq "P") { | ||
1078 | $name = $2; | ||
1079 | $pvalue = format_email($name, $address, $email_usename); | ||
1080 | } | ||
1081 | } | ||
1082 | } | ||
1083 | } | ||
1084 | if ($email_reviewer) { | ||
1085 | push_email_addresses($pvalue, 'reviewer'); | ||
1086 | } | ||
1067 | } elsif ($ptype eq "T") { | 1087 | } elsif ($ptype eq "T") { |
1068 | push(@scm, $pvalue); | 1088 | push(@scm, $pvalue); |
1069 | } elsif ($ptype eq "W") { | 1089 | } elsif ($ptype eq "W") { |
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c index 9d9c5b905b35..091d90573b63 100644 --- a/scripts/mod/modpost.c +++ b/scripts/mod/modpost.c | |||
@@ -772,32 +772,10 @@ static const char *sech_name(struct elf_info *elf, Elf_Shdr *sechdr) | |||
772 | sechdr->sh_name; | 772 | sechdr->sh_name; |
773 | } | 773 | } |
774 | 774 | ||
775 | /* if sym is empty or point to a string | ||
776 | * like ".[0-9]+" then return 1. | ||
777 | * This is the optional prefix added by ld to some sections | ||
778 | */ | ||
779 | static int number_prefix(const char *sym) | ||
780 | { | ||
781 | if (*sym++ == '\0') | ||
782 | return 1; | ||
783 | if (*sym != '.') | ||
784 | return 0; | ||
785 | do { | ||
786 | char c = *sym++; | ||
787 | if (c < '0' || c > '9') | ||
788 | return 0; | ||
789 | } while (*sym); | ||
790 | return 1; | ||
791 | } | ||
792 | |||
793 | /* The pattern is an array of simple patterns. | 775 | /* The pattern is an array of simple patterns. |
794 | * "foo" will match an exact string equal to "foo" | 776 | * "foo" will match an exact string equal to "foo" |
795 | * "*foo" will match a string that ends with "foo" | 777 | * "*foo" will match a string that ends with "foo" |
796 | * "foo*" will match a string that begins with "foo" | 778 | * "foo*" will match a string that begins with "foo" |
797 | * "foo$" will match a string equal to "foo" or "foo.1" | ||
798 | * where the '1' can be any number including several digits. | ||
799 | * The $ syntax is for sections where ld append a dot number | ||
800 | * to make section name unique. | ||
801 | */ | 779 | */ |
802 | static int match(const char *sym, const char * const pat[]) | 780 | static int match(const char *sym, const char * const pat[]) |
803 | { | 781 | { |
@@ -816,13 +794,6 @@ static int match(const char *sym, const char * const pat[]) | |||
816 | if (strncmp(sym, p, strlen(p) - 1) == 0) | 794 | if (strncmp(sym, p, strlen(p) - 1) == 0) |
817 | return 1; | 795 | return 1; |
818 | } | 796 | } |
819 | /* "foo$" */ | ||
820 | else if (*endp == '$') { | ||
821 | if (strncmp(sym, p, strlen(p) - 1) == 0) { | ||
822 | if (number_prefix(sym + strlen(p) - 1)) | ||
823 | return 1; | ||
824 | } | ||
825 | } | ||
826 | /* no wildcards */ | 797 | /* no wildcards */ |
827 | else { | 798 | else { |
828 | if (strcmp(p, sym) == 0) | 799 | if (strcmp(p, sym) == 0) |
@@ -880,20 +851,20 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
880 | 851 | ||
881 | 852 | ||
882 | #define ALL_INIT_DATA_SECTIONS \ | 853 | #define ALL_INIT_DATA_SECTIONS \ |
883 | ".init.setup$", ".init.rodata$", ".meminit.rodata$", \ | 854 | ".init.setup", ".init.rodata", ".meminit.rodata", \ |
884 | ".init.data$", ".meminit.data$" | 855 | ".init.data", ".meminit.data" |
885 | #define ALL_EXIT_DATA_SECTIONS \ | 856 | #define ALL_EXIT_DATA_SECTIONS \ |
886 | ".exit.data$", ".memexit.data$" | 857 | ".exit.data", ".memexit.data" |
887 | 858 | ||
888 | #define ALL_INIT_TEXT_SECTIONS \ | 859 | #define ALL_INIT_TEXT_SECTIONS \ |
889 | ".init.text$", ".meminit.text$" | 860 | ".init.text", ".meminit.text" |
890 | #define ALL_EXIT_TEXT_SECTIONS \ | 861 | #define ALL_EXIT_TEXT_SECTIONS \ |
891 | ".exit.text$", ".memexit.text$" | 862 | ".exit.text", ".memexit.text" |
892 | 863 | ||
893 | #define ALL_PCI_INIT_SECTIONS \ | 864 | #define ALL_PCI_INIT_SECTIONS \ |
894 | ".pci_fixup_early$", ".pci_fixup_header$", ".pci_fixup_final$", \ | 865 | ".pci_fixup_early", ".pci_fixup_header", ".pci_fixup_final", \ |
895 | ".pci_fixup_enable$", ".pci_fixup_resume$", \ | 866 | ".pci_fixup_enable", ".pci_fixup_resume", \ |
896 | ".pci_fixup_resume_early$", ".pci_fixup_suspend$" | 867 | ".pci_fixup_resume_early", ".pci_fixup_suspend" |
897 | 868 | ||
898 | #define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS | 869 | #define ALL_XXXINIT_SECTIONS MEM_INIT_SECTIONS |
899 | #define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS | 870 | #define ALL_XXXEXIT_SECTIONS MEM_EXIT_SECTIONS |
@@ -901,8 +872,8 @@ static void check_section(const char *modname, struct elf_info *elf, | |||
901 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS | 872 | #define ALL_INIT_SECTIONS INIT_SECTIONS, ALL_XXXINIT_SECTIONS |
902 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS | 873 | #define ALL_EXIT_SECTIONS EXIT_SECTIONS, ALL_XXXEXIT_SECTIONS |
903 | 874 | ||
904 | #define DATA_SECTIONS ".data$", ".data.rel$" | 875 | #define DATA_SECTIONS ".data", ".data.rel" |
905 | #define TEXT_SECTIONS ".text$", ".text.unlikely$" | 876 | #define TEXT_SECTIONS ".text", ".text.unlikely" |
906 | 877 | ||
907 | #define INIT_SECTIONS ".init.*" | 878 | #define INIT_SECTIONS ".init.*" |
908 | #define MEM_INIT_SECTIONS ".meminit.*" | 879 | #define MEM_INIT_SECTIONS ".meminit.*" |
@@ -1703,12 +1674,11 @@ static void check_sec_ref(struct module *mod, const char *modname, | |||
1703 | 1674 | ||
1704 | static char *remove_dot(char *s) | 1675 | static char *remove_dot(char *s) |
1705 | { | 1676 | { |
1706 | char *end; | 1677 | size_t n = strcspn(s, "."); |
1707 | int n = strcspn(s, "."); | ||
1708 | 1678 | ||
1709 | if (n > 0 && s[n] != 0) { | 1679 | if (n && s[n]) { |
1710 | strtoul(s + n + 1, &end, 10); | 1680 | size_t m = strspn(s + n + 1, "0123456789"); |
1711 | if (end > s + n + 1 && (*end == '.' || *end == 0)) | 1681 | if (m && (s[n + m] == '.' || s[n + m] == 0)) |
1712 | s[n] = 0; | 1682 | s[n] = 0; |
1713 | } | 1683 | } |
1714 | return s; | 1684 | return s; |
diff --git a/scripts/selinux/genheaders/Makefile b/scripts/selinux/genheaders/Makefile index 417b165008ee..1d1ac51359e3 100644 --- a/scripts/selinux/genheaders/Makefile +++ b/scripts/selinux/genheaders/Makefile | |||
@@ -2,4 +2,3 @@ hostprogs-y := genheaders | |||
2 | HOST_EXTRACFLAGS += -Isecurity/selinux/include | 2 | HOST_EXTRACFLAGS += -Isecurity/selinux/include |
3 | 3 | ||
4 | always := $(hostprogs-y) | 4 | always := $(hostprogs-y) |
5 | clean-files := $(hostprogs-y) | ||
diff --git a/scripts/selinux/mdp/Makefile b/scripts/selinux/mdp/Makefile index eb365b333441..dba7eff69a00 100644 --- a/scripts/selinux/mdp/Makefile +++ b/scripts/selinux/mdp/Makefile | |||
@@ -2,4 +2,4 @@ hostprogs-y := mdp | |||
2 | HOST_EXTRACFLAGS += -Isecurity/selinux/include | 2 | HOST_EXTRACFLAGS += -Isecurity/selinux/include |
3 | 3 | ||
4 | always := $(hostprogs-y) | 4 | always := $(hostprogs-y) |
5 | clean-files := $(hostprogs-y) policy.* file_contexts | 5 | clean-files := policy.* file_contexts |
diff --git a/scripts/tags.sh b/scripts/tags.sh index e6b011fe1d0d..cbfd269a6011 100755 --- a/scripts/tags.sh +++ b/scripts/tags.sh | |||
@@ -168,6 +168,7 @@ exuberant() | |||
168 | --extra=+f --c-kinds=+px \ | 168 | --extra=+f --c-kinds=+px \ |
169 | --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ | 169 | --regex-asm='/^(ENTRY|_GLOBAL)\(([^)]*)\).*/\2/' \ |
170 | --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ | 170 | --regex-c='/^SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/sys_\1/' \ |
171 | --regex-c='/^COMPAT_SYSCALL_DEFINE[[:digit:]]?\(([^,)]*).*/compat_sys_\1/' \ | ||
171 | --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ | 172 | --regex-c++='/^TRACE_EVENT\(([^,)]*).*/trace_\1/' \ |
172 | --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \ | 173 | --regex-c++='/^DEFINE_EVENT\([^,)]*, *([^,)]*).*/trace_\1/' \ |
173 | --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/' \ | 174 | --regex-c++='/PAGEFLAG\(([^,)]*).*/Page\1/' \ |
@@ -231,6 +232,7 @@ emacs() | |||
231 | all_target_sources | xargs $1 -a \ | 232 | all_target_sources | xargs $1 -a \ |
232 | --regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \ | 233 | --regex='/^\(ENTRY\|_GLOBAL\)(\([^)]*\)).*/\2/' \ |
233 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ | 234 | --regex='/^SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/sys_\1/' \ |
235 | --regex='/^COMPAT_SYSCALL_DEFINE[0-9]?(\([^,)]*\).*/compat_sys_\1/' \ | ||
234 | --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ | 236 | --regex='/^TRACE_EVENT(\([^,)]*\).*/trace_\1/' \ |
235 | --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \ | 237 | --regex='/^DEFINE_EVENT([^,)]*, *\([^,)]*\).*/trace_\1/' \ |
236 | --regex='/PAGEFLAG(\([^,)]*\).*/Page\1/' \ | 238 | --regex='/PAGEFLAG(\([^,)]*\).*/Page\1/' \ |