From bda0ca26fb03f339f5eea32dd13b880e31a9d496 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Sun, 24 Nov 2019 14:55:20 +0100 Subject: [PATCH 1/2] i2c/eeprom: lint --- src/eeprom.rs | 2 +- src/i2c.rs | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/eeprom.rs b/src/eeprom.rs index 70cb3cf..ce2efc4 100644 --- a/src/eeprom.rs +++ b/src/eeprom.rs @@ -3,7 +3,7 @@ use super::i2c; const I2C_ADDR: u8 = 0xa0; -pub fn read_eui48<'a>(i2c: &pac::I2C2) -> Result<[u8; 6], i2c::Error> { +pub fn read_eui48(i2c: &pac::I2C2) -> Result<[u8; 6], i2c::Error> { let mut buffer = [0u8; 6]; i2c::write_read(i2c, I2C_ADDR, &[0xFAu8], &mut buffer)?; Ok(buffer) diff --git a/src/i2c.rs b/src/i2c.rs index 05989c9..5b3a17b 100644 --- a/src/i2c.rs +++ b/src/i2c.rs @@ -101,7 +101,7 @@ fn poll_for_start_ack( } } - return Err(Error::Timeout); + Err(Error::Timeout) } @@ -111,10 +111,10 @@ pub fn write_read( bytes: &[u8], buffer: &mut [u8], ) -> Result<(), Error> { - assert!(bytes.len() < 256 && bytes.len() > 0); - assert!(buffer.len() < 256 && buffer.len() > 0); + assert!(bytes.len() < 256 && !bytes.is_empty()); + assert!(buffer.len() < 256 && !buffer.is_empty()); - poll_for_start_ack(i2c, addr|0, false, bytes.len(), false, true)?; + poll_for_start_ack(i2c, addr, false, bytes.len(), false, true)?; for byte in bytes { // Wait until we are allowed to send data (START has been ACKed or last From 8c2c0a2027ea4e19fd07abb0c193a8ff5f5b5599 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20J=C3=B6rdens?= Date: Sun, 24 Nov 2019 15:04:29 +0100 Subject: [PATCH 2/2] clippy: allow missing safety doc (rtfm) --- src/eth.rs | 8 ++++++++ src/main.rs | 1 + 2 files changed, 9 insertions(+) diff --git a/src/eth.rs b/src/eth.rs index 9f71623..7f3d3de 100644 --- a/src/eth.rs +++ b/src/eth.rs @@ -328,6 +328,14 @@ impl Device { Self{ rx: RxRing::new(), tx: TxRing::new() } } + // Initialize the ethernet peripherals + // + // # Safety + // + // This iis transitively unsafe since it sets potentially + // unsafe register values. Might ultimately be safe if the values + // are correct. + // // After `init` is called, `Device` shall not be moved. pub unsafe fn init(&mut self, mac: EthernetAddress, eth_mac: &pac::ETHERNET_MAC, diff --git a/src/main.rs b/src/main.rs index ece96ce..78ef457 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,4 +1,5 @@ #![deny(warnings)] +#![allow(clippy::missing_safety_doc)] #![no_std] #![no_main]