diff options
| -rw-r--r-- | Documentation/kbuild/00-INDEX | 2 | ||||
| -rw-r--r-- | Documentation/kbuild/headers_install.txt (renamed from Documentation/make/headers_install.txt) | 0 | ||||
| -rw-r--r-- | Makefile | 18 | ||||
| -rw-r--r-- | scripts/coccinelle/api/alloc/alloc_cast.cocci | 72 | ||||
| -rw-r--r-- | scripts/coccinelle/misc/array_size.cocci | 87 | ||||
| -rw-r--r-- | scripts/coccinelle/misc/badty.cocci | 76 | ||||
| -rw-r--r-- | scripts/coccinelle/misc/bugon.cocci (renamed from scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci) | 47 | ||||
| -rw-r--r-- | scripts/coccinelle/null/badzero.cocci | 3 |
8 files changed, 275 insertions, 30 deletions
diff --git a/Documentation/kbuild/00-INDEX b/Documentation/kbuild/00-INDEX index e8d2b6d83a3d..8c5e6aa78004 100644 --- a/Documentation/kbuild/00-INDEX +++ b/Documentation/kbuild/00-INDEX | |||
| @@ -1,5 +1,7 @@ | |||
| 1 | 00-INDEX | 1 | 00-INDEX |
| 2 | - this file: info on the kernel build process | 2 | - this file: info on the kernel build process |
| 3 | headers_install.txt | ||
| 4 | - how to export Linux headers for use by userspace | ||
| 3 | kbuild.txt | 5 | kbuild.txt |
| 4 | - developer information on kbuild | 6 | - developer information on kbuild |
| 5 | kconfig.txt | 7 | kconfig.txt |
diff --git a/Documentation/make/headers_install.txt b/Documentation/kbuild/headers_install.txt index 951eb9f1e040..951eb9f1e040 100644 --- a/Documentation/make/headers_install.txt +++ b/Documentation/kbuild/headers_install.txt | |||
| @@ -1064,6 +1064,13 @@ headers_check: headers_install | |||
| 1064 | $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1 | 1064 | $(Q)$(MAKE) $(hdr-inst)=arch/$(hdr-arch)/include/uapi/asm $(hdr-dst) HDRCHECK=1 |
| 1065 | 1065 | ||
| 1066 | # --------------------------------------------------------------------------- | 1066 | # --------------------------------------------------------------------------- |
| 1067 | # Kernel selftest | ||
| 1068 | |||
| 1069 | PHONY += kselftest | ||
| 1070 | kselftest: | ||
| 1071 | $(Q)$(MAKE) -C tools/testing/selftests run_tests | ||
| 1072 | |||
| 1073 | # --------------------------------------------------------------------------- | ||
| 1067 | # Modules | 1074 | # Modules |
| 1068 | 1075 | ||
| 1069 | ifdef CONFIG_MODULES | 1076 | ifdef CONFIG_MODULES |
| @@ -1250,9 +1257,9 @@ help: | |||
| 1250 | @echo ' tags/TAGS - Generate tags file for editors' | 1257 | @echo ' tags/TAGS - Generate tags file for editors' |
| 1251 | @echo ' cscope - Generate cscope index' | 1258 | @echo ' cscope - Generate cscope index' |
| 1252 | @echo ' gtags - Generate GNU GLOBAL index' | 1259 | @echo ' gtags - Generate GNU GLOBAL index' |
| 1253 | @echo ' kernelrelease - Output the release version string' | 1260 | @echo ' kernelrelease - Output the release version string (use with make -s)' |
| 1254 | @echo ' kernelversion - Output the version stored in Makefile' | 1261 | @echo ' kernelversion - Output the version stored in Makefile (use with make -s)' |
| 1255 | @echo ' image_name - Output the image name' | 1262 | @echo ' image_name - Output the image name (use with make -s)' |
| 1256 | @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ | 1263 | @echo ' headers_install - Install sanitised kernel headers to INSTALL_HDR_PATH'; \ |
| 1257 | echo ' (default: $(INSTALL_HDR_PATH))'; \ | 1264 | echo ' (default: $(INSTALL_HDR_PATH))'; \ |
| 1258 | echo '' | 1265 | echo '' |
| @@ -1266,6 +1273,11 @@ help: | |||
| 1266 | @echo ' headerdep - Detect inclusion cycles in headers' | 1273 | @echo ' headerdep - Detect inclusion cycles in headers' |
| 1267 | @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help | 1274 | @$(MAKE) -f $(srctree)/scripts/Makefile.help checker-help |
| 1268 | @echo '' | 1275 | @echo '' |
| 1276 | @echo 'Kernel selftest' | ||
| 1277 | @echo ' kselftest - Build and run kernel selftest (run as root)' | ||
| 1278 | @echo ' Build, install, and boot kernel before' | ||
| 1279 | @echo ' running kselftest on it' | ||
| 1280 | @echo '' | ||
| 1269 | @echo 'Kernel packaging:' | 1281 | @echo 'Kernel packaging:' |
| 1270 | @$(MAKE) $(build)=$(package-dir) help | 1282 | @$(MAKE) $(build)=$(package-dir) help |
| 1271 | @echo '' | 1283 | @echo '' |
diff --git a/scripts/coccinelle/api/alloc/alloc_cast.cocci b/scripts/coccinelle/api/alloc/alloc_cast.cocci new file mode 100644 index 000000000000..6c308ee19b32 --- /dev/null +++ b/scripts/coccinelle/api/alloc/alloc_cast.cocci | |||
| @@ -0,0 +1,72 @@ | |||
| 1 | /// Remove casting the values returned by memory allocation functions | ||
| 2 | /// like kmalloc, kzalloc, kmem_cache_alloc, kmem_cache_zalloc etc. | ||
| 3 | /// | ||
| 4 | //# This makes an effort to find cases of casting of values returned by | ||
| 5 | //# kmalloc, kzalloc, kcalloc, kmem_cache_alloc, kmem_cache_zalloc, | ||
| 6 | //# kmem_cache_alloc_node, kmalloc_node and kzalloc_node and removes | ||
| 7 | //# the casting as it is not required. The result in the patch case may | ||
| 8 | //#need some reformatting. | ||
| 9 | // | ||
| 10 | // Confidence: High | ||
| 11 | // Copyright: 2014, Himangi Saraogi GPLv2. | ||
| 12 | // Comments: | ||
| 13 | // Options: --no-includes --include-headers | ||
| 14 | // | ||
| 15 | |||
| 16 | virtual context | ||
| 17 | virtual patch | ||
| 18 | virtual org | ||
| 19 | virtual report | ||
| 20 | |||
| 21 | //---------------------------------------------------------- | ||
| 22 | // For context mode | ||
| 23 | //---------------------------------------------------------- | ||
| 24 | |||
| 25 | @depends on context@ | ||
| 26 | type T; | ||
| 27 | @@ | ||
| 28 | |||
| 29 | * (T *) | ||
| 30 | \(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | ||
| 31 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...) | ||
| 32 | |||
| 33 | //---------------------------------------------------------- | ||
| 34 | // For patch mode | ||
| 35 | //---------------------------------------------------------- | ||
| 36 | |||
| 37 | @depends on patch@ | ||
| 38 | type T; | ||
| 39 | @@ | ||
| 40 | |||
| 41 | - (T *) | ||
| 42 | (\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | ||
| 43 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...)) | ||
| 44 | |||
| 45 | //---------------------------------------------------------- | ||
| 46 | // For org and report mode | ||
| 47 | //---------------------------------------------------------- | ||
| 48 | |||
| 49 | @r depends on org || report@ | ||
| 50 | type T; | ||
| 51 | position p; | ||
| 52 | @@ | ||
| 53 | |||
| 54 | (T@p *)\(kmalloc\|kzalloc\|kcalloc\|kmem_cache_alloc\|kmem_cache_zalloc\| | ||
| 55 | kmem_cache_alloc_node\|kmalloc_node\|kzalloc_node\)(...) | ||
| 56 | |||
| 57 | @script:python depends on org@ | ||
| 58 | p << r.p; | ||
| 59 | t << r.T; | ||
| 60 | @@ | ||
| 61 | |||
| 62 | coccilib.org.print_safe_todo(p[0], t) | ||
| 63 | |||
| 64 | @script:python depends on report@ | ||
| 65 | p << r.p; | ||
| 66 | t << r.T; | ||
| 67 | @@ | ||
| 68 | |||
| 69 | msg="WARNING: casting value returned by memory allocation function to (%s *) is useless." % (t) | ||
| 70 | coccilib.report.print_report(p[0], msg) | ||
| 71 | |||
| 72 | |||
diff --git a/scripts/coccinelle/misc/array_size.cocci b/scripts/coccinelle/misc/array_size.cocci new file mode 100644 index 000000000000..81e279cd347b --- /dev/null +++ b/scripts/coccinelle/misc/array_size.cocci | |||
| @@ -0,0 +1,87 @@ | |||
| 1 | /// Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element | ||
| 2 | /// | ||
| 3 | //# This makes an effort to find cases where ARRAY_SIZE can be used such as | ||
| 4 | //# where there is a division of sizeof the array by the sizeof its first | ||
| 5 | //# element or by any indexed element or the element type. It replaces the | ||
| 6 | //# division of the two sizeofs by ARRAY_SIZE. | ||
| 7 | // | ||
| 8 | // Confidence: High | ||
| 9 | // Copyright: (C) 2014 Himangi Saraogi. GPLv2. | ||
| 10 | // Comments: | ||
| 11 | // Options: --no-includes --include-headers | ||
| 12 | |||
| 13 | virtual patch | ||
| 14 | virtual context | ||
| 15 | virtual org | ||
| 16 | virtual report | ||
| 17 | |||
| 18 | @i@ | ||
| 19 | @@ | ||
| 20 | |||
| 21 | #include <linux/kernel.h> | ||
| 22 | |||
| 23 | //---------------------------------------------------------- | ||
| 24 | // For context mode | ||
| 25 | //---------------------------------------------------------- | ||
| 26 | |||
| 27 | @depends on i&&context@ | ||
| 28 | type T; | ||
| 29 | T[] E; | ||
| 30 | @@ | ||
| 31 | ( | ||
| 32 | * (sizeof(E)/sizeof(*E)) | ||
| 33 | | | ||
| 34 | * (sizeof(E)/sizeof(E[...])) | ||
| 35 | | | ||
| 36 | * (sizeof(E)/sizeof(T)) | ||
| 37 | ) | ||
| 38 | |||
| 39 | //---------------------------------------------------------- | ||
| 40 | // For patch mode | ||
| 41 | //---------------------------------------------------------- | ||
| 42 | |||
| 43 | @depends on i&&patch@ | ||
| 44 | type T; | ||
| 45 | T[] E; | ||
| 46 | @@ | ||
| 47 | ( | ||
| 48 | - (sizeof(E)/sizeof(*E)) | ||
| 49 | + ARRAY_SIZE(E) | ||
| 50 | | | ||
| 51 | - (sizeof(E)/sizeof(E[...])) | ||
| 52 | + ARRAY_SIZE(E) | ||
| 53 | | | ||
| 54 | - (sizeof(E)/sizeof(T)) | ||
| 55 | + ARRAY_SIZE(E) | ||
| 56 | ) | ||
| 57 | |||
| 58 | //---------------------------------------------------------- | ||
| 59 | // For org and report mode | ||
| 60 | //---------------------------------------------------------- | ||
| 61 | |||
| 62 | @r@ | ||
| 63 | type T; | ||
| 64 | T[] E; | ||
| 65 | position p; | ||
| 66 | @@ | ||
| 67 | ( | ||
| 68 | (sizeof(E)@p /sizeof(*E)) | ||
| 69 | | | ||
| 70 | (sizeof(E)@p /sizeof(E[...])) | ||
| 71 | | | ||
| 72 | (sizeof(E)@p /sizeof(T)) | ||
| 73 | ) | ||
| 74 | |||
| 75 | @script:python depends on i&&org@ | ||
| 76 | p << r.p; | ||
| 77 | @@ | ||
| 78 | |||
| 79 | coccilib.org.print_todo(p[0], "WARNING should use ARRAY_SIZE") | ||
| 80 | |||
| 81 | @script:python depends on i&&report@ | ||
| 82 | p << r.p; | ||
| 83 | @@ | ||
| 84 | |||
| 85 | msg="WARNING: Use ARRAY_SIZE" | ||
| 86 | coccilib.report.print_report(p[0], msg) | ||
| 87 | |||
diff --git a/scripts/coccinelle/misc/badty.cocci b/scripts/coccinelle/misc/badty.cocci new file mode 100644 index 000000000000..2fc06fc71927 --- /dev/null +++ b/scripts/coccinelle/misc/badty.cocci | |||
| @@ -0,0 +1,76 @@ | |||
| 1 | /// Use ARRAY_SIZE instead of dividing sizeof array with sizeof an element | ||
| 2 | /// | ||
| 3 | //# This makes an effort to find cases where the argument to sizeof is wrong | ||
| 4 | //# in memory allocation functions by checking the type of the allocated memory | ||
| 5 | //# when it is a double pointer and ensuring the sizeof argument takes a pointer | ||
| 6 | //# to the the memory being allocated. There are false positives in cases the | ||
| 7 | //# sizeof argument is not used in constructing the return value. The result | ||
| 8 | //# may need some reformatting. | ||
| 9 | // | ||
| 10 | // Confidence: Moderate | ||
| 11 | // Copyright: (C) 2014 Himangi Saraogi. GPLv2. | ||
| 12 | // Comments: | ||
| 13 | // Options: | ||
| 14 | |||
| 15 | virtual patch | ||
| 16 | virtual context | ||
| 17 | virtual org | ||
| 18 | virtual report | ||
| 19 | |||
| 20 | //---------------------------------------------------------- | ||
| 21 | // For context mode | ||
| 22 | //---------------------------------------------------------- | ||
| 23 | |||
| 24 | @depends on context disable sizeof_type_expr@ | ||
| 25 | type T; | ||
| 26 | T **x; | ||
| 27 | @@ | ||
| 28 | |||
| 29 | x = | ||
| 30 | <+...sizeof( | ||
| 31 | * T | ||
| 32 | )...+> | ||
| 33 | |||
| 34 | //---------------------------------------------------------- | ||
| 35 | // For patch mode | ||
| 36 | //---------------------------------------------------------- | ||
| 37 | |||
| 38 | @depends on patch disable sizeof_type_expr@ | ||
| 39 | type T; | ||
| 40 | T **x; | ||
| 41 | @@ | ||
| 42 | |||
| 43 | x = | ||
| 44 | <+...sizeof( | ||
| 45 | - T | ||
| 46 | + *x | ||
| 47 | )...+> | ||
| 48 | |||
| 49 | //---------------------------------------------------------- | ||
| 50 | // For org and report mode | ||
| 51 | //---------------------------------------------------------- | ||
| 52 | |||
| 53 | @r disable sizeof_type_expr@ | ||
| 54 | type T; | ||
| 55 | T **x; | ||
| 56 | position p; | ||
| 57 | @@ | ||
| 58 | |||
| 59 | x = | ||
| 60 | <+...sizeof( | ||
| 61 | T@p | ||
| 62 | )...+> | ||
| 63 | |||
| 64 | @script:python depends on org@ | ||
| 65 | p << r.p; | ||
| 66 | @@ | ||
| 67 | |||
| 68 | coccilib.org.print_todo(p[0], "WARNING sizeof argument should be pointer type, not structure type") | ||
| 69 | |||
| 70 | @script:python depends on report@ | ||
| 71 | p << r.p; | ||
| 72 | @@ | ||
| 73 | |||
| 74 | msg="WARNING: Use correct pointer type argument for sizeof" | ||
| 75 | coccilib.report.print_report(p[0], msg) | ||
| 76 | |||
diff --git a/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci b/scripts/coccinelle/misc/bugon.cocci index bd5d08b882ee..556456ca761c 100644 --- a/scripts/coccinelle/api/alloc/drop_kmalloc_cast.cocci +++ b/scripts/coccinelle/misc/bugon.cocci | |||
| @@ -1,20 +1,17 @@ | |||
| 1 | /// Use BUG_ON instead of a if condition followed by BUG. | ||
| 1 | /// | 2 | /// |
| 2 | /// Casting (void *) value returned by kmalloc is useless | 3 | //# This makes an effort to find cases where BUG() follows an if |
| 3 | /// as mentioned in Documentation/CodingStyle, Chap 14. | 4 | //# condition on an expression and replaces the if condition and BUG() |
| 4 | /// | 5 | //# with a BUG_ON having the conditional expression of the if statement |
| 5 | // Confidence: High | 6 | //# as argument. |
| 6 | // Copyright: 2009,2010 Nicolas Palix, DIKU. GPLv2. | ||
| 7 | // URL: http://coccinelle.lip6.fr/ | ||
| 8 | // Options: --no-includes --include-headers | ||
| 9 | // | ||
| 10 | // Keywords: kmalloc, kzalloc, kcalloc | ||
| 11 | // Version min: < 2.6.12 kmalloc | ||
| 12 | // Version min: < 2.6.12 kcalloc | ||
| 13 | // Version min: 2.6.14 kzalloc | ||
| 14 | // | 7 | // |
| 8 | // Confidence: High | ||
| 9 | // Copyright: (C) 2014 Himangi Saraogi. GPLv2. | ||
| 10 | // Comments: | ||
| 11 | // Options: --no-includes, --include-headers | ||
| 15 | 12 | ||
| 16 | virtual context | ||
| 17 | virtual patch | 13 | virtual patch |
| 14 | virtual context | ||
| 18 | virtual org | 15 | virtual org |
| 19 | virtual report | 16 | virtual report |
| 20 | 17 | ||
| @@ -23,45 +20,43 @@ virtual report | |||
| 23 | //---------------------------------------------------------- | 20 | //---------------------------------------------------------- |
| 24 | 21 | ||
| 25 | @depends on context@ | 22 | @depends on context@ |
| 26 | type T; | 23 | expression e; |
| 27 | @@ | 24 | @@ |
| 28 | 25 | ||
| 29 | * (T *) | 26 | *if (e) BUG(); |
| 30 | \(kmalloc\|kzalloc\|kcalloc\)(...) | ||
| 31 | 27 | ||
| 32 | //---------------------------------------------------------- | 28 | //---------------------------------------------------------- |
| 33 | // For patch mode | 29 | // For patch mode |
| 34 | //---------------------------------------------------------- | 30 | //---------------------------------------------------------- |
| 35 | 31 | ||
| 36 | @depends on patch@ | 32 | @depends on patch@ |
| 37 | type T; | 33 | expression e; |
| 38 | @@ | 34 | @@ |
| 39 | 35 | ||
| 40 | - (T *) | 36 | -if (e) BUG(); |
| 41 | \(kmalloc\|kzalloc\|kcalloc\)(...) | 37 | +BUG_ON(e); |
| 42 | 38 | ||
| 43 | //---------------------------------------------------------- | 39 | //---------------------------------------------------------- |
| 44 | // For org and report mode | 40 | // For org and report mode |
| 45 | //---------------------------------------------------------- | 41 | //---------------------------------------------------------- |
| 46 | 42 | ||
| 47 | @r depends on org || report@ | 43 | @r@ |
| 48 | type T; | 44 | expression e; |
| 49 | position p; | 45 | position p; |
| 50 | @@ | 46 | @@ |
| 51 | 47 | ||
| 52 | (T@p *)\(kmalloc\|kzalloc\|kcalloc\)(...) | 48 | if (e) BUG@p (); |
| 53 | 49 | ||
| 54 | @script:python depends on org@ | 50 | @script:python depends on org@ |
| 55 | p << r.p; | 51 | p << r.p; |
| 56 | t << r.T; | ||
| 57 | @@ | 52 | @@ |
| 58 | 53 | ||
| 59 | coccilib.org.print_safe_todo(p[0], t) | 54 | coccilib.org.print_todo(p[0], "WARNING use BUG_ON") |
| 60 | 55 | ||
| 61 | @script:python depends on report@ | 56 | @script:python depends on report@ |
| 62 | p << r.p; | 57 | p << r.p; |
| 63 | t << r.T; | ||
| 64 | @@ | 58 | @@ |
| 65 | 59 | ||
| 66 | msg="WARNING: casting value returned by k[cmz]alloc to (%s *) is useless." % (t) | 60 | msg="WARNING: Use BUG_ON" |
| 67 | coccilib.report.print_report(p[0], msg) | 61 | coccilib.report.print_report(p[0], msg) |
| 62 | |||
diff --git a/scripts/coccinelle/null/badzero.cocci b/scripts/coccinelle/null/badzero.cocci index d79baf7220e7..5551da2b4fe3 100644 --- a/scripts/coccinelle/null/badzero.cocci +++ b/scripts/coccinelle/null/badzero.cocci | |||
| @@ -10,7 +10,7 @@ | |||
| 10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. | 10 | // Copyright: (C) 2012 Julia Lawall, INRIA/LIP6. GPLv2. |
| 11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. | 11 | // Copyright: (C) 2012 Gilles Muller, INRIA/LiP6. GPLv2. |
| 12 | // URL: http://coccinelle.lip6.fr/ | 12 | // URL: http://coccinelle.lip6.fr/ |
| 13 | // Comments: | 13 | // Comments: Requires Coccinelle version 1.0.0-rc20 or later |
| 14 | // Options: | 14 | // Options: |
| 15 | 15 | ||
| 16 | virtual patch | 16 | virtual patch |
| @@ -19,6 +19,7 @@ virtual org | |||
| 19 | virtual report | 19 | virtual report |
| 20 | 20 | ||
| 21 | @initialize:ocaml@ | 21 | @initialize:ocaml@ |
| 22 | @@ | ||
| 22 | let negtable = Hashtbl.create 101 | 23 | let negtable = Hashtbl.create 101 |
| 23 | 24 | ||
| 24 | @depends on patch@ | 25 | @depends on patch@ |
