Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
eldruin committed Aug 1, 2023
1 parent ea3ee5b commit b283b82
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 14 deletions.
14 changes: 7 additions & 7 deletions examples/nunchuck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,13 @@ mod nunchuck {

#[derive(Debug)]
pub struct NunchuckReading {
joystick_x: u8,
joystick_y: u8,
accel_x: u16, // 10-bit
accel_y: u16, // 10-bit
accel_z: u16, // 10-bit
c_button_pressed: bool,
z_button_pressed: bool,
pub joystick_x: u8,
pub joystick_y: u8,
pub accel_x: u16, // 10-bit
pub accel_y: u16, // 10-bit
pub accel_z: u16, // 10-bit
pub c_button_pressed: bool,
pub z_button_pressed: bool,
}

impl NunchuckReading {
Expand Down
5 changes: 2 additions & 3 deletions examples/sensors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,8 @@ mod sensors {
// If values are less than 16 bytes, need to adjust
let extrabits = 16 - integer_bits - fractional_bits - 1;
let rawval: i16 = BigEndian::read_i16(&[msb, lsb]);
let adj = (f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits))
/ 10_f32.powi(dec_pt_zero_pad);
adj
(f32::from(rawval) / 2_f32.powi(fractional_bits + extrabits))
/ 10_f32.powi(dec_pt_zero_pad)
}

impl MPL115A2Coefficients {
Expand Down
6 changes: 3 additions & 3 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,7 @@ pub fn i2c_smbus_read_block_data(fd: RawFd, register: u8) -> Result<Vec<u8>, I2C
// create a vector from the data in the block starting at byte
// 1 and ending after count bytes after that
let count = data.block[0];
Ok((&data.block[1..(count + 1) as usize]).to_vec())
Ok((data.block[1..(count + 1) as usize]).to_vec())
}

pub fn i2c_smbus_read_i2c_block_data(
Expand All @@ -377,7 +377,7 @@ pub fn i2c_smbus_read_i2c_block_data(
// create a vector from the data in the block starting at byte
// 1 and ending after count bytes after that
let count = data.block[0];
Ok((&data.block[1..(count + 1) as usize]).to_vec())
Ok((data.block[1..(count + 1) as usize]).to_vec())
}

#[inline]
Expand Down Expand Up @@ -445,7 +445,7 @@ pub fn i2c_smbus_process_call_block(
// create a vector from the data in the block starting at byte
// 1 and ending after count bytes after that
let count = data.block[0];
Ok((&data.block[1..(count + 1) as usize]).to_vec())
Ok((data.block[1..(count + 1) as usize]).to_vec())
}

#[inline]
Expand Down
2 changes: 1 addition & 1 deletion src/linux.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ impl<'a> I2CTransfer<'a> for LinuxI2CDevice {
/// Issue the provided sequence of I2C transactions
fn transfer(&mut self, messages: &'a mut [Self::Message]) -> Result<u32, LinuxI2CError> {
for msg in messages.iter_mut() {
(*msg).addr = self.slave_address;
msg.addr = self.slave_address;
}
ffi::i2c_rdwr(self.as_raw_fd(), messages).map_err(From::from)
}
Expand Down

0 comments on commit b283b82

Please sign in to comment.