rust-i2cdev icon indicating copy to clipboard operation
rust-i2cdev copied to clipboard

I2CRegisterMap panics when reading with offset 0

Open Disasm opened this issue 1 year ago • 0 comments

#[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.

Disasm avatar Feb 25 '24 11:02 Disasm