diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-07 00:14:42 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2014-08-07 00:14:42 -0400 |
| commit | 33caee39925b887a99a2400dc5c980097c3573f9 (patch) | |
| tree | 8e68ad97e1fee88c4a3f31453041f8d139f2027e /scripts | |
| parent | 6456a0438b984186a0c9c8ecc9fe3d97b7ac3613 (diff) | |
| parent | f84223087402c45179be5e7060c5736c17a7b271 (diff) | |
Merge branch 'akpm' (patchbomb from Andrew Morton)
Merge incoming from Andrew Morton:
- Various misc things.
- arch/sh updates.
- Part of ocfs2. Review is slow.
- Slab updates.
- Most of -mm.
- printk updates.
- lib/ updates.
- checkpatch updates.
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (226 commits)
checkpatch: update $declaration_macros, add uninitialized_var
checkpatch: warn on missing spaces in broken up quoted
checkpatch: fix false positives for --strict "space after cast" test
checkpatch: fix false positive MISSING_BREAK warnings with --file
checkpatch: add test for native c90 types in unusual order
checkpatch: add signed generic types
checkpatch: add short int to c variable types
checkpatch: add for_each tests to indentation and brace tests
checkpatch: fix brace style misuses of else and while
checkpatch: add --fix option for a couple OPEN_BRACE misuses
checkpatch: use the correct indentation for which()
checkpatch: add fix_insert_line and fix_delete_line helpers
checkpatch: add ability to insert and delete lines to patch/file
checkpatch: add an index variable for fixed lines
checkpatch: warn on break after goto or return with same tab indentation
checkpatch: emit a warning on file add/move/delete
checkpatch: add test for commit id formatting style in commit log
checkpatch: emit fewer kmalloc_array/kcalloc conversion warnings
checkpatch: improve "no space after cast" test
checkpatch: allow multiple const * types
...
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 581 |
1 files changed, 470 insertions, 111 deletions
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 = (); | ||
