This week I’m going to talk of some of the interesting scripts I’ve found in Coccinellery.
There are A LOT of scripts in coccinellery which you can see here.
One of the first few scripts that I submitted a patch for was using badcheck.cocci. This script checks the devm_ioremap_resource error detection code. Some functions in the kernel like devm_ioremap_resource use an IS_ERR test instead of a NULL test for error detection but in many places in the kernel developers have not updated the error detection code. Excitingly, this script, if all goes well, after some required updation I will be sending to the kernel 🙂
Some functions like kmem_cache_alloc, kmem_cache_zalloc, etc have a corresponding freeing function known as kmem_cache_free; but some developers have used kfree instead of kmem_cache_free. A script to solve this issue is given here.
countptr.cocci is a script that removes an exceptional ‘&’ in front of a function name. Interestingly this one gives a lot of results in the kernel and is a good semantic patch to submit and get patches accepted. It is very easy too 🙂
Typically, we use devm_kzalloc in probe function of a driver to allocate managed resources. But sometimes, both devm_kzalloc and kzalloc are used in the probe function. This is generally an incorrect practice and devm functions should be used consistently. These inconsistencies can be found with the help of this script.
There are lots of interesting scripts on devm functions and a number of opportunities to submit patches on the same.
Interesting times ahead indeed!