From e7d00d47352dbafcae4b527232ad1a3fbc3f0e58 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Thu, 11 Jun 2020 12:58:03 +0200 Subject: [PATCH] Fix various kernel warnings. --- src/acpi/aml/namespace.rs | 2 +- src/acpi/dmar/mod.rs | 24 +++++++++++------------- src/acpi/fadt.rs | 4 ++-- src/acpi/hpet.rs | 2 +- src/acpi/madt.rs | 8 +++----- src/acpi/mod.rs | 2 +- src/acpi/rsdt.rs | 2 +- src/acpi/rxsdt.rs | 2 +- src/acpi/xsdt.rs | 2 +- src/arch/x86_64/device/ioapic.rs | 5 ++--- src/arch/x86_64/device/mod.rs | 2 +- src/arch/x86_64/interrupt/irq.rs | 2 +- src/arch/x86_64/start.rs | 2 +- src/scheme/acpi.rs | 6 +++--- src/scheme/irq.rs | 4 ++-- src/scheme/serio.rs | 4 ++-- src/syscall/process.rs | 2 +- 17 files changed, 35 insertions(+), 40 deletions(-) diff --git a/src/acpi/aml/namespace.rs b/src/acpi/aml/namespace.rs index 8716398..fef3b20 100644 --- a/src/acpi/aml/namespace.rs +++ b/src/acpi/aml/namespace.rs @@ -4,7 +4,7 @@ use alloc::string::ToString; use alloc::vec::Vec; use alloc::collections::BTreeMap; -use core::fmt::{Debug, Formatter, Error}; +use core::fmt::Debug; use core::str::FromStr; use super::termlist::parse_term_list; diff --git a/src/acpi/dmar/mod.rs b/src/acpi/dmar/mod.rs index 1e18a52..4e5c363 100644 --- a/src/acpi/dmar/mod.rs +++ b/src/acpi/dmar/mod.rs @@ -39,12 +39,12 @@ impl Dmar { DmarEntry::Drhd(dmar_drhd) => { let drhd = dmar_drhd.get(active_table); - println!("VER: {:X}", drhd.version); - println!("CAP: {:X}", drhd.cap); - println!("EXT_CAP: {:X}", drhd.ext_cap); - println!("GCMD: {:X}", drhd.gl_cmd); - println!("GSTS: {:X}", drhd.gl_sts); - println!("RT: {:X}", drhd.root_table); + println!("VER: {:X}", {drhd.version}); + println!("CAP: {:X}", {drhd.cap}); + println!("EXT_CAP: {:X}", {drhd.ext_cap}); + println!("GCMD: {:X}", {drhd.gl_cmd}); + println!("GSTS: {:X}", {drhd.gl_sts}); + println!("RT: {:X}", {drhd.root_table}); }, _ => () } @@ -77,11 +77,9 @@ impl Dmar { } } -/// - /// DMAR DMA Remapping Hardware Unit Definition // TODO: Implement iterator on DmarDrhd scope -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct DmarDrhd { kind: u16, @@ -102,7 +100,7 @@ impl DmarDrhd { /// DMAR Reserved Memory Region Reporting // TODO: Implement iterator on DmarRmrr scope -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct DmarRmrr { kind: u16, @@ -115,7 +113,7 @@ pub struct DmarRmrr { /// DMAR Root Port ATS Capability Reporting // TODO: Implement iterator on DmarAtsr scope -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct DmarAtsr { kind: u16, @@ -126,7 +124,7 @@ pub struct DmarAtsr { } /// DMAR Remapping Hardware Static Affinity -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct DmarRhsa { kind: u16, @@ -138,7 +136,7 @@ pub struct DmarRhsa { /// DMAR ACPI Name-space Device Declaration // TODO: Implement iterator on DmarAndd object name -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct DmarAndd { kind: u16, diff --git a/src/acpi/fadt.rs b/src/acpi/fadt.rs index 31dcea2..4ee13e9 100644 --- a/src/acpi/fadt.rs +++ b/src/acpi/fadt.rs @@ -6,7 +6,7 @@ use super::{ACPI_TABLE, SDT_POINTERS, get_sdt, find_sdt, get_sdt_signature, load use crate::paging::ActivePageTable; #[repr(packed)] -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] pub struct Fadt { pub header: Sdt, pub firmware_ctrl: u32, @@ -108,7 +108,7 @@ impl Fadt { }; if let Some(fadt) = fadt { - println!(" FACP: {:X}", fadt.dsdt); + println!(" FACP: {:X}", {fadt.dsdt}); let dsdt_sdt = get_sdt(fadt.dsdt as usize, active_table); diff --git a/src/acpi/hpet.rs b/src/acpi/hpet.rs index 906a7b8..405afa5 100644 --- a/src/acpi/hpet.rs +++ b/src/acpi/hpet.rs @@ -20,7 +20,7 @@ pub struct GenericAddressStructure { } #[repr(packed)] -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] pub struct Hpet { pub header: Sdt, diff --git a/src/acpi/madt.rs b/src/acpi/madt.rs index 6774358..61396b7 100644 --- a/src/acpi/madt.rs +++ b/src/acpi/madt.rs @@ -169,10 +169,8 @@ impl Madt { } } -/// - /// MADT Local APIC -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct MadtLocalApic { /// Processor ID @@ -184,7 +182,7 @@ pub struct MadtLocalApic { } /// MADT I/O APIC -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct MadtIoApic { /// I/O APIC ID @@ -198,7 +196,7 @@ pub struct MadtIoApic { } /// MADT Interrupt Source Override -#[derive(Debug)] +#[derive(Clone, Copy, Debug)] #[repr(packed)] pub struct MadtIntSrcOverride { /// Bus Source diff --git a/src/acpi/mod.rs b/src/acpi/mod.rs index 5f507b2..4764aa4 100644 --- a/src/acpi/mod.rs +++ b/src/acpi/mod.rs @@ -135,7 +135,7 @@ pub unsafe fn init(active_table: &mut ActivePageTable, already_supplied_rsdps: O } println!(":"); - let rxsdt: Box = if let Some(rsdt) = Rsdt::new(rxsdt) { + let rxsdt: Box = if let Some(rsdt) = Rsdt::new(rxsdt) { Box::new(rsdt) } else if let Some(xsdt) = Xsdt::new(rxsdt) { Box::new(xsdt) diff --git a/src/acpi/rsdt.rs b/src/acpi/rsdt.rs index 5cf9460..c2eb8c9 100644 --- a/src/acpi/rsdt.rs +++ b/src/acpi/rsdt.rs @@ -18,7 +18,7 @@ impl Rsdt { } impl Rxsdt for Rsdt { - fn iter(&self) -> Box> { + fn iter(&self) -> Box> { Box::new(RsdtIter { sdt: self.0, i: 0 diff --git a/src/acpi/rxsdt.rs b/src/acpi/rxsdt.rs index 0d91c58..db23880 100644 --- a/src/acpi/rxsdt.rs +++ b/src/acpi/rxsdt.rs @@ -6,7 +6,7 @@ use super::sdt::Sdt; use super::get_sdt; pub trait Rxsdt { - fn iter(&self) -> Box>; + fn iter(&self) -> Box>; fn map_all(&self, active_table: &mut ActivePageTable) { for sdt in self.iter() { diff --git a/src/acpi/xsdt.rs b/src/acpi/xsdt.rs index aea267d..9f0d363 100644 --- a/src/acpi/xsdt.rs +++ b/src/acpi/xsdt.rs @@ -18,7 +18,7 @@ impl Xsdt { } impl Rxsdt for Xsdt { - fn iter(&self) -> Box> { + fn iter(&self) -> Box> { Box::new(XsdtIter { sdt: self.0, i: 0 diff --git a/src/arch/x86_64/device/ioapic.rs b/src/arch/x86_64/device/ioapic.rs index 99f299e..1465ff7 100644 --- a/src/arch/x86_64/device/ioapic.rs +++ b/src/arch/x86_64/device/ioapic.rs @@ -9,7 +9,6 @@ use crate::acpi::madt::{self, Madt, MadtEntry, MadtIoApic, MadtIntSrcOverride}; use crate::arch::interrupt::irq; use crate::memory::Frame; use crate::paging::{ActivePageTable, entry::EntryFlags, Page, PhysicalAddress, VirtualAddress}; -use crate::syscall::io::Mmio; use super::pic; @@ -243,7 +242,7 @@ pub unsafe fn handle_ioapic(active_table: &mut ActivePageTable, madt_ioapic: &'s result.flush(active_table); let ioapic_registers = page.start_address().get() as *const u32; - let mut ioapic = IoApic::new(ioapic_registers, madt_ioapic.gsi_base); + let ioapic = IoApic::new(ioapic_registers, madt_ioapic.gsi_base); assert_eq!(ioapic.regs.lock().id(), madt_ioapic.id, "mismatched ACPI MADT I/O APIC ID, and the ID reported by the I/O APIC"); @@ -283,7 +282,7 @@ pub unsafe fn handle_src_override(src_override: &'static MadtIntSrcOverride) { } pub unsafe fn init(active_table: &mut ActivePageTable) { - let mut bsp_apic_id = x86::cpuid::CpuId::new().get_feature_info().unwrap().initial_local_apic_id(); // TODO + let bsp_apic_id = x86::cpuid::CpuId::new().get_feature_info().unwrap().initial_local_apic_id(); // TODO // search the madt for all IOAPICs. #[cfg(feature = "acpi")] diff --git a/src/arch/x86_64/device/mod.rs b/src/arch/x86_64/device/mod.rs index 0c3f4de..9460f65 100644 --- a/src/arch/x86_64/device/mod.rs +++ b/src/arch/x86_64/device/mod.rs @@ -14,7 +14,7 @@ pub unsafe fn init(active_table: &mut ActivePageTable) { pic::init(); local_apic::init(active_table); } -pub unsafe fn init_after_acpi(active_table: &mut ActivePageTable) { +pub unsafe fn init_after_acpi(_active_table: &mut ActivePageTable) { // this will disable the IOAPIC if needed. //ioapic::init(active_table); } diff --git a/src/arch/x86_64/interrupt/irq.rs b/src/arch/x86_64/interrupt/irq.rs index d604e0d..a01196f 100644 --- a/src/arch/x86_64/interrupt/irq.rs +++ b/src/arch/x86_64/interrupt/irq.rs @@ -18,7 +18,7 @@ pub static PIT_TICKS: AtomicUsize = AtomicUsize::new(0); // reading the status register is not done atomically with reading the data. This is not possible // from userspace, so we do this minimal part of the PS2 driver in the kernel. #[inline(always)] -unsafe fn ps2_interrupt(index: usize) { +unsafe fn ps2_interrupt(_index: usize) { use crate::scheme::serio::serio_input; let data: u8; diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index 8438079..ab7fc39 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -3,7 +3,7 @@ /// It must create the IDT with the correct entries, those entries are /// defined in other files inside of the `arch` module -use core::{mem, slice}; +use core::slice; use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering}; use crate::allocator; diff --git a/src/scheme/acpi.rs b/src/scheme/acpi.rs index 12eb2d7..9ab6de1 100644 --- a/src/scheme/acpi.rs +++ b/src/scheme/acpi.rs @@ -1,4 +1,4 @@ -use core::convert::{TryFrom, TryInto}; +use core::convert::TryInto; use core::fmt::Write; use core::str; use core::sync::atomic::{self, AtomicUsize}; @@ -239,7 +239,7 @@ impl Scheme for AcpiScheme { } Handle::Tables(0) } else { - if (flags & O_DIRECTORY != 0 && flags & O_STAT == 0) { + if flags & O_DIRECTORY != 0 && flags & O_STAT == 0 { return Err(Error::new(ENOTDIR)); } if flags & O_ACCMODE == O_WRONLY || flags & O_ACCMODE == O_RDWR { @@ -448,7 +448,7 @@ impl Scheme for AcpiScheme { } } } - fn write(&self, id: usize, buf: &[u8]) -> Result { + fn write(&self, _id: usize, _buf: &[u8]) -> Result { Err(Error::new(EBADF)) } } diff --git a/src/scheme/irq.rs b/src/scheme/irq.rs index 0c3a844..66e0ee0 100644 --- a/src/scheme/irq.rs +++ b/src/scheme/irq.rs @@ -155,7 +155,7 @@ impl Scheme for IrqScheme { use core::fmt::Write; for cpu_id in &self.cpus { - writeln!(bytes, "cpu-{:02x}", cpu_id); + writeln!(bytes, "cpu-{:02x}", cpu_id).unwrap(); } if bsp_apic_id().is_some() { @@ -186,7 +186,7 @@ impl Scheme for IrqScheme { if Some(u32::from(cpu_id)) == bsp_apic_id() && irq < BASE_IRQ_COUNT { continue; } - writeln!(data, "{}", irq); + writeln!(data, "{}", irq).unwrap(); } Handle::Avail(cpu_id, data.into_bytes(), AtomicUsize::new(0)) diff --git a/src/scheme/serio.rs b/src/scheme/serio.rs index b19f97a..f5b79ed 100644 --- a/src/scheme/serio.rs +++ b/src/scheme/serio.rs @@ -66,9 +66,9 @@ impl Scheme for SerioScheme { } let index = str::from_utf8(path) - .map_err(|err| Error::new(ENOENT))? + .or(Err(Error::new(ENOENT)))? .parse::() - .map_err(|err| Error::new(ENOENT))?; + .or(Err(Error::new(ENOENT)))?; if index >= INPUT.len() { return Err(Error::new(ENOENT)); } diff --git a/src/syscall/process.rs b/src/syscall/process.rs index 086e82d..1920976 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -81,7 +81,7 @@ pub fn clone(flags: CloneFlags, stack_base: usize) -> Result { let ens; let umask; let sigmask; - let mut cpu_id_opt = None; + let cpu_id_opt = None; let arch; let vfork; let mut kfx_opt = None;