rust-embedded / rust-i2cdev

Rust library for interfacing with i2c devices under Linux
Apache License 2.0
205 stars 53 forks source link

I2CRegisterMap panics when reading with offset 0 #84

Open Disasm opened 6 months ago

Disasm commented 6 months ago
#[test]
fn check_read_0() {
    let mut i2c = MockI2CDevice::new();
    let value = i2c.smbus_read_byte_data(0).unwrap();
    assert_eq!(value, 0);
}

This code panics with attempt to subtract with overflow because offset is no longer incremented inside I2CRegisterMap::read after 6671e87fbfde461ffcd36535ba0172f8e9835378. Probably it should be incremented.