4 ms·
> fortunately the programmer does and they can use Rust's type safety to reduce the opportunity for foot guns. And what, they just didn’t? This is an ordering
by geocar 5y ago
> fortunately the programmer does and they can use Rust's type safety to reduce the opportunity for foot guns.
And what, they just didn’t?
This is an ordering bug. You could encode that into types perhaps, but I do not think that would be easy or as valuable as other ways to spend time.
> Specifically, when you call that Rust readb() function with a constant like GPIO_SIZE that's not actually a GPIO register, it compares the constant you asked to readb to the size of the GPIO's I/O memory (1 page = 4096 bytes) and check it is smaller - if not the type match fails and your compiler tells you this won't work. No runtime crash, it doesn't compile.
I think nearly every c compiler has had the ability to warn on something like this for thirty years. What’s the point? The rust programmer could do things differently but so could the C programmer?
- tialaramex 5y ago> This is an ordering bug. It turns out that it isn't. I discussed in another part of the thread that these registers control interrupt handling between them. Maybe if you fiddle with them while something is bouncing the relevant IO pins up and down, you get a spurious interrupt, but I'm actually not sure which ordering would be least likely to cause that, the correct thing is almost certainly to just not blow up if you eat a spurious interrupt while fiddling with these registers or tell the device you don't want interrupts while fiddling with them, both of which are the same in either driver.