I’ve been getting quite a few mails recently regarding Outreachy round 12 and where to get started. This post is just my attempt to sum it all up.
Build the kernel
Tools to cleanup the kernel
Checkpatch is a script in the kernel tree that facilitates better kernel code, and can be used to check many coding style rules. You should essentially run it on all the patches you prepare before sending them to maintainers. Note that Checkpatch also gives false warnings at times. It is available in the “scripts” directory of Linux.
Run Checkpatch on all drivers in staging.
perl scripts/checkpatch.pl -f drivers/staging/*
Coccinelle is a program matching and transformation engine which provides the language SmPL (Semantic Patch Language) for specifying desired matches and transformations in C code. Coccinelle semantic patches are available in the “scripts” directory of Linux.
sudo apt-get install coccinelle
Run the coccinelle script on all drivers in the kernel.
spatch –sp-file a.cocci */
A Coccinelle-specific target is defined in the top level Makefile.This target is named ‘coccicheck’ and calls the ‘coccicheck’ front-end in the ‘scripts’ directory.
To make a report for every semantic patch, run the following command
make coccicheck MODE=report
To produce patches, run:
make coccicheck MODE=patch
Smatch is a static analysis tool for C. Most of the checks are for the linux kernel.
git clone git://repo.or.cz/smatch.git cd smatch make sudo make install
make clean make CHECK=~/path/to/smatch/smatch -p=kernel C=1 bzImage modules | tee warns.txt
Tool for static code analysis to detect coding errors
sudo apt-get install sparse
make C=2 CF=”-D__CHECK_ENDIAN__” drivers/staging/wlan-ng/
Check out the documentation here
Books To Read
- Linux kernel development by Robert Love
- Linux Device Drivers by Jonathan Corbet, Alessandro Rubini, and Greg Kroah-Hartman
Open source is all about collaboration
The kernel is huge and it’s easy to get lost in it. I can tell by personal experience that you will learn more about working of operating systems by hacking on kernel code than you ever will by reading an entire OS textbook. However the process will be faster if you ask questions on mailing lists such as firstname.lastname@example.org, email@example.com and interact with other developers. Finally, if you find that you love it don’t give up. It’s totally worth it.
Helpful links -