Hii all. I was about to write this blog before many days but I was kind of busy with some other stuffs. So, just forgot to write this blog. But now its almost 2:30am [IST] and I am stuck with one kernel error. So, to refresh my mind I just thought to write this blog. Ok. So, here is a blog dedicated to “Smatch”- One of the finest part of kernel janitors project. [To know more about kernel janitors project, go here: http://kernelnewbies.org/KernelJanitors%5D Basically Smatch is a released bug-finding tool that allows developers to write perl scripts to search for problems, it is also based on a modified gcc. It is created by Dan Carpenter. You can use smatch by cloning its git repository and building cross-functional database for it. Here I am giving you step by step instructions and commands for the same.
1. git clone git://repo.or.cz/smatch.git/
2. cd smatch; make -j4
3. cd ~/your/code
4. make clean
Now to build cross functional database go for following command:
[ This may take while. Don’t panic] And here you go. You are ready to run smatch over your files. Here are some commands for that. 1. To run smatch over whole kernel:
To run smatch over 1 particular directory:
Here, it may possible that sometimes you don’t need to build whole cross-functional database. At that time, you can go for building tiny cross functional database and can work on your particular file.
1. make allmodconfig
2. touch path/to/your/file
3. ~/smatch/smatch_scripts/kchecker –info –spammy patch/to/your/directory/ | tee warns.txt-info
4. touch path/to/your/file
5. ~/smatch/smatch_scripts/kchecker patch/to/your/directory/
And you are done. You will have smatch errors of your file. And trust me Smatch gives amazing errors. You can learn lots of things through it. Though I didn’t work on Smatch errors that much, I am planning to work more on it in future. By the way,Smatch gave me one good bug to work on. And I found the solution of it using Coccinelle. Oh.. Do you know about Coccinelle?? No. Wants to know?? Yes. Then wait for my next blog and till then……What are you waiting for!! Go and search to know more about it.