From 5d55d4eb87f2472a018378b06d302ef689331303 Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Fri, 29 Jul 2022 18:33:54 -0600 Subject: [PATCH] Fix warnings --- src/acpi/hpet.rs | 8 ++++---- src/acpi/madt.rs | 2 +- src/acpi/mod.rs | 2 +- src/acpi/rsdp.rs | 10 +++++----- src/arch/x86_64/device/cpu.rs | 2 +- src/arch/x86_64/device/hpet.rs | 2 +- src/arch/x86_64/idt.rs | 4 ++-- src/arch/x86_64/rmm.rs | 7 +++---- src/arch/x86_64/start.rs | 14 +++++++------- src/context/memory.rs | 6 +++--- src/debugger.rs | 2 +- src/devices/graphical_debug/mod.rs | 2 -- src/lib.rs | 2 ++ src/scheme/proc.rs | 6 +++--- src/syscall/futex.rs | 2 +- src/syscall/process.rs | 4 ++-- 16 files changed, 37 insertions(+), 38 deletions(-) diff --git a/src/acpi/hpet.rs b/src/acpi/hpet.rs index 18e9ee0..241bdaa 100644 --- a/src/acpi/hpet.rs +++ b/src/acpi/hpet.rs @@ -11,10 +11,10 @@ use super::{ACPI_TABLE, find_sdt}; #[repr(packed)] #[derive(Clone, Copy, Debug, Default)] pub struct GenericAddressStructure { - address_space: u8, - bit_width: u8, - bit_offset: u8, - access_size: u8, + _address_space: u8, + _bit_width: u8, + _bit_offset: u8, + _access_size: u8, pub address: u64, } diff --git a/src/acpi/madt.rs b/src/acpi/madt.rs index 1f8d8f0..0593144 100644 --- a/src/acpi/madt.rs +++ b/src/acpi/madt.rs @@ -212,7 +212,7 @@ pub struct MadtIoApic { /// I/O APIC ID pub id: u8, /// reserved - reserved: u8, + _reserved: u8, /// I/O APIC address pub address: u32, /// Global system interrupt base diff --git a/src/acpi/mod.rs b/src/acpi/mod.rs index 370d058..d1f91a4 100644 --- a/src/acpi/mod.rs +++ b/src/acpi/mod.rs @@ -50,7 +50,7 @@ pub fn get_sdt(sdt_address: usize, mapper: &mut KernelMapper) -> &'static Sdt { const SDT_SIZE: usize = core::mem::size_of::(); map_linearly(physaddr, SDT_SIZE, mapper); - sdt = unsafe { &*(RmmA::phys_to_virt(physaddr).data() as *const Sdt) }; + sdt = &*(RmmA::phys_to_virt(physaddr).data() as *const Sdt); map_linearly(physaddr.add(SDT_SIZE), sdt.length as usize - SDT_SIZE, mapper); } diff --git a/src/acpi/rsdp.rs b/src/acpi/rsdp.rs index 3d08186..6239d88 100644 --- a/src/acpi/rsdp.rs +++ b/src/acpi/rsdp.rs @@ -9,14 +9,14 @@ use crate::paging::{KernelMapper, Page, PageFlags, PhysicalAddress, VirtualAddre #[repr(packed)] pub struct RSDP { signature: [u8; 8], - checksum: u8, - oemid: [u8; 6], + _checksum: u8, + _oemid: [u8; 6], revision: u8, rsdt_address: u32, - length: u32, + _length: u32, xsdt_address: u64, - extended_checksum: u8, - reserved: [u8; 3] + _extended_checksum: u8, + _reserved: [u8; 3] } impl RSDP { diff --git a/src/arch/x86_64/device/cpu.rs b/src/arch/x86_64/device/cpu.rs index 3f3b358..589713c 100644 --- a/src/arch/x86_64/device/cpu.rs +++ b/src/arch/x86_64/device/cpu.rs @@ -8,7 +8,7 @@ pub fn cpu_info(w: &mut W) -> Result { let cpuid = CpuId::new(); if let Some(info) = cpuid.get_vendor_info() { - writeln!(w, "Vendor: {}", info.as_string())?; + writeln!(w, "Vendor: {}", info.as_str())?; } if let Some(brand) = cpuid.get_processor_brand_string() { diff --git a/src/arch/x86_64/device/hpet.rs b/src/arch/x86_64/device/hpet.rs index 1222779..1ab3ce9 100644 --- a/src/arch/x86_64/device/hpet.rs +++ b/src/arch/x86_64/device/hpet.rs @@ -69,7 +69,7 @@ pub unsafe fn init(hpet: &mut Hpet) -> bool { } pub unsafe fn debug(hpet: &mut Hpet) { - println!("HPET @ {:#x}", hpet.base_address.address); + println!("HPET @ {:#x}", { hpet.base_address.address }); let capability = hpet.base_address.read_u64(CAPABILITY_OFFSET); { diff --git a/src/arch/x86_64/idt.rs b/src/arch/x86_64/idt.rs index 3e74885..3cc8db0 100644 --- a/src/arch/x86_64/idt.rs +++ b/src/arch/x86_64/idt.rs @@ -293,7 +293,7 @@ pub struct IdtEntry { attribute: u8, offsetm: u16, offseth: u32, - zero2: u32 + _zero2: u32 } impl IdtEntry { @@ -305,7 +305,7 @@ impl IdtEntry { attribute: 0, offsetm: 0, offseth: 0, - zero2: 0 + _zero2: 0 } } diff --git a/src/arch/x86_64/rmm.rs b/src/arch/x86_64/rmm.rs index d158b79..63ef67a 100644 --- a/src/arch/x86_64/rmm.rs +++ b/src/arch/x86_64/rmm.rs @@ -140,8 +140,8 @@ unsafe fn inner( } let mut identity_map = |base, size_aligned| { - // Map stack with identity mapping - for i in 0..size / A::PAGE_SIZE { + // Map with identity mapping + for i in 0..size_aligned / A::PAGE_SIZE { let phys = PhysicalAddress::new(base + i * A::PAGE_SIZE); let virt = A::phys_to_virt(phys); let flags = page_flags::(virt); @@ -154,7 +154,6 @@ unsafe fn inner( } }; - identity_map(stack_base, stack_size_aligned); identity_map(env_base, env_size_aligned); identity_map(acpi_base, acpi_size_aligned); @@ -365,7 +364,7 @@ pub unsafe fn init( // Copy memory map from bootloader location, and page align it let mut area_i = 0; for bootloader_area in bootloader_areas.iter() { - if bootloader_area.kind != BootloaderMemoryKind::Free { + if { bootloader_area.kind } != BootloaderMemoryKind::Free { // Not a free area continue; } diff --git a/src/arch/x86_64/start.rs b/src/arch/x86_64/start.rs index 8394617..d5bc159 100644 --- a/src/arch/x86_64/start.rs +++ b/src/arch/x86_64/start.rs @@ -106,13 +106,13 @@ pub unsafe extern fn kstart(args_ptr: *const KernelArgs) -> ! { }); info!("Redox OS starting..."); - info!("Kernel: {:X}:{:X}", args.kernel_base, args.kernel_base + args.kernel_size); - info!("Stack: {:X}:{:X}", args.stack_base, args.stack_base + args.stack_size); - info!("Env: {:X}:{:X}", args.env_base, args.env_base + args.env_size); - info!("RSDPs: {:X}:{:X}", args.acpi_rsdps_base, args.acpi_rsdps_base + args.acpi_rsdps_size); - info!("Areas: {:X}:{:X}", args.areas_base, args.areas_base + args.areas_size); - info!("Bootstrap: {:X}:{:X}", args.bootstrap_base, args.bootstrap_base + args.bootstrap_size); - info!("Bootstrap entry point: {:X}", args.bootstrap_entry); + info!("Kernel: {:X}:{:X}", { args.kernel_base }, { args.kernel_base } + { args.kernel_size }); + info!("Stack: {:X}:{:X}", { args.stack_base }, { args.stack_base } + { args.stack_size }); + info!("Env: {:X}:{:X}", { args.env_base }, { args.env_base } + { args.env_size }); + info!("RSDPs: {:X}:{:X}", { args.acpi_rsdps_base }, { args.acpi_rsdps_base } + { args.acpi_rsdps_size }); + info!("Areas: {:X}:{:X}", { args.areas_base }, { args.areas_base } + { args.areas_size }); + info!("Bootstrap: {:X}:{:X}", { args.bootstrap_base }, { args.bootstrap_base } + { args.bootstrap_size }); + info!("Bootstrap entry point: {:X}", { args.bootstrap_entry }); // Set up GDT before paging gdt::init(); diff --git a/src/context/memory.rs b/src/context/memory.rs index 1d3f964..a26052b 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -281,7 +281,7 @@ impl UserGrants { // MAP_FIXED/MAP_FIXED_NOREPLACE. // TODO: Allow explicitly allocating guard pages? - let (hole_start, hole_size) = self.holes.iter() + let (hole_start, _hole_size) = self.holes.iter() .skip_while(|(hole_offset, hole_size)| hole_offset.data() + **hole_size <= min) .find(|(hole_offset, hole_size)| { let avail_size = if hole_offset.data() <= min && min <= hole_offset.data() + **hole_size { @@ -313,7 +313,7 @@ impl UserGrants { } - if let Some(grant) = self.conflicts(requested).next() { + if let Some(_grant) = self.conflicts(requested).next() { // ... but it already exists if flags.contains(MapFlags::MAP_FIXED_NOREPLACE) { @@ -684,7 +684,7 @@ impl Grant { for index in 0..page_count { let src_page = src_base.next_by(index); - let (address, entry_flags) = if unmap { + let (address, _entry_flags) = if unmap { let (entry, entry_flags, flush) = unsafe { src_mapper.unmap_phys(src_page.start_address(), true).expect("grant references unmapped memory") }; src_flusher.consume(flush); diff --git a/src/debugger.rs b/src/debugger.rs index 030babd..4c644b7 100644 --- a/src/debugger.rs +++ b/src/debugger.rs @@ -47,7 +47,7 @@ pub unsafe fn debugger(target_id: Option) { } } } - if let Some(regs) = unsafe { crate::ptrace::regs_for(&context) } { + if let Some(regs) = crate::ptrace::regs_for(&context) { println!("regs:"); regs.dump(); diff --git a/src/devices/graphical_debug/mod.rs b/src/devices/graphical_debug/mod.rs index 0bf2dcb..4b1e3ee 100644 --- a/src/devices/graphical_debug/mod.rs +++ b/src/devices/graphical_debug/mod.rs @@ -45,8 +45,6 @@ pub fn init(env: &[u8]) { println!("Framebuffer {}x{} at {:X}", width, height, physbaseptr); { - let size = width * height * 4; - let virtbaseptr = physbaseptr + crate::PHYS_OFFSET; let display = Display::new(width, height, virtbaseptr as *mut u32); diff --git a/src/lib.rs b/src/lib.rs index 2308c9d..91db058 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -3,6 +3,8 @@ //! The Redox OS Kernel is a microkernel that supports `x86_64` systems and //! provides Unix-like syscalls for primarily Rust applications +//TODO: fix the need to generate references to packed fields +#![allow(unaligned_references)] // Useful for adding comments about different branches #![allow(clippy::if_same_then_else)] // Useful in the syscall function diff --git a/src/scheme/proc.rs b/src/scheme/proc.rs index 59eeb84..4c13ed5 100644 --- a/src/scheme/proc.rs +++ b/src/scheme/proc.rs @@ -1,6 +1,6 @@ use crate::{ arch::paging::{mapper::InactiveFlusher, Page, VirtualAddress}, - context::{self, Context, ContextId, Status, file::{FileDescription, FileDescriptor}, memory::{AddrSpace, Grant, new_addrspace, map_flags, page_flags, Region}}, + context::{self, Context, ContextId, Status, file::{FileDescription, FileDescriptor}, memory::{AddrSpace, Grant, new_addrspace, map_flags, Region}}, memory::PAGE_SIZE, ptrace, scheme::{self, FileHandle, KernelScheme, SchemeId}, @@ -65,7 +65,7 @@ where } callback(&mut context) } -fn try_stop_context(pid: ContextId, mut callback: F) -> Result +fn try_stop_context(pid: ContextId, callback: F) -> Result where F: FnOnce(&mut Context) -> Result, { @@ -1222,7 +1222,7 @@ impl KernelScheme for ProcScheme { if let Some(before) = before { src_addr_space.grants.insert(before); } if let Some(after) = after { src_addr_space.grants.insert(after); } - dst_addr_space.mmap(requested_dst_page, grant_page_count, map.flags, |dst_page, flags, dst_mapper, dst_flusher| Ok(Grant::transfer(middle, dst_page, src_mapper, dst_mapper, InactiveFlusher::new(), dst_flusher)?))? + dst_addr_space.mmap(requested_dst_page, grant_page_count, map.flags, |dst_page, _flags, dst_mapper, dst_flusher| Ok(Grant::transfer(middle, dst_page, src_mapper, dst_mapper, InactiveFlusher::new(), dst_flusher)?))? } else { dst_addr_space.mmap(requested_dst_page, grant_page_count, map.flags, |dst_page, flags, dst_mapper, flusher| Ok(Grant::borrow(Page::containing_address(src_grant_region.start_address()), dst_page, grant_page_count, flags, None, src_mapper, dst_mapper, flusher)?))? }; diff --git a/src/syscall/futex.rs b/src/syscall/futex.rs index 5838ec3..28bb069 100644 --- a/src/syscall/futex.rs +++ b/src/syscall/futex.rs @@ -163,7 +163,7 @@ pub fn futex(addr: usize, op: usize, val: usize, val2: usize, addr2: usize) -> R Ok(woken) }, FUTEX_REQUEUE => { - let (addr2_physaddr, _) = unsafe { + let (addr2_physaddr, _) = { let addr2_virt = VirtualAddress::new(addr2); if !crate::CurrentRmmArch::virt_is_valid(addr2_virt) { diff --git a/src/syscall/process.rs b/src/syscall/process.rs index ae4055d..a8cf746 100644 --- a/src/syscall/process.rs +++ b/src/syscall/process.rs @@ -420,8 +420,8 @@ fn reap(pid: ContextId) -> Result { let mut contexts = context::contexts_mut(); let context_lock = contexts.remove(pid).ok_or(Error::new(ESRCH))?; { - let mut context = context_lock.write(); - context = empty(&context_lock, context, true); + let context = context_lock.write(); + empty(&context_lock, context, true); } drop(context_lock);