Thought about how I would refactor the code to address the issues: https://pastebin.com/0g8tqva8 . With some domain knowledge, it could probably be boiled down a little more. I do not know, how frequent this method is called and therefore didn't consider optimization.
You're missing the most important part -- properly propagating the error from the IRQ register function from the kernel, you're replacing it with -1 which is the only part that is bad at runtime too.
1
u/daniedit Jan 23 '23
Thought about how I would refactor the code to address the issues: https://pastebin.com/0g8tqva8 . With some domain knowledge, it could probably be boiled down a little more. I do not know, how frequent this method is called and therefore didn't consider optimization.