3 ms·
In some part the problem here is that Rust is making error handling explicit, while the C driver has all those error handling covered in other files. For examp
by xondono 5y ago
In some part the problem here is that Rust is making error handling explicit, while the C driver has all those error handling covered in other files.
For example, in the C version:
struct pl061 *pl061 = gpiochip_get_data(gc);
What happens if there's no chip? you should have a NULL check, but it's omitted because error handling is done outside of this file. The same is true for the additional if statement on the IRQ.
In the end is a side effect of this being an example, because it should be possible to refactor the code where error handling is simply done through the ? operator. IMO that's a better way to do it than the C alternative, because right now there's no way to know if those struct pointers have proper error handling or not without leaving this file and hunting for each struct and function.