SL Phase I - (Post 2) My Contribution to the Kernel!
This is the second post in a series of logs of my experience at the MAC0470 Free Software (SL) course at IME-USP.
Troubles in my environment
After finishing the two first tutorials again, I’ve been frustrated by the same problems: I wasn’t able to install new modules at the VM’s kernel.
After more debugging and frustration, I decided to switch back to Marcelo’s series of tutorials, but unfortunately, I still wasn’t able to execute libvirt due to incompatibilities.
Instead of spending even more time trying to setup the environment in my machine, I switched to pair programming, and went to collaborate with a colleague who had their setup working.
My contribution
Together, we’ve managed to make a few adjustments to one of the IIO driver files. The changes were simple, but useful, and I describe them next.
In certain parts of the code, there are loops that iterate trough each children of a node, which have to lock for the loop to execute. At each iteration, it is required to free the node after performing the desired computations.
In the kernel codebase, there are certain macros which support these iterative operations. One of them (which I’ll refer to as MACRO I) requires the calling function to free the current node after each iteration. Another (MACRO II), the actually reccomended one, does it automatically. It’s even able to recover from errors within the loop and free the child nodes in those occasions, providing a more robust and resilient approach.
Not all files of the codebase apply MACRO II. Our contribution consisted of replacting MACRO I with MACRO II in a particular file. Additionlay, since the node freeing was made automatically, we could even remove extra lines of code that would be responsible from allocating and freeing in the calling function.
We’ve applied our changes as a patch, sent it through the respective responsible mail list and, we’re currently waiting for feedback.
Note about old repo
For clarification, my colleague followed a different series of tutorials than me, which rendered my personal repo not being useful anymore. I will not be referring to it anymore.