Skip to content

Commit

Permalink
preparing fuzz
Browse files Browse the repository at this point in the history
Signed-off-by: JadKHaddad <jadkhaddad@gmail.com>
  • Loading branch information
JadKHaddad committed Apr 8, 2024
1 parent e843349 commit e518820
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions bmp180/src/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,23 +47,17 @@ impl embedded_hal::i2c::I2c for FuzzI2C<'_> {
for operation in operations {
match operation {
embedded_hal::i2c::Operation::Write(write) => {
if write[0] == Register::ChipId as u8 {
self.is_id_write = true;
} else {
self.is_id_write = false;
}
self.is_id_write = write[0] == Register::ChipId as u8;
}
embedded_hal::i2c::Operation::Read(read) => {
if self.is_id_write {
read[0] = Id::Valid as u8;
} else if self.data.len() == read.len() {
read.copy_from_slice(self.data);
} else if self.data.len() < read.len() {
read[..self.data.len()].copy_from_slice(self.data);
} else {
if self.data.len() == read.len() {
read.copy_from_slice(self.data);
} else if self.data.len() < read.len() {
read[..self.data.len()].copy_from_slice(self.data);
} else {
read.copy_from_slice(&self.data[..read.len()]);
}
read.copy_from_slice(&self.data[..read.len()]);
}
}
}
Expand Down

0 comments on commit e518820

Please sign in to comment.