diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-14 12:22:35 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2015-02-14 12:22:35 -0500 |
commit | 83e047c104aa95a8a683d6bd421df1551c17dbd2 (patch) | |
tree | 494aef444659ebe5bcbd0e423f91e3eff33100c4 /scripts | |
parent | 18320f2a6871aaf2522f793fee4a67eccf5e131a (diff) | |
parent | a3b30e7210c870d79d3c3cedb80f8cfaab0f4e2e (diff) |
Merge branch 'akpm' (patches from Andrew)
Merge fourth set of updates from Andrew Morton:
- the rest of lib/
- checkpatch updates
- a few misc things
- kasan: kernel address sanitizer
- the rtc tree
* emailed patches from Andrew Morton <akpm@linux-foundation.org>: (108 commits)
ARM: mvebu: enable Armada 38x RTC driver in mvebu_v7_defconfig
ARM: mvebu: add Device Tree description of RTC on Armada 38x
MAINTAINERS: add the RTC driver for the Armada38x
drivers/rtc/rtc-armada38x: add a new RTC driver for recent mvebu SoCs
rtc: armada38x: add the device tree binding documentation
rtc: rtc-ab-b5ze-s3: add sub-minute alarm support
rtc: add support for Abracon AB-RTCMC-32.768kHz-B5ZE-S3 I2C RTC chip
of: add vendor prefix for Abracon Corporation
drivers/rtc/rtc-rk808.c: fix rtc time reading issue
drivers/rtc/rtc-isl12057.c: constify struct regmap_config
drivers/rtc/rtc-at91sam9.c: constify struct regmap_config
drivers/rtc/rtc-imxdi.c: add more known register bits
drivers/rtc/rtc-imxdi.c: trivial clean up code
ARM: mvebu: ISL12057 rtc chip can now wake up RN102, RN102 and RN2120
rtc: rtc-isl12057: add isil,irq2-can-wakeup-machine property for in-tree users
drivers/rtc/rtc-isl12057.c: add alarm support to Intersil ISL12057 RTC driver
drivers/rtc/rtc-pcf2123.c: add support for devicetree
kprobes: makes kprobes/enabled works correctly for optimized kprobes.
kprobes: set kprobes_all_disarmed earlier to enable re-optimization.
init: remove CONFIG_INIT_FALLBACK
...
Diffstat (limited to 'scripts')
-rw-r--r-- | scripts/Makefile.kasan | 25 | ||||
-rw-r--r-- | scripts/Makefile.lib | 10 | ||||
-rwxr-xr-x | scripts/checkpatch.pl | 147 | ||||
-rw-r--r-- | scripts/module-common.lds | 3 |
4 files changed, 159 insertions, 26 deletions
diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan new file mode 100644 index 000000000000..631619b2b118 --- /dev/null +++ b/scripts/Makefile.kasan | |||
@@ -0,0 +1,25 @@ | |||
1 | ifdef CONFIG_KASAN | ||
2 | ifdef CONFIG_KASAN_INLINE | ||
3 | call_threshold := 10000 | ||
4 | else | ||
5 | call_threshold := 0 | ||
6 | endif | ||
7 | |||
8 | CFLAGS_KASAN_MINIMAL := -fsanitize=kernel-address | ||
9 | |||
10 | CFLAGS_KASAN := $(call cc-option, -fsanitize=kernel-address \ | ||
11 | -fasan-shadow-offset=$(CONFIG_KASAN_SHADOW_OFFSET) \ | ||
12 | --param asan-stack=1 --param asan-globals=1 \ | ||
13 | --param asan-instrumentation-with-call-threshold=$(call_threshold)) | ||
14 | |||
15 | ifeq ($(call cc-option, $(CFLAGS_KASAN_MINIMAL) -Werror),) | ||
16 | $(warning Cannot use CONFIG_KASAN: \ | ||
17 | -fsanitize=kernel-address is not supported by compiler) | ||
18 | else | ||
19 | ifeq ($(CFLAGS_KASAN),) | ||
20 | $(warning CONFIG_KASAN: compiler does not support all options.\ | ||
21 | Trying minimal configuration) | ||
22 | CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL) | ||
23 | endif | ||
24 | endif | ||
25 | endif | ||
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 511755200634..044eb4f89a91 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib | |||
@@ -119,6 +119,16 @@ _c_flags += $(if $(patsubst n%,, \ | |||
119 | $(CFLAGS_GCOV)) | 119 | $(CFLAGS_GCOV)) |
120 | endif | 120 | endif |
121 | 121 | ||
122 | # | ||
123 | # Enable address sanitizer flags for kernel except some files or directories | ||
124 | # we don't want to check (depends on variables KASAN_SANITIZE_obj.o, KASAN_SANITIZE) | ||
125 | # | ||
126 | ifeq ($(CONFIG_KASAN),y) | ||
127 | _c_flags += $(if $(patsubst n%,, \ | ||
128 | $(KASAN_SANITIZE_$(basetarget).o)$(KASAN_SANITIZE)y), \ | ||
129 | $(CFLAGS_KASAN)) | ||
130 | endif | ||
131 | |||
122 | # If building the kernel in a separate objtree expand all occurrences | 132 | # If building the kernel in a separate objtree expand all occurrences |
123 | # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). | 133 | # of -Idir to -I$(srctree)/dir except for absolute paths (starting with '/'). |
124 | 134 | ||
diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index f0bb6d60c07b..d12435992dea 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl | |||
@@ -278,6 +278,7 @@ our $Attribute = qr{ | |||
278 | __noreturn| | 278 | __noreturn| |
279 | __used| | 279 | __used| |
280 | __cold| | 280 | __cold| |
281 | __pure| | ||
281 | __noclone| | 282 | __noclone| |
282 | __deprecated| | 283 | __deprecated| |
283 | __read_mostly| | 284 | __read_mostly| |
@@ -298,6 +299,7 @@ our $Binary = qr{(?i)0b[01]+$Int_type?}; | |||
298 | our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; | 299 | our $Hex = qr{(?i)0x[0-9a-f]+$Int_type?}; |
299 | our $Int = qr{[0-9]+$Int_type?}; | 300 | our $Int = qr{[0-9]+$Int_type?}; |
300 | our $Octal = qr{0[0-7]+$Int_type?}; | 301 | our $Octal = qr{0[0-7]+$Int_type?}; |
302 | our $String = qr{"[X\t]*"}; | ||
301 | our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; | 303 | our $Float_hex = qr{(?i)0x[0-9a-f]+p-?[0-9]+[fl]?}; |
302 | our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; | 304 | our $Float_dec = qr{(?i)(?:[0-9]+\.[0-9]*|[0-9]*\.[0-9]+)(?:e-?[0-9]+)?[fl]?}; |
303 | our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; | 305 | our $Float_int = qr{(?i)[0-9]+e-?[0-9]+[fl]?}; |
@@ -337,6 +339,11 @@ our $UTF8 = qr{ | |||
337 | | $NON_ASCII_UTF8 | 339 | | $NON_ASCII_UTF8 |
338 | }x; | 340 | }x; |
339 | 341 | ||
342 | our $typeOtherOSTypedefs = qr{(?x: | ||
343 | u_(?:char|short|int|long) | # bsd | ||
344 | u(?:nchar|short|int|long) # sysv | ||
345 | )}; | ||
346 | |||
340 | our $typeTypedefs = qr{(?x: | 347 | our $typeTypedefs = qr{(?x: |
341 | (?:__)?(?:u|s|be|le)(?:8|16|32|64)| | 348 | (?:__)?(?:u|s|be|le)(?:8|16|32|64)| |
342 | atomic_t | 349 | atomic_t |
@@ -473,6 +480,7 @@ sub build_types { | |||
473 | (?:$Modifier\s+|const\s+)* | 480 | (?:$Modifier\s+|const\s+)* |
474 | (?: | 481 | (?: |
475 | (?:typeof|__typeof__)\s*\([^\)]*\)| | 482 | (?:typeof|__typeof__)\s*\([^\)]*\)| |
483 | (?:$typeOtherOSTypedefs\b)| | ||
476 | (?:$typeTypedefs\b)| | 484 | (?:$typeTypedefs\b)| |
477 | (?:${all}\b) | 485 | (?:${all}\b) |
478 | ) | 486 | ) |
@@ -490,6 +498,7 @@ sub build_types { | |||
490 | (?: | 498 | (?: |
491 | (?:typeof|__typeof__)\s*\([^\)]*\)| | 499 | (?:typeof|__typeof__)\s*\([^\)]*\)| |
492 | (?:$typeTypedefs\b)| | 500 | (?:$typeTypedefs\b)| |
501 | (?:$typeOtherOSTypedefs\b)| | ||
493 | (?:${allWithAttr}\b) | 502 | (?:${allWithAttr}\b) |
494 | ) | 503 | ) |
495 | (?:\s+$Modifier|\s+const)* | 504 | (?:\s+$Modifier|\s+const)* |
@@ -517,7 +526,7 @@ our $Typecast = qr{\s*(\(\s*$NonptrType\s*\)){0,1}\s*}; | |||
517 | 526 | ||
518 | our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; | 527 | our $balanced_parens = qr/(\((?:[^\(\)]++|(?-1))*\))/; |
519 | our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*}; | 528 | our $LvalOrFunc = qr{((?:[\&\*]\s*)?$Lval)\s*($balanced_parens{0,1})\s*}; |
520 | our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant)}; | 529 | our $FuncArg = qr{$Typecast{0,1}($LvalOrFunc|$Constant|$String)}; |
521 | 530 | ||
522 | our $declaration_macros = qr{(?x: | 531 | our $declaration_macros = qr{(?x: |
523 | (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(| | 532 | (?:$Storage\s+)?(?:[A-Z_][A-Z0-9]*_){0,2}(?:DEFINE|DECLARE)(?:_[A-Z0-9]+){1,2}\s*\(| |
@@ -632,6 +641,8 @@ sub git_commit_info { | |||
632 | $output =~ s/^\s*//gm; | 641 | $output =~ s/^\s*//gm; |
633 | my @lines = split("\n", $output); | 642 | my @lines = split("\n", $output); |
634 | 643 | ||
644 | return ($id, $desc) if ($#lines < 0); | ||
645 | |||
635 | if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { | 646 | if ($lines[0] =~ /^error: short SHA1 $commit is ambiguous\./) { |
636 | # Maybe one day convert this block of bash into something that returns | 647 | # Maybe one day convert this block of bash into something that returns |
637 | # all matching commit ids, but it's very slow... | 648 | # all matching commit ids, but it's very slow... |
@@ -2159,6 +2170,13 @@ sub process { | |||
2159 | } | 2170 | } |
2160 | } | 2171 | } |
2161 | 2172 | ||
2173 | # Check email subject for common tools that don't need to be mentioned | ||
2174 | if ($in_header_lines && | ||
2175 | $line =~ /^Subject:.*\b(?:checkpatch|sparse|smatch)\b[^:]/i) { | ||
2176 | WARN("EMAIL_SUBJECT", | ||
2177 | "A patch subject line should describe the change not the tool that found it\n" . $herecurr); | ||
2178 | } | ||
2179 | |||
2162 | # Check for old stable address | 2180 | # Check for old stable address |
2163 | if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) { | 2181 | if ($line =~ /^\s*cc:\s*.*<?\bstable\@kernel\.org\b>?.*$/i) { |
2164 | ERROR("STABLE_ADDRESS", | 2182 | ERROR("STABLE_ADDRESS", |
@@ -2171,21 +2189,49 @@ sub process { | |||
2171 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); | 2189 | "Remove Gerrit Change-Id's before submitting upstream.\n" . $herecurr); |
2172 | } | 2190 | } |
2173 | 2191 | ||
2174 | # Check for improperly formed commit descriptions | 2192 | # Check for git id commit length and improperly formed commit descriptions |
2175 | if ($in_commit_log && | 2193 | if ($in_commit_log && $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i) { |
2176 | $line =~ /\bcommit\s+[0-9a-f]{5,}/i && | ||
2177 | !($line =~ /\b[Cc]ommit [0-9a-f]{12,40} \("/ || | ||
2178 | ($line =~ /\b[Cc]ommit [0-9a-f]{12,40}\s*$/ && | ||
2179 | defined $rawlines[$linenr] && | ||
2180 | $rawlines[$linenr] =~ /^\s*\("/))) { | ||
2181 | $line =~ /\b(c)ommit\s+([0-9a-f]{5,})/i; | ||
2182 | my $init_char = $1; | 2194 | my $init_char = $1; |
2183 | my $orig_commit = lc($2); | 2195 | my $orig_commit = lc($2); |
2184 | my $id = '01234567890ab'; | 2196 | my $short = 1; |
2185 | my $desc = 'commit description'; | 2197 | my $long = 0; |
2186 | ($id, $desc) = git_commit_info($orig_commit, $id, $desc); | 2198 | my $case = 1; |
2187 | ERROR("GIT_COMMIT_ID", | 2199 | my $space = 1; |
2188 | "Please use 12 or more chars for the git commit ID like: '${init_char}ommit $id (\"$desc\")'\n" . $herecurr); | 2200 | my $hasdesc = 0; |
2201 | my $hasparens = 0; | ||
2202 | my $id = '0123456789ab'; | ||
2203 | my $orig_desc = "commit description"; | ||
2204 | my $description = ""; | ||
2205 | |||
2206 | $short = 0 if ($line =~ /\bcommit\s+[0-9a-f]{12,40}/i); | ||
2207 | $long = 1 if ($line =~ /\bcommit\s+[0-9a-f]{41,}/i); | ||
2208 | $space = 0 if ($line =~ /\bcommit [0-9a-f]/i); | ||
2209 | $case = 0 if ($line =~ /\b[Cc]ommit\s+[0-9a-f]{5,40}[^A-F]/); | ||
2210 | if ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)"\)/i) { | ||
2211 | $orig_desc = $1; | ||
2212 | $hasparens = 1; | ||
2213 | } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s*$/i && | ||
2214 | defined $rawlines[$linenr] && | ||
2215 | $rawlines[$linenr] =~ /^\s*\("([^"]+)"\)/) { | ||
2216 | $orig_desc = $1; | ||
2217 | $hasparens = 1; | ||
2218 | } elsif ($line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("[^"]+$/i && | ||
2219 | defined $rawlines[$linenr] && | ||
2220 | $rawlines[$linenr] =~ /^\s*[^"]+"\)/) { | ||
2221 | $line =~ /\bcommit\s+[0-9a-f]{5,}\s+\("([^"]+)$/i; | ||
2222 | $orig_desc = $1; | ||
2223 | $rawlines[$linenr] =~ /^\s*([^"]+)"\)/; | ||
2224 | $orig_desc .= " " . $1; | ||
2225 | $hasparens = 1; | ||
2226 | } | ||
2227 | |||
2228 | ($id, $description) = git_commit_info($orig_commit, | ||
2229 | $id, $orig_desc); | ||
2230 | |||
2231 | if ($short || $long || $space || $case || ($orig_desc ne $description) || !$hasparens) { | ||
2232 | ERROR("GIT_COMMIT_ID", | ||
2233 | "Please use git commit description style 'commit <12+ chars of sha1> (\"<title line>\")' - ie: '${init_char}ommit $id (\"$description\")'\n" . $herecurr); | ||
2234 | } | ||
2189 | } | 2235 | } |
2190 | 2236 | ||
2191 | # Check for added, moved or deleted files | 2237 | # Check for added, moved or deleted files |
@@ -2355,6 +2401,13 @@ sub process { | |||
2355 | "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); | 2401 | "Use of CONFIG_EXPERIMENTAL is deprecated. For alternatives, see https://lkml.org/lkml/2012/10/23/580\n"); |
2356 | } | 2402 | } |
2357 | 2403 | ||
2404 | # discourage the use of boolean for type definition attributes of Kconfig options | ||
2405 | if ($realfile =~ /Kconfig/ && | ||
2406 | $line =~ /^\+\s*\bboolean\b/) { | ||
2407 | WARN("CONFIG_TYPE_BOOLEAN", | ||
2408 | "Use of boolean is deprecated, please use bool instead.\n" . $herecurr); | ||
2409 | } | ||
2410 | |||
2358 | if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && | 2411 | if (($realfile =~ /Makefile.*/ || $realfile =~ /Kbuild.*/) && |
2359 | ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { | 2412 | ($line =~ /\+(EXTRA_[A-Z]+FLAGS).*/)) { |
2360 | my $flag = $1; | 2413 | my $flag = $1; |
@@ -2499,7 +2552,7 @@ sub process { | |||
2499 | } | 2552 | } |
2500 | } | 2553 | } |
2501 | 2554 | ||
2502 | if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;\({\[\<\>])/ && | 2555 | if ($line =~ /^\+.*(\w+\s*)?\(\s*$Type\s*\)[ \t]+(?!$Assignment|$Arithmetic|[,;:\?\(\{\}\[\<\>]|&&|\|\||\\$)/ && |
2503 | (!defined($1) || $1 !~ /sizeof\s*/)) { | 2556 | (!defined($1) || $1 !~ /sizeof\s*/)) { |
2504 | if (CHK("SPACING", | 2557 | if (CHK("SPACING", |
2505 | "No space is necessary after a cast\n" . $herecurr) && | 2558 | "No space is necessary after a cast\n" . $herecurr) && |
@@ -3124,6 +3177,7 @@ sub process { | |||
3124 | $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && | 3177 | $line !~ /\btypedef\s+$Type\s*\(\s*\*?$Ident\s*\)\s*\(/ && |
3125 | $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && | 3178 | $line !~ /\btypedef\s+$Type\s+$Ident\s*\(/ && |
3126 | $line !~ /\b$typeTypedefs\b/ && | 3179 | $line !~ /\b$typeTypedefs\b/ && |
3180 | $line !~ /\b$typeOtherOSTypedefs\b/ && | ||
3127 | $line !~ /\b__bitwise(?:__|)\b/) { | 3181 | $line !~ /\b__bitwise(?:__|)\b/) { |
3128 | WARN("NEW_TYPEDEFS", | 3182 | WARN("NEW_TYPEDEFS", |
3129 | "do not add new typedefs\n" . $herecurr); | 3183 | "do not add new typedefs\n" . $herecurr); |
@@ -3200,7 +3254,7 @@ sub process { | |||
3200 | # check for uses of printk_ratelimit | 3254 | # check for uses of printk_ratelimit |
3201 | if ($line =~ /\bprintk_ratelimit\s*\(/) { | 3255 | if ($line =~ /\bprintk_ratelimit\s*\(/) { |
3202 | WARN("PRINTK_RATELIMITED", | 3256 | WARN("PRINTK_RATELIMITED", |
3203 | "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); | 3257 | "Prefer printk_ratelimited or pr_<level>_ratelimited to printk_ratelimit\n" . $herecurr); |
3204 | } | 3258 | } |
3205 | 3259 | ||
3206 | # printk should use KERN_* levels. Note that follow on printk's on the | 3260 | # printk should use KERN_* levels. Note that follow on printk's on the |
@@ -3646,7 +3700,22 @@ sub process { | |||
3646 | $op eq '*' or $op eq '/' or | 3700 | $op eq '*' or $op eq '/' or |
3647 | $op eq '%') | 3701 | $op eq '%') |
3648 | { | 3702 | { |
3649 | if ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { | 3703 | if ($check) { |
3704 | if (defined $fix_elements[$n + 2] && $ctx !~ /[EW]x[EW]/) { | ||
3705 | if (CHK("SPACING", | ||
3706 | "spaces preferred around that '$op' $at\n" . $hereptr)) { | ||
3707 | $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; | ||
3708 | $fix_elements[$n + 2] =~ s/^\s+//; | ||
3709 | $line_fixed = 1; | ||
3710 | } | ||
3711 | } elsif (!defined $fix_elements[$n + 2] && $ctx !~ /Wx[OE]/) { | ||
3712 | if (CHK("SPACING", | ||
3713 | "space preferred before that '$op' $at\n" . $hereptr)) { | ||
3714 | $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]); | ||
3715 | $line_fixed = 1; | ||
3716 | } | ||
3717 | } | ||
3718 | } elsif ($ctx =~ /Wx[^WCE]|[^WCE]xW/) { | ||
3650 | if (ERROR("SPACING", | 3719 | if (ERROR("SPACING", |
3651 | "need consistent spacing around '$op' $at\n" . $hereptr)) { | 3720 | "need consistent spacing around '$op' $at\n" . $hereptr)) { |
3652 | $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; | 3721 | $good = rtrim($fix_elements[$n]) . " " . trim($fix_elements[$n + 1]) . " "; |
@@ -4251,6 +4320,7 @@ sub process { | |||
4251 | $ctx = $dstat; | 4320 | $ctx = $dstat; |
4252 | 4321 | ||
4253 | $dstat =~ s/\\\n.//g; | 4322 | $dstat =~ s/\\\n.//g; |
4323 | $dstat =~ s/$;/ /g; | ||
4254 | 4324 | ||
4255 | if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) { | 4325 | if ($dstat =~ /^\+\s*#\s*define\s+$Ident\s*${balanced_parens}\s*do\s*{(.*)\s*}\s*while\s*\(\s*0\s*\)\s*([;\s]*)\s*$/) { |
4256 | my $stmts = $2; | 4326 | my $stmts = $2; |
@@ -4417,12 +4487,18 @@ sub process { | |||
4417 | 4487 | ||
4418 | # check for unnecessary blank lines around braces | 4488 | # check for unnecessary blank lines around braces |
4419 | if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) { | 4489 | if (($line =~ /^.\s*}\s*$/ && $prevrawline =~ /^.\s*$/)) { |
4420 | CHK("BRACES", | 4490 | if (CHK("BRACES", |
4421 | "Blank lines aren't necessary before a close brace '}'\n" . $hereprev); | 4491 | "Blank lines aren't necessary before a close brace '}'\n" . $hereprev) && |
4492 | $fix && $prevrawline =~ /^\+/) { | ||
4493 | fix_delete_line($fixlinenr - 1, $prevrawline); | ||
4494 | } | ||
4422 | } | 4495 | } |
4423 | if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { | 4496 | if (($rawline =~ /^.\s*$/ && $prevline =~ /^..*{\s*$/)) { |
4424 | CHK("BRACES", | 4497 | if (CHK("BRACES", |
4425 | "Blank lines aren't necessary after an open brace '{'\n" . $hereprev); | 4498 | "Blank lines aren't necessary after an open brace '{'\n" . $hereprev) && |
4499 | $fix) { | ||
4500 | fix_delete_line($fixlinenr, $rawline); | ||
4501 | } | ||
4426 | } | 4502 | } |
4427 | 4503 | ||
4428 | # no volatiles please | 4504 | # no volatiles please |
@@ -4545,7 +4621,7 @@ sub process { | |||
4545 | } | 4621 | } |
4546 | 4622 | ||
4547 | # check for logging functions with KERN_<LEVEL> | 4623 | # check for logging functions with KERN_<LEVEL> |
4548 | if ($line !~ /printk\s*\(/ && | 4624 | if ($line !~ /printk(?:_ratelimited|_once)?\s*\(/ && |
4549 | $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) { | 4625 | $line =~ /\b$logFunctions\s*\(.*\b(KERN_[A-Z]+)\b/) { |
4550 | my $level = $1; | 4626 | my $level = $1; |
4551 | if (WARN("UNNECESSARY_KERN_LEVEL", | 4627 | if (WARN("UNNECESSARY_KERN_LEVEL", |
@@ -4804,7 +4880,8 @@ sub process { | |||
4804 | # check for seq_printf uses that could be seq_puts | 4880 | # check for seq_printf uses that could be seq_puts |
4805 | if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) { | 4881 | if ($sline =~ /\bseq_printf\s*\(.*"\s*\)\s*;\s*$/) { |
4806 | my $fmt = get_quoted_string($line, $rawline); | 4882 | my $fmt = get_quoted_string($line, $rawline); |
4807 | if ($fmt ne "" && $fmt !~ /[^\\]\%/) { | 4883 | $fmt =~ s/%%//g; |
4884 | if ($fmt !~ /%/) { | ||
4808 | if (WARN("PREFER_SEQ_PUTS", | 4885 | if (WARN("PREFER_SEQ_PUTS", |
4809 | "Prefer seq_puts to seq_printf\n" . $herecurr) && | 4886 | "Prefer seq_puts to seq_printf\n" . $herecurr) && |
4810 | $fix) { | 4887 | $fix) { |
@@ -5089,6 +5166,12 @@ sub process { | |||
5089 | } | 5166 | } |
5090 | } | 5167 | } |
5091 | 5168 | ||
5169 | # check for uses of __DATE__, __TIME__, __TIMESTAMP__ | ||
5170 | while ($line =~ /\b(__(?:DATE|TIME|TIMESTAMP)__)\b/g) { | ||
5171 | ERROR("DATE_TIME", | ||
5172 | "Use of the '$1' macro makes the build non-deterministic\n" . $herecurr); | ||
5173 | } | ||
5174 | |||
5092 | # check for use of yield() | 5175 | # check for use of yield() |
5093 | if ($line =~ /\byield\s*\(\s*\)/) { | 5176 | if ($line =~ /\byield\s*\(\s*\)/) { |
5094 | WARN("YIELD", | 5177 | WARN("YIELD", |
@@ -5140,8 +5223,9 @@ sub process { | |||
5140 | "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr); | 5223 | "please use device_initcall() or more appropriate function instead of __initcall() (see include/linux/init.h)\n" . $herecurr); |
5141 | } | 5224 | } |
5142 | 5225 | ||
5143 | # check for various ops structs, ensure they are const. | 5226 | # check for various structs that are normally const (ops, kgdb, device_tree) |
5144 | my $struct_ops = qr{acpi_dock_ops| | 5227 | my $const_structs = qr{ |
5228 | acpi_dock_ops| | ||
5145 | address_space_operations| | 5229 | address_space_operations| |
5146 | backlight_ops| | 5230 | backlight_ops| |
5147 | block_device_operations| | 5231 | block_device_operations| |
@@ -5164,6 +5248,7 @@ sub process { | |||
5164 | mtrr_ops| | 5248 | mtrr_ops| |
5165 | neigh_ops| | 5249 | neigh_ops| |
5166 | nlmsvc_binding| | 5250 | nlmsvc_binding| |
5251 | of_device_id| | ||
5167 | pci_raw_ops| | 5252 | pci_raw_ops| |
5168 | pipe_buf_operations| | 5253 | pipe_buf_operations| |
5169 | platform_hibernation_ops| | 5254 | platform_hibernation_ops| |
@@ -5179,7 +5264,7 @@ sub process { | |||
5179 | usb_mon_operations| | 5264 | usb_mon_operations| |
5180 | wd_ops}x; | 5265 | wd_ops}x; |
5181 | if ($line !~ /\bconst\b/ && | 5266 | if ($line !~ /\bconst\b/ && |
5182 | $line =~ /\bstruct\s+($struct_ops)\b/) { | 5267 | $line =~ /\bstruct\s+($const_structs)\b/) { |
5183 | WARN("CONST_STRUCT", | 5268 | WARN("CONST_STRUCT", |
5184 | "struct $1 should normally be const\n" . | 5269 | "struct $1 should normally be const\n" . |
5185 | $herecurr); | 5270 | $herecurr); |
@@ -5204,6 +5289,13 @@ sub process { | |||
5204 | "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr); | 5289 | "#define of '$1' is wrong - use Kconfig variables or standard guards instead\n" . $herecurr); |
5205 | } | 5290 | } |
5206 | 5291 | ||
5292 | # likely/unlikely comparisons similar to "(likely(foo) > 0)" | ||
5293 | if ($^V && $^V ge 5.10.0 && | ||
5294 | $line =~ /\b((?:un)?likely)\s*\(\s*$FuncArg\s*\)\s*$Compare/) { | ||
5295 | WARN("LIKELY_MISUSE", | ||
5296 | "Using $1 should generally have parentheses around the comparison\n" . $herecurr); | ||
5297 | } | ||
5298 | |||
5207 | # whine mightly about in_atomic | 5299 | # whine mightly about in_atomic |
5208 | if ($line =~ /\bin_atomic\s*\(/) { | 5300 | if ($line =~ /\bin_atomic\s*\(/) { |
5209 | if ($realfile =~ m@^drivers/@) { | 5301 | if ($realfile =~ m@^drivers/@) { |
@@ -5255,6 +5347,9 @@ sub process { | |||
5255 | length($val) ne 4)) { | 5347 | length($val) ne 4)) { |
5256 | ERROR("NON_OCTAL_PERMISSIONS", | 5348 | ERROR("NON_OCTAL_PERMISSIONS", |
5257 | "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr); | 5349 | "Use 4 digit octal (0777) not decimal permissions\n" . $herecurr); |
5350 | } elsif ($val =~ /^$Octal$/ && (oct($val) & 02)) { | ||
5351 | ERROR("EXPORTED_WORLD_WRITABLE", | ||
5352 | "Exporting writable files is usually an error. Consider more restrictive permissions.\n" . $herecurr); | ||
5258 | } | 5353 | } |
5259 | } | 5354 | } |
5260 | } | 5355 | } |
diff --git a/scripts/module-common.lds b/scripts/module-common.lds index bec15f908fc6..73a2c7da0e55 100644 --- a/scripts/module-common.lds +++ b/scripts/module-common.lds | |||
@@ -16,4 +16,7 @@ SECTIONS { | |||
16 | __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) } | 16 | __kcrctab_unused 0 : { *(SORT(___kcrctab_unused+*)) } |
17 | __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } | 17 | __kcrctab_unused_gpl 0 : { *(SORT(___kcrctab_unused_gpl+*)) } |
18 | __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } | 18 | __kcrctab_gpl_future 0 : { *(SORT(___kcrctab_gpl_future+*)) } |
19 | |||
20 | . = ALIGN(8); | ||
21 | .init_array 0 : { *(SORT(.init_array.*)) *(.init_array) } | ||
19 | } | 22 | } |