From 1f9ad5ff62e67ddb7f933a5414d541f42b163c6b Mon Sep 17 00:00:00 2001 From: Astro Date: Sun, 11 Aug 2019 00:55:27 +0200 Subject: [PATCH] delint --- src/cortex_a9/mmu.rs | 7 +------ src/cortex_a9/regs.rs | 2 +- src/eth/mod.rs | 2 +- src/eth/regs.rs | 2 +- src/eth/rx.rs | 12 +++++++----- src/eth/tx.rs | 12 +++++++----- src/main.rs | 5 +++-- src/slcr.rs | 2 +- src/stdio.rs | 8 ++++---- src/uart/baud_rate_gen.rs | 2 +- src/uart/mod.rs | 1 - src/uart/regs.rs | 2 +- 12 files changed, 28 insertions(+), 29 deletions(-) diff --git a/src/cortex_a9/mmu.rs b/src/cortex_a9/mmu.rs index 2eb477d..435a844 100644 --- a/src/cortex_a9/mmu.rs +++ b/src/cortex_a9/mmu.rs @@ -1,4 +1,3 @@ -use core::mem::uninitialized; use bit_field::BitField; use super::{regs::*, asm}; use crate::regs::RegisterW; @@ -73,7 +72,7 @@ pub struct L1Entry(u32); impl L1Entry { #[inline(always)] pub fn section(phys_base: u32, section: L1Section) -> Self { - /// Must be aligned to 1 MB + // Must be aligned to 1 MB assert!(phys_base & 0x000f_ffff == 0); let mut entry = L1Entry(phys_base); @@ -382,8 +381,4 @@ pub fn with_mmu !>(l1table: &L1Table, mut f: F) -> ! { asm::isb(); f(); - - // table must live until here - drop(l1table.table); - unreachable!(); } diff --git a/src/cortex_a9/regs.rs b/src/cortex_a9/regs.rs index 8f265b2..647db47 100644 --- a/src/cortex_a9/regs.rs +++ b/src/cortex_a9/regs.rs @@ -1,5 +1,5 @@ use crate::{register_bit, register_bits}; -use crate::regs::{RegisterR, RegisterW, RegisterRW}; +use crate::regs::{RegisterR, RegisterW}; macro_rules! def_reg_r { ($name:tt, $type: ty, $asm_instr:tt) => { diff --git a/src/eth/mod.rs b/src/eth/mod.rs index e84c489..bb804e8 100644 --- a/src/eth/mod.rs +++ b/src/eth/mod.rs @@ -219,7 +219,7 @@ impl Eth { }); } - fn init(mut self) -> Self { + fn init(self) -> Self { // Clear the Network Control register. self.regs.net_ctrl.write(regs::NetCtrl::zeroed()); self.regs.net_ctrl.write(regs::NetCtrl::zeroed().clear_stat_regs(true)); diff --git a/src/eth/regs.rs b/src/eth/regs.rs index b7b16b7..4a75f20 100644 --- a/src/eth/regs.rs +++ b/src/eth/regs.rs @@ -1,6 +1,6 @@ use volatile_register::{RO, WO, RW}; -use crate::{register, register_bit, register_bits, register_bits_typed, regs::*}; +use crate::{register, register_bit, register_bits, register_bits_typed}; #[repr(C)] pub struct RegisterBlock { diff --git a/src/eth/rx.rs b/src/eth/rx.rs index 516ea80..828d633 100644 --- a/src/eth/rx.rs +++ b/src/eth/rx.rs @@ -1,5 +1,5 @@ use core::ops::Deref; -use crate::{register, register_bit, register_bits, register_bits_typed, regs::*}; +use crate::{register, register_bit, register_bits, regs::*}; use super::MTU; #[derive(Debug)] @@ -18,10 +18,12 @@ pub struct DescEntry { } register!(desc_word0, DescWord0, RW, u32); -/// true if owned by software, false if owned by hardware -register_bit!(desc_word0, used, 0); -/// mark last desc in list -register_bit!(desc_word0, wrap, 1); +register_bit!(desc_word0, + /// true if owned by software, false if owned by hardware + used, 0); +register_bit!(desc_word0, + /// mark last desc in list + wrap, 1); register_bits!(desc_word0, address, u32, 2, 31); register!(desc_word1, DescWord1, RW, u32); diff --git a/src/eth/tx.rs b/src/eth/tx.rs index 45fedf7..1353539 100644 --- a/src/eth/tx.rs +++ b/src/eth/tx.rs @@ -1,5 +1,5 @@ use core::ops::{Deref, DerefMut}; -use crate::{register, register_bit, register_bits, register_bits_typed, regs::*}; +use crate::{register, register_bit, register_bits, regs::*}; use crate::println; use super::{MTU, regs}; @@ -20,10 +20,12 @@ register_bits!(desc_word1, csum_offload_errors, u8, 20, 22); register_bit!(desc_word1, late_collision_tx_error, 26); register_bit!(desc_word1, ahb_frame_corruption, 27); register_bit!(desc_word1, retry_limit_exceeded, 29); -/// marks last descriptor in list -register_bit!(desc_word1, wrap, 30); -/// true if owned by software, false if owned by hardware -register_bit!(desc_word1, used, 31); +register_bit!(desc_word1, + /// marks last descriptor in list + wrap, 30); +register_bit!(desc_word1, + /// true if owned by software, false if owned by hardware + used, 31); /// Number of descriptors pub const DESCS: usize = 8; diff --git a/src/main.rs b/src/main.rs index 3e6edef..d889cf0 100644 --- a/src/main.rs +++ b/src/main.rs @@ -5,6 +5,8 @@ #![feature(naked_functions)] #![feature(compiler_builtins_lib)] #![feature(never_type)] +// TODO: disallow unused/dead_code when code moves into a lib crate +#![allow(dead_code)] use core::mem::uninitialized; @@ -79,7 +81,7 @@ fn main() { let mut rx_descs: [eth::rx::DescEntry; 8] = unsafe { uninitialized() }; let mut rx_buffers = [[0u8; 1536]; 8]; - let mut eth = eth.start_rx(&mut rx_descs, &mut rx_buffers); + let eth = eth.start_rx(&mut rx_descs, &mut rx_buffers); let mut tx_descs: [eth::tx::DescEntry; 8] = unsafe { uninitialized() }; let mut tx_buffers = [[0u8; 1536]; 8]; let mut eth = eth.start_tx(&mut tx_descs, &mut tx_buffers); @@ -111,7 +113,6 @@ fn main() { None => println!("eth tx shortage"), } } - panic!("End"); } #[panic_handler] diff --git a/src/slcr.rs b/src/slcr.rs index 407d81a..f5d8341 100644 --- a/src/slcr.rs +++ b/src/slcr.rs @@ -1,6 +1,6 @@ ///! Register definitions for System Level Control -use volatile_register::{RO, WO, RW}; +use volatile_register::{RO, RW}; use crate::{register, register_at, register_bit, register_bits, register_bits_typed, regs::RegisterW, regs::RegisterRW}; diff --git a/src/stdio.rs b/src/stdio.rs index 05ff4af..0860019 100644 --- a/src/stdio.rs +++ b/src/stdio.rs @@ -9,7 +9,7 @@ pub fn get_uart() -> &'static mut Uart { unsafe { match &mut UART { None => { - let mut uart = Uart::serial(UART_RATE); + let uart = Uart::serial(UART_RATE); UART = Some(uart); UART.as_mut().unwrap() } @@ -23,7 +23,7 @@ macro_rules! print { ($($arg:tt)*) => ({ use core::fmt::Write; let uart = crate::stdio::get_uart(); - write!(uart, $($arg)*); + let _ = write!(uart, $($arg)*); }) } @@ -32,8 +32,8 @@ macro_rules! println { ($($arg:tt)*) => ({ use core::fmt::Write; let uart = crate::stdio::get_uart(); - write!(uart, $($arg)*); - write!(uart, "\r\n"); + let _ = write!(uart, $($arg)*); + let _ = write!(uart, "\r\n"); while !uart.tx_fifo_empty() {} }) } diff --git a/src/uart/baud_rate_gen.rs b/src/uart/baud_rate_gen.rs index 673635b..6ee2801 100644 --- a/src/uart/baud_rate_gen.rs +++ b/src/uart/baud_rate_gen.rs @@ -37,7 +37,7 @@ pub fn configure(regs: &mut RegisterBlock, mut clk: u32, baud: u32) { } match best { - Some((cd, bdiv, error)) => { + Some((cd, bdiv, _error)) => { regs.baud_rate_gen.write(BaudRateGen::zeroed().cd(cd)); regs.baud_rate_divider.write(BaudRateDiv::zeroed().bdiv(bdiv)); } diff --git a/src/uart/mod.rs b/src/uart/mod.rs index 223abbd..512f2a8 100644 --- a/src/uart/mod.rs +++ b/src/uart/mod.rs @@ -1,5 +1,4 @@ use core::fmt; -use volatile_register::RW; use crate::regs::*; use crate::slcr; diff --git a/src/uart/regs.rs b/src/uart/regs.rs index bc3592f..b2f1e75 100644 --- a/src/uart/regs.rs +++ b/src/uart/regs.rs @@ -1,6 +1,6 @@ use volatile_register::{RO, WO, RW}; -use crate::{register, register_bit, register_bits, register_bits_typed, register_at, regs::*}; +use crate::{register, register_bit, register_bits, register_bits_typed, register_at}; #[repr(u8)] pub enum ChannelMode {