summaryrefslogtreecommitdiffstats
path: root/Documentation
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation')
-rw-r--r--Documentation/dev-tools/sparse.rst (renamed from Documentation/sparse.txt)39
-rw-r--r--Documentation/dev-tools/tools.rst1
2 files changed, 25 insertions, 15 deletions
diff --git a/Documentation/sparse.txt b/Documentation/dev-tools/sparse.rst
index eceab1308a8c..8c250e8a2105 100644
--- a/Documentation/sparse.txt
+++ b/Documentation/dev-tools/sparse.rst
@@ -1,11 +1,20 @@
1Copyright 2004 Linus Torvalds 1.. Copyright 2004 Linus Torvalds
2Copyright 2004 Pavel Machek <pavel@ucw.cz> 2.. Copyright 2004 Pavel Machek <pavel@ucw.cz>
3Copyright 2006 Bob Copeland <me@bobcopeland.com> 3.. Copyright 2006 Bob Copeland <me@bobcopeland.com>
4
5Sparse
6======
7
8Sparse is a semantic checker for C programs; it can be used to find a
9number of potential problems with kernel code. See
10https://lwn.net/Articles/689907/ for an overview of sparse; this document
11contains some kernel-specific sparse information.
12
4 13
5Using sparse for typechecking 14Using sparse for typechecking
6~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 15-----------------------------
7 16
8"__bitwise" is a type attribute, so you have to do something like this: 17"__bitwise" is a type attribute, so you have to do something like this::
9 18
10 typedef int __bitwise pm_request_t; 19 typedef int __bitwise pm_request_t;
11 20
@@ -20,13 +29,13 @@ but in this case we really _do_ want to force the conversion). And because
20the enum values are all the same type, now "enum pm_request" will be that 29the enum values are all the same type, now "enum pm_request" will be that
21type too. 30type too.
22 31
23And with gcc, all the __bitwise/__force stuff goes away, and it all ends 32And with gcc, all the "__bitwise"/"__force stuff" goes away, and it all
24up looking just like integers to gcc. 33ends up looking just like integers to gcc.
25 34
26Quite frankly, you don't need the enum there. The above all really just 35Quite frankly, you don't need the enum there. The above all really just
27boils down to one special "int __bitwise" type. 36boils down to one special "int __bitwise" type.
28 37
29So the simpler way is to just do 38So the simpler way is to just do::
30 39
31 typedef int __bitwise pm_request_t; 40 typedef int __bitwise pm_request_t;
32 41
@@ -50,7 +59,7 @@ __bitwise - noisy stuff; in particular, __le*/__be* are that. We really
50don't want to drown in noise unless we'd explicitly asked for it. 59don't want to drown in noise unless we'd explicitly asked for it.
51 60
52Using sparse for lock checking 61Using sparse for lock checking
53~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 62------------------------------
54 63
55The following macros are undefined for gcc and defined during a sparse 64The following macros are undefined for gcc and defined during a sparse
56run to use the "context" tracking feature of sparse, applied to 65run to use the "context" tracking feature of sparse, applied to
@@ -69,22 +78,22 @@ annotation is needed. The tree annotations above are for cases where
69sparse would otherwise report a context imbalance. 78sparse would otherwise report a context imbalance.
70 79
71Getting sparse 80Getting sparse
72~~~~~~~~~~~~~~ 81--------------
73 82
74You can get latest released versions from the Sparse homepage at 83You can get latest released versions from the Sparse homepage at
75https://sparse.wiki.kernel.org/index.php/Main_Page 84https://sparse.wiki.kernel.org/index.php/Main_Page
76 85
77Alternatively, you can get snapshots of the latest development version 86Alternatively, you can get snapshots of the latest development version
78of sparse using git to clone.. 87of sparse using git to clone::
79 88
80 git://git.kernel.org/pub/scm/devel/sparse/sparse.git 89 git://git.kernel.org/pub/scm/devel/sparse/sparse.git
81 90
82DaveJ has hourly generated tarballs of the git tree available at.. 91DaveJ has hourly generated tarballs of the git tree available at::
83 92
84 http://www.codemonkey.org.uk/projects/git-snapshots/sparse/ 93 http://www.codemonkey.org.uk/projects/git-snapshots/sparse/
85 94
86 95
87Once you have it, just do 96Once you have it, just do::
88 97
89 make 98 make
90 make install 99 make install
@@ -92,7 +101,7 @@ Once you have it, just do
92as a regular user, and it will install sparse in your ~/bin directory. 101as a regular user, and it will install sparse in your ~/bin directory.
93 102
94Using sparse 103Using sparse
95~~~~~~~~~~~~ 104------------
96 105
97Do a kernel make with "make C=1" to run sparse on all the C files that get 106Do a kernel make with "make C=1" to run sparse on all the C files that get
98recompiled, or use "make C=2" to run sparse on the files whether they need to 107recompiled, or use "make C=2" to run sparse on the files whether they need to
@@ -101,7 +110,7 @@ have already built it.
101 110
102The optional make variable CF can be used to pass arguments to sparse. The 111The optional make variable CF can be used to pass arguments to sparse. The
103build system passes -Wbitwise to sparse automatically. To perform endianness 112build system passes -Wbitwise to sparse automatically. To perform endianness
104checks, you may define __CHECK_ENDIAN__: 113checks, you may define __CHECK_ENDIAN__::
105 114
106 make C=2 CF="-D__CHECK_ENDIAN__" 115 make C=2 CF="-D__CHECK_ENDIAN__"
107 116
diff --git a/Documentation/dev-tools/tools.rst b/Documentation/dev-tools/tools.rst
index ae0c58c784db..d4bbda319e79 100644
--- a/Documentation/dev-tools/tools.rst
+++ b/Documentation/dev-tools/tools.rst
@@ -15,3 +15,4 @@ whole; patches welcome!
15 :maxdepth: 2 15 :maxdepth: 2
16 16
17 coccinelle 17 coccinelle
18 sparse