Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
eldruin committed Sep 15, 2021
1 parent 15f797b commit f24a9fa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 11 deletions.
5 changes: 2 additions & 3 deletions examples/nunchuck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ mod nunchuck {
let mut buf: [u8; 6] = [0; 6];

// tell the nunchuck to prepare a sample
try!(self
.i2cdev
self.i2cdev
.smbus_write_byte(0x00)
.map_err(NunchuckError::Error));
.map_err(NunchuckError::Error)?;

// now, read it!
thread::sleep(Duration::from_millis(10));
Expand Down
4 changes: 2 additions & 2 deletions examples/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ mod sensors {
i2cdev.smbus_write_byte_data(REGISTER_POWER_CTL, 0x00)?;

// configure some defaults
try!(i2cdev
.smbus_write_byte_data(REGISTER_BW_RATE, ADXL345DataRate::RATE_1600HZ as u8));
i2cdev
.smbus_write_byte_data(REGISTER_BW_RATE, ADXL345DataRate::RATE_1600HZ as u8)?;
i2cdev.smbus_write_byte_data(REGISTER_DATA_FORMAT, 0x08)?;
i2cdev.smbus_write_byte_data(REGISTER_OFSX, 0xFD)?;
i2cdev.smbus_write_byte_data(REGISTER_OFSY, 0x03)?;
Expand Down
10 changes: 5 additions & 5 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,15 @@ unsafe fn i2c_smbus_access(
size: I2CSMBusSize,
data: *mut i2c_smbus_data,
) -> Result<(), I2CError> {
let mut args = i2c_smbus_ioctl_data {
let args = i2c_smbus_ioctl_data {
read_write: read_write as u8,
command,
size: size as u32,
data,
};

// remove type information
ioctl::i2c_smbus(fd, &mut args).map(drop)
ioctl::i2c_smbus(fd, &args).map(drop)
}

#[inline]
Expand Down Expand Up @@ -375,7 +375,7 @@ fn copy_to_i2c_block_data(values: &[u8], max_size: usize) -> i2c_smbus_data {

#[inline]
pub fn i2c_smbus_write_block_data(fd: RawFd, register: u8, values: &[u8]) -> Result<(), I2CError> {
let mut data = copy_to_i2c_block_data(&values, 32);
let mut data = copy_to_i2c_block_data(values, 32);
unsafe {
i2c_smbus_access(
fd,
Expand All @@ -393,7 +393,7 @@ pub fn i2c_smbus_write_i2c_block_data(
register: u8,
values: &[u8],
) -> Result<(), I2CError> {
let mut data = copy_to_i2c_block_data(&values, 32);
let mut data = copy_to_i2c_block_data(values, 32);
unsafe {
i2c_smbus_access(
fd,
Expand All @@ -411,7 +411,7 @@ pub fn i2c_smbus_process_call_block(
register: u8,
values: &[u8],
) -> Result<Vec<u8>, I2CError> {
let mut data = copy_to_i2c_block_data(&values, 31);
let mut data = copy_to_i2c_block_data(values, 31);
unsafe {
i2c_smbus_access(
fd,
Expand Down
2 changes: 1 addition & 1 deletion src/mock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl I2CRegisterMap {
/// Set several registers starting at the given offset
pub fn write_regs(&mut self, offset: usize, data: &[u8]) {
println!("WRITE | 0x{:X} : {:?}", offset, data);
self.registers[offset..(data.len() + offset)].clone_from_slice(&data);
self.registers[offset..(data.len() + offset)].clone_from_slice(data);
}
}

Expand Down

0 comments on commit f24a9fa

Please sign in to comment.