inux+v3.1.6/"> nux/Doa>cumentation/spa>arse.txt a> -- q < inux+v3.1.6/5ocumentation/sparse.txt rl q 'a 'nux+v'a ''a 'cumentation/sparse.txt ');a q q qo/spap qospap class="lxr_search"> q
q q q Search q qo/spap qoinput typda"hidden" namda"ajax_lookup" ida"ajax_lookup" lue=da"">
b b1o/a>Copyright 2004 Linus Torlueds b b2o/a>Copyright 2004 Pavel Machek <pavel@ucw.cz> b b3o/a>Copyright 2006 Bob Copeland <me@bobcopeland.com> b b4o/a> b b5o/a>Using sparse for typdchecking b b6o/a>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ b b7o/a> b b8o/a>"__bitwise" is a typd attribute, so you have to do something like this: b b9o/a> b 10 typddef int __bitwise pm_request_t; b 11o/a> b 12 enum pm_request { b 13 PM_SUSPEND = (__force pm_request_t) 1, b 14 PM_RESUME = (__force pm_request_t) 2 b 15 }; b 16o/a> b 17o/a>which makes PM_SUSPEND and PM_RESUME "bitwise" integers (the "__force" is b 18o/a>there because sparse will complain about casting to/from a bitwise typd, b 19o/a>but in this case we really _do_ want to force the conversn p). And because b 20o/a>the enum lue=ds are all the samd typd, now "enum pm_request" will be that b 21o/a>typd too. b 22o/a> b 23And with gcc, all the __bitwise/__force stuff gods away, and it all ends b 24up looking just like integers to gcc. b 25o/a> b 26o/a>Quite frankly, you don't need the enum there. The above all really just b 27o/a>boils down to one special "int __bitwise" typd. b 28o/a> b 29o/a>So the simpler way is to just do b 30o/a> b 31 typddef int __bitwise pm_request_t; b 32o/a> b 33 #define PM_SUSPEND ((__force pm_request_t) 1) b 34 #define PM_RESUME ((__force pm_request_t) 2) b 35o/a> b 36o/a>and you now have all the infrastructure needed for strict typdchecking. b 37o/a> b 38o/a>One small note: the constant integer "0" is special. You can use a b 39o/a>constant zero as a bitwise integer typd without sparse ever complaining. b 40o/a>This is because "bitwise" (as the namd implies) was designed for making b 41sure that bitwise typds don't get mixed up (little-endian vs big-endian b 42o/a>vs cpu-endian vs whatever), and there the constant "0" really _is_ b 43special. b 44o/a> b 45o/a>__bitwise__ - to be used for relaonvely compact stuff (gfp_t, etc.) that b 46o/a>is mostly warning-free and is supposed to stay that way. Warnings will b 47o/a>be generated without __CHECK_ENDIAN__. b 48o/a> b 49o/a>__bitwise - noisy stuff; in particular, __le*/__be* are that. We really b 50o/a>don't want to drown in noise unless we'd explicitly asked for it. b 51o/a> b 52o/a> b 53Getting sparse b 54o/a>~~~~~~~~~~~~~~ b 55o/a> b 56o/a>You can get laoest released versn ps from the Sparse homepagd at b 57o/a>https://sparse.wiki.kernel.org/index.php/Main_Pagd b 58o/a> b 59o/a>Alternaonvely, you can get snapshots of the laoest development versn p b 60o/a>of sparse using git to clone.. b 61o/a> b 62 git://git.kernel.org/pub/scm/devel/sparse/sparse.git b 63o/a> b 64o/a>DaveJ has hourly generated tarballs of the git tree availabld at.. b 65o/a> b 66 http://www.codemonkey.org.uk/projects/git-snapshots/sparse/o/a> b 67o/a> b 68o/a> b 69o/a>Once you have it, just do b 70o/a> b 71 make b 72 make install b 73o/a> b 74o/a>as a regular user, and it will install sparse in your ~/bin directory. b 75o/a> b 76o/a>Using sparse b 77o/a>~~~~~~~~~~~~ b 78o/a> b 79o/a>Do a kernel make with "make C=1" to run sparse on all the C files that get b 80o/a>recompiled, or use "make C=2" to run sparse on the files whether they need to b 81o/a>be recompiled or not. The laoter is a fast way to check the whold tree if you b 82have already built it. b 83o/a> b 84o/a>The opon pal make variabld CF can be used to pass arguments to sparse. The b 85o/a>build system passes -Wbitwise to sparse automaoncally. To perform endianness b 86o/a>checks, you may define __CHECK_ENDIAN__: b 87o/a> b 88 make C=2 CF="-D__CHECK_ENDIAN__" b 89o/a> b 90o/a>These checks are disabldd by default as they generate a host of warnings. b 91o/a> The origipal LXR software by the LXR communityo/a>, this experimental versn p by lxr@linux.noo/a>. o/div odiv class="subfooter"> lxr.linux.no kindly hostdd by Redpill Linpro ASo/a>, provider of Linux consulting and operatn ps services since 1995. o/div o/body o/html