diff options
Diffstat (limited to 'scripts')
| -rwxr-xr-x | scripts/checkpatch.pl | 71 | ||||
| -rw-r--r-- | scripts/coccinelle/iterators/use_after_iter.cocci | 147 | ||||
| -rw-r--r-- | scripts/coccinelle/misc/irqf_oneshot.cocci | 65 | ||||
| -rwxr-xr-x | scripts/config | 62 | ||||
| -rw-r--r-- | scripts/kconfig/.gitignore | 1 | ||||
| -rw-r--r-- | scripts/kconfig/Makefile | 41 | ||||
| -rw-r--r-- | scripts/kconfig/confdata.c | 61 | ||||
| -rw-r--r-- | scripts/kconfig/lxdialog/check-lxdialog.sh | 8 | ||||
| -rw-r--r-- | scripts/kconfig/lxdialog/textbox.c | 3 | ||||
| -rw-r--r-- | scripts/kconfig/mconf.c | 6 | ||||
| -rw-r--r-- | scripts/kconfig/nconf.c | 10 | ||||
| -rw-r--r-- | scripts/kconfig/nconf.gui.c | 8 | ||||
| -rw-r--r-- | scripts/kconfig/streamline_config.pl | 175 | ||||
| -rw-r--r-- | scripts/link-vmlinux.sh | 4 | ||||
| -rw-r--r-- | scripts/mksysmap | 2 | ||||
| -rw-r--r-- | scripts/mod/file2alias.c | 5 | ||||
| -rw-r--r-- | scripts/mod/modpost.c | 11 | ||||
| -rw-r--r-- | scripts/package/builddeb | 7 | ||||
| -rw-r--r-- | scripts/sortextable.c | 1 | ||||
| -rwxr-xr-x | scripts/tags.sh | 6 |
20 files changed, 613 insertions, 81 deletions
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index e5bd60ff48e3..913d6bdfdda3 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
| @@ -1600,13 +1600,17 @@ sub process { | |||
| 1600 | 1600 | ||
| 1601 | # Check signature styles | 1601 | # Check signature styles |
| 1602 | if (!$in_header_lines && | 1602 | if (!$in_header_lines && |
| 1603 | $line =~ /^(\s*)($signature_tags)(\s*)(.*)/) { | 1603 | $line =~ /^(\s*)([a-z0-9_-]+by:|$signature_tags)(\s*)(.*)/i) { |
| 1604 | my $space_before = $1; | 1604 | my $space_before = $1; |
| 1605 | my $sign_off = $2; | 1605 | my $sign_off = $2; |
| 1606 | my $space_after = $3; | 1606 | my $space_after = $3; |
| 1607 | my $email = $4; | 1607 | my $email = $4; |
| 1608 | my $ucfirst_sign_off = ucfirst(lc($sign_off)); | 1608 | my $ucfirst_sign_off = ucfirst(lc($sign_off)); |
| 1609 | 1609 | ||
| 1610 | if ($sign_off !~ /$signature_tags/) { | ||
| 1611 | WARN("BAD_SIGN_OFF", | ||
| 1612 | "Non-standard signature: $sign_off\n" . $herecurr); | ||
| 1613 | } | ||
| 1610 | if (defined $space_before && $space_before ne "") { | 1614 | if (defined $space_before && $space_before ne "") { |
| 1611 | WARN("BAD_SIGN_OFF", | 1615 | WARN("BAD_SIGN_OFF", |
| 1612 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); | 1616 | "Do not use whitespace before $ucfirst_sign_off\n" . $herecurr); |
| @@ -1848,8 +1852,8 @@ sub process { | |||
| 1848 | 1852 | ||
| 1849 | my $pos = pos_last_openparen($rest); | 1853 | my $pos = pos_last_openparen($rest); |
| 1850 | if ($pos >= 0) { | 1854 | if ($pos >= 0) { |
| 1851 | $line =~ /^\+([ \t]*)/; | 1855 | $line =~ /^(\+| )([ \t]*)/; |
| 1852 | my $newindent = $1; | 1856 | my $newindent = $2; |
| 1853 | 1857 | ||
| 1854 | my $goodtabindent = $oldindent . | 1858 | my $goodtabindent = $oldindent . |
| 1855 | "\t" x ($pos / 8) . | 1859 | "\t" x ($pos / 8) . |
| @@ -2984,6 +2988,45 @@ sub process { | |||
| 2984 | } | 2988 | } |
| 2985 | } | 2989 | } |
| 2986 | 2990 | ||
| 2991 | # do {} while (0) macro tests: | ||
| 2992 | # single-statement macros do not need to be enclosed in do while (0) loop, | ||
| 2993 | # macro should not end with a semicolon | ||
| 2994 | if ($^V && $^V ge 5.10.0 && | ||
| 2995 | $realfile !~ m@/vmlinux.lds.h$@ && | ||
| 2996 | $line =~ /^.\s*\#\s*define\s+$Ident(\()?/) { | ||
| 2997 | my $ln = $linenr; | ||
| 2998 | my $cnt = $realcnt; | ||
| 2999 | my ($off, $dstat, $dcond, $rest); | ||
| 3000 | my $ctx = ''; | ||
| 3001 | ($dstat, $dcond, $ln, $cnt, $off) = | ||
| 3002 | ctx_statement_block($linenr, $realcnt, 0); | ||
| 3003 | $ctx = $dstat; | ||
| 3004 | |||
| 3005 | $dstat =~ s/\\\n.//g; | ||
| 3006 | |||
| 3007 | if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) { | ||
| 3008 | my $stmts = $2; | ||
| 3009 | my $semis = $3; | ||
| 3010 | |||
| 3011 | $ctx =~ s/\n*$//; | ||
| 3012 | my $cnt = statement_rawlines($ctx); | ||
| 3013 | my $herectx = $here . "\n"; | ||
| 3014 | |||
| 3015 | for (my $n = 0; $n < $cnt; $n++) { | ||
| 3016 | $herectx .= raw_line($linenr, $n) . "\n"; | ||
| 3017 | } | ||
| 3018 | |||
| 3019 | if (($stmts =~ tr/;/;/) == 1) { | ||
| 3020 | WARN("SINGLE_STATEMENT_DO_WHILE_MACRO", | ||
| 3021 | "Single statement macros should not use a do {} while (0) loop\n" . "$herectx"); | ||
| 3022 | } | ||
| 3023 | if (defined $semis && $semis ne "") { | ||
| 3024 | WARN("DO_WHILE_MACRO_WITH_TRAILING_SEMICOLON", | ||
| 3025 | "do {} while (0) macros should not be semicolon terminated\n" . "$herectx"); | ||
| 3026 | } | ||
| 3027 | } | ||
| 3028 | } | ||
| 3029 | |||
| 2987 | # make sure symbols are always wrapped with VMLINUX_SYMBOL() ... | 3030 | # make sure symbols are always wrapped with VMLINUX_SYMBOL() ... |
| 2988 | # all assignments may have only one of the following with an assignment: | 3031 | # all assignments may have only one of the following with an assignment: |
| 2989 | # . | 3032 | # . |
| @@ -3261,6 +3304,12 @@ sub process { | |||
| 3261 | "sizeof(& should be avoided\n" . $herecurr); | 3304 | "sizeof(& should be avoided\n" . $herecurr); |
| 3262 | } | 3305 | } |
| 3263 | 3306 | ||
| 3307 | # check for sizeof without parenthesis | ||
| 3308 | if ($line =~ /\bsizeof\s+((?:\*\s*|)$Lval|$Type(?:\s+$Lval|))/) { | ||
| 3309 | WARN("SIZEOF_PARENTHESIS", | ||
| 3310 | "sizeof $1 should be sizeof($1)\n" . $herecurr); | ||
| 3311 | } | ||
| 3312 | |||
| 3264 | # check for line continuations in quoted strings with odd counts of " | 3313 | # check for line continuations in quoted strings with odd counts of " |
| 3265 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { | 3314 | if ($rawline =~ /\\$/ && $rawline =~ tr/"/"/ % 2) { |
| 3266 | WARN("LINE_CONTINUATIONS", | 3315 | WARN("LINE_CONTINUATIONS", |
| @@ -3309,6 +3358,22 @@ sub process { | |||
| 3309 | } | 3358 | } |
| 3310 | } | 3359 | } |
| 3311 | 3360 | ||
| 3361 | # check usleep_range arguments | ||
| 3362 | if ($^V && $^V ge 5.10.0 && | ||
| 3363 | defined $stat && | ||
| 3364 | $stat =~ /^\+(?:.*?)\busleep_range\s*\(\s*($FuncArg)\s*,\s*($FuncArg)\s*\)/) { | ||
| 3365 | my $min = $1; | ||
| 3366 | my $max = $7; | ||
| 3367 | if ($min eq $max) { | ||
| 3368 | WARN("USLEEP_RANGE", | ||
| 3369 | "usleep_range should not use min == max args; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
| 3370 | } elsif ($min =~ /^\d+$/ && $max =~ /^\d+$/ && | ||
| 3371 | $min > $max) { | ||
| 3372 | WARN("USLEEP_RANGE", | ||
| 3373 | "usleep_range args reversed, use min then max; see Documentation/timers/timers-howto.txt\n" . "$here\n$stat\n"); | ||
| 3374 | } | ||
| 3375 | } | ||
| 3376 | |||
| 3312 | # check for new externs in .c files. | 3377 | # check for new externs in .c files. |
| 3313 | if ($realfile =~ /\.c$/ && defined $stat && | 3378 | if ($realfile =~ /\.c$/ && defined $stat && |
| 3314 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) | 3379 | $stat =~ /^.\s*(?:extern\s+)?$Type\s+($Ident)(\s*)\(/s) |
diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci new file mode 100644 index 000000000000..06284c57a951 --- /dev/null +++ b/scripts/coccinelle/iterators/use_after_iter.cocci | |||
| @@ -0,0 +1,147 @@ | |||
| 1 | /// If list_for_each_entry, etc complete a traversal of the list, the iterator | ||
| 2 | /// variable ends up pointing to an address at an offset from the list head, | ||
| 3 | /// and not a meaningful structure. Thus this value should not be used after | ||
| 4 | /// the end of the iterator. | ||
| 5 | //#False positives arise when there is a goto in the iterator and the | ||
| 6 | //#reported reference is at the label of this goto. Some flag tests | ||
| 7 | //#may also cause a report to be a false positive. | ||
| 8 | /// | ||
| 9 | // Confidence: Moderate | ||
| 10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | ||
| 11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LIP6. GPLv2. | ||
| 12 | // URL: http://coccinelle.lip6.fr/ | ||
| 13 | // Comments: | ||
| 14 | // Options: -no_includes -include_headers | ||
| 15 | |||
| 16 | virtual context | ||
| 17 | virtual org | ||
| 18 | virtual report | ||
| 19 | |||
| 20 | @r exists@ | ||
| 21 | identifier c,member; | ||
| 22 | expression E,x; | ||
| 23 | iterator name list_for_each_entry; | ||
| 24 | iterator name list_for_each_entry_reverse; | ||
| 25 | iterator name list_for_each_entry_continue; | ||
| 26 | iterator name list_for_each_entry_continue_reverse; | ||
| 27 | iterator name list_for_each_entry_from; | ||
| 28 | iterator name list_for_each_entry_safe; | ||
| 29 | iterator name list_for_each_entry_safe_continue; | ||
| 30 | iterator name list_for_each_entry_safe_from; | ||
| 31 | iterator name list_for_each_entry_safe_reverse; | ||
