Skip to content

Commit 3693a09

Browse files
committed
Take code out of unsafe + whitespace fix
1 parent cb90512 commit 3693a09

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/ffi.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ pub struct i2c_msg {
3030
pub(crate) len: u16,
3131
/// pointer to msg data
3232
pub(crate) buf: *const u8,
33-
}
33+
}
3434

3535
bitflags! {
3636
struct I2CFunctions: u32 {
@@ -420,8 +420,9 @@ pub fn i2c_rdwr(fd: RawFd, values: &mut [i2c_msg]) -> Result<u32, I2CError> {
420420
nmsgs: values.len() as u32,
421421
};
422422

423+
let n;
423424
unsafe {
424-
let n = ioctl::i2c_rdwr(fd, &i2c_data)?;
425-
Ok(n as u32)
425+
n = ioctl::i2c_rdwr(fd, &i2c_data)?;
426426
}
427+
Ok(n as u32)
427428
}

0 commit comments

Comments
 (0)