diff options
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.rst | 1 |
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 @@ | |||
1 | Copyright 2004 Linus Torvalds | 1 | .. Copyright 2004 Linus Torvalds |
2 | Copyright 2004 Pavel Machek <pavel@ucw.cz> | 2 | .. Copyright 2004 Pavel Machek <pavel@ucw.cz> |
3 | Copyright 2006 Bob Copeland <me@bobcopeland.com> | 3 | .. Copyright 2006 Bob Copeland <me@bobcopeland.com> |
4 | |||
5 | Sparse | ||
6 | ====== | ||
7 | |||
8 | Sparse is a semantic checker for C programs; it can be used to find a | ||
9 | number of potential problems with kernel code. See | ||
10 | https://lwn.net/Articles/689907/ for an overview of sparse; this document | ||
11 | contains some kernel-specific sparse information. | ||
12 | |||
4 | 13 | ||
5 | Using sparse for typechecking | 14 | Using 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 | |||
20 | the enum values are all the same type, now "enum pm_request" will be that | 29 | the enum values are all the same type, now "enum pm_request" will be that |
21 | type too. | 30 | type too. |
22 | 31 | ||
23 | And with gcc, all the __bitwise/__force stuff goes away, and it all ends | 32 | And with gcc, all the "__bitwise"/"__force stuff" goes away, and it all |
24 | up looking just like integers to gcc. | 33 | ends up looking just like integers to gcc. |
25 | 34 | ||
26 | Quite frankly, you don't need the enum there. The above all really just | 35 | Quite frankly, you don't need the enum there. The above all really just |
27 | boils down to one special "int __bitwise" type. | 36 | boils down to one special "int __bitwise" type. |
28 | 37 | ||
29 | So the simpler way is to just do | 38 | So 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 | |||
50 | don't want to drown in noise unless we'd explicitly asked for it. | 59 | don't want to drown in noise unless we'd explicitly asked for it. |
51 | 60 | ||
52 | Using sparse for lock checking | 61 | Using sparse for lock checking |
53 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 62 | ------------------------------ |
54 | 63 | ||
55 | The following macros are undefined for gcc and defined during a sparse | 64 | The following macros are undefined for gcc and defined during a sparse |
56 | run to use the "context" tracking feature of sparse, applied to | 65 | run 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 | |||
69 | sparse would otherwise report a context imbalance. | 78 | sparse would otherwise report a context imbalance. |
70 | 79 | ||
71 | Getting sparse | 80 | Getting sparse |
72 | ~~~~~~~~~~~~~~ | 81 | -------------- |
73 | 82 | ||
74 | You can get latest released versions from the Sparse homepage at | 83 | You can get latest released versions from the Sparse homepage at |
75 | https://sparse.wiki.kernel.org/index.php/Main_Page | 84 | https://sparse.wiki.kernel.org/index.php/Main_Page |
76 | 85 | ||
77 | Alternatively, you can get snapshots of the latest development version | 86 | Alternatively, you can get snapshots of the latest development version |
78 | of sparse using git to clone.. | 87 | of 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 | ||
82 | DaveJ has hourly generated tarballs of the git tree available at.. | 91 | DaveJ 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 | ||
87 | Once you have it, just do | 96 | Once 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 | |||
92 | as a regular user, and it will install sparse in your ~/bin directory. | 101 | as a regular user, and it will install sparse in your ~/bin directory. |
93 | 102 | ||
94 | Using sparse | 103 | Using sparse |
95 | ~~~~~~~~~~~~ | 104 | ------------ |
96 | 105 | ||
97 | Do a kernel make with "make C=1" to run sparse on all the C files that get | 106 | Do a kernel make with "make C=1" to run sparse on all the C files that get |
98 | recompiled, or use "make C=2" to run sparse on the files whether they need to | 107 | recompiled, 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 | ||
102 | The optional make variable CF can be used to pass arguments to sparse. The | 111 | The optional make variable CF can be used to pass arguments to sparse. The |
103 | build system passes -Wbitwise to sparse automatically. To perform endianness | 112 | build system passes -Wbitwise to sparse automatically. To perform endianness |
104 | checks, you may define __CHECK_ENDIAN__: | 113 | checks, 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 | ||