Эх сурвалжийг харах

style: remove unused warnings

greatbridf 3 сар өмнө
parent
commit
eaa6cda7db

+ 2 - 0
src/driver/ahci/control.rs

@@ -8,6 +8,7 @@ use super::{BitsIterator, GHC_IE};
 ///
 /// All reads and writes to this struct is volatile
 ///
+#[allow(dead_code)]
 #[repr(C)]
 struct AdapterControlData {
     capabilities: u32,
@@ -26,6 +27,7 @@ struct AdapterControlData {
     vendor: [u8; 96],
 }
 
+#[allow(dead_code)]
 const CONTROL_CAP: usize = 0;
 const CONTROL_GHC: usize = 1;
 const CONTROL_IS: usize = 2;

+ 1 - 0
src/driver/ahci/mod.rs

@@ -61,6 +61,7 @@ fn vwrite<T: Sized + Copy>(refval: *mut T, val: T) {
     unsafe { refval.write_volatile(val) }
 }
 
+#[allow(dead_code)]
 struct Device {
     control_base: usize,
     control: AdapterControl,

+ 2 - 0
src/driver/ahci/port.rs

@@ -36,6 +36,7 @@ fn spinwait_clear(refval: *const u32, mask: u32) -> KResult<()> {
 ///
 /// All reads and writes to this struct is volatile
 ///
+#[allow(dead_code)]
 #[repr(C)]
 pub struct AdapterPortData {
     pub command_list_base: u64,
@@ -65,6 +66,7 @@ pub struct AdapterPortData {
     vendor: [u32; 4],
 }
 
+#[allow(dead_code)]
 #[derive(Debug, PartialEq, Eq, Clone, Copy)]
 enum SlotState {
     Idle,

+ 1 - 0
src/driver/serial.rs

@@ -11,6 +11,7 @@ use crate::{
 
 use super::Port8;
 
+#[allow(dead_code)]
 struct Serial {
     id: u32,
     name: Arc<str>,

+ 0 - 2
src/elf.rs

@@ -6,8 +6,6 @@ use crate::{
     kernel::{
         constants::ENOEXEC,
         mem::{FileMapping, MMList, Mapping, Permission, VAddr},
-        task::Thread,
-        user::{dataflow::CheckedUserPointer, UserPointerMut},
         vfs::dentry::Dentry,
     },
     prelude::*,

+ 1 - 0
src/fs/fat32.rs

@@ -208,6 +208,7 @@ impl<'fat> Iterator for ClusterIterator<'fat> {
     }
 }
 
+#[allow(dead_code)]
 #[derive(Clone)]
 enum FatInode {
     File(Arc<FileInode>),

+ 1 - 0
src/fs/fat32/dir.rs

@@ -39,6 +39,7 @@ impl RawDirEntry {
     const ATTR_SYSTEM: u8 = 0x04;
     const ATTR_VOLUME_ID: u8 = 0x08;
     const ATTR_DIRECTORY: u8 = 0x10;
+    #[allow(dead_code)]
     const ATTR_ARCHIVE: u8 = 0x20;
 
     const RESERVED_FILENAME_LOWERCASE: u8 = 0x08;

+ 1 - 4
src/fs/fat32/file.rs

@@ -1,7 +1,4 @@
-use crate::{
-    kernel::mem::{phys::PhysPtr, Page},
-    KResult,
-};
+use crate::{kernel::mem::Page, KResult};
 
 use super::{ClusterIterator, FatFs};
 

+ 4 - 1
src/fs/procfs.rs

@@ -30,6 +30,7 @@ fn split_len_offset(data: &[u8], len: usize, offset: usize) -> Option<&[u8]> {
     real_data.split_at_checked(offset).map(|(_, data)| data)
 }
 
+#[allow(dead_code)]
 pub trait ProcFsFile: Send + Sync {
     fn can_read(&self) -> bool {
         false
@@ -116,7 +117,7 @@ impl Inode for FileInode {
 }
 
 define_struct_inode! {
-    struct DirInode {
+    pub struct DirInode {
         entries: Locked<Vec<(Arc<[u8]>, ProcFsNode)>, ()>,
     }
 }
@@ -196,6 +197,7 @@ lazy_static! {
 
 struct ProcFsMountCreator;
 
+#[allow(dead_code)]
 impl ProcFsMountCreator {
     pub fn get() -> Arc<ProcFs> {
         GLOBAL_PROCFS.clone()
@@ -247,6 +249,7 @@ pub fn creat(
     Ok(ProcFsNode::File(inode))
 }
 
+#[allow(dead_code)]
 pub fn mkdir(parent: &ProcFsNode, name: &[u8]) -> KResult<ProcFsNode> {
     let parent = match parent {
         ProcFsNode::File(_) => return Err(ENOTDIR),

+ 1 - 0
src/intrusive_list.rs

@@ -5,6 +5,7 @@ pub struct Link {
     next: Option<NonNull<Link>>,
 }
 
+#[allow(dead_code)]
 impl Link {
     pub const fn new() -> Self {
         Self {

+ 1 - 0
src/kernel.rs

@@ -16,6 +16,7 @@ pub mod smp;
 mod chardev;
 mod terminal;
 
+#[allow(unused_imports)]
 pub use chardev::{CharDevice, CharDeviceType, VirtualCharDevice};
 pub use console::Console;
 pub use terminal::{Terminal, TerminalDevice};

+ 1 - 0
src/kernel/chardev.rs

@@ -29,6 +29,7 @@ pub enum CharDeviceType {
     Virtual(Box<dyn VirtualCharDevice>),
 }
 
+#[allow(dead_code)]
 pub struct CharDevice {
     name: Arc<str>,
     device: CharDeviceType,

+ 1 - 0
src/kernel/constants.rs

@@ -23,6 +23,7 @@ pub const ENXIO: u32 = 6;
 pub const ENOEXEC: u32 = 8;
 pub const ENOSYS: u32 = 38;
 
+#[allow(dead_code)]
 pub const S_IFIFO: u32 = 0o010000;
 pub const S_IFCHR: u32 = 0o020000;
 pub const S_IFDIR: u32 = 0o040000;

+ 2 - 2
src/kernel/mem.rs

@@ -7,9 +7,9 @@ mod mm_list;
 mod page_alloc;
 mod page_table;
 
+#[allow(unused_imports)]
 pub use address::{PAddr, VAddr, VRange, PFN, VPN};
 pub(self) use mm_area::MMArea;
-pub use mm_list::{handle_page_fault, FileMapping, MMList, Mapping, PageFaultError, Permission};
-pub(self) use page_alloc::{alloc_page, alloc_pages, create_pages, free_pages, mark_present};
+pub use mm_list::{handle_page_fault, FileMapping, MMList, Mapping, Permission};
 pub(self) use page_table::{PageTable, PTE};
 pub use paging::{Page, PageBuffer};

+ 3 - 3
src/kernel/mem/address.rs

@@ -1,7 +1,7 @@
 use core::{
     cmp::Ordering,
     fmt::{self, Debug, Formatter},
-    ops::{Add, Sub, RangeBounds},
+    ops::{Add, RangeBounds, Sub},
 };
 
 #[repr(C)]
@@ -38,7 +38,7 @@ impl From<PFN> for usize {
 
 impl From<VAddr> for usize {
     fn from(v: VAddr) -> Self {
-       v.0
+        v.0
     }
 }
 
@@ -72,7 +72,6 @@ impl From<usize> for VPN {
     }
 }
 
-
 impl From<VPN> for VAddr {
     fn from(v: VPN) -> Self {
         Self(v.0 << PAGE_SIZE_BITS)
@@ -353,6 +352,7 @@ impl VRange {
         VRange { start, end }
     }
 
+    #[allow(dead_code)]
     pub fn is_overlapped(&self, other: &Self) -> bool {
         self == other
     }

+ 3 - 2
src/kernel/mem/mm_area.rs

@@ -1,6 +1,6 @@
-use bindings::PA_MMAP;
+use crate::prelude::*;
 
-use crate::{kernel::task::Signal, prelude::*};
+use bindings::PA_MMAP;
 
 use core::{borrow::Borrow, cell::UnsafeCell, cmp::Ordering};
 
@@ -44,6 +44,7 @@ impl MMArea {
         *self.range_borrow()
     }
 
+    #[allow(dead_code)]
     pub fn len(&self) -> usize {
         self.range_borrow().len()
     }

+ 1 - 1
src/kernel/mem/mm_list.rs

@@ -11,7 +11,7 @@ use crate::kernel::vfs::dentry::Dentry;
 
 use super::{MMArea, Page, PageTable, VAddr, VRange};
 
-pub use page_fault::{handle_page_fault, PageFaultError};
+pub use page_fault::handle_page_fault;
 
 #[derive(Debug, Clone)]
 pub struct FileMapping {

+ 0 - 2
src/kernel/mem/mm_list/page_fault.rs

@@ -1,8 +1,6 @@
 use arch::InterruptContext;
-use bindings::{PA_A, PA_ANON, PA_COW, PA_MMAP, PA_P, PA_RW};
 use bitflags::bitflags;
 
-use crate::kernel::mem::paging::{Page, PageBuffer};
 use crate::kernel::mem::{Mapping, VRange};
 use crate::kernel::task::{ProcessList, Signal, Thread};
 use crate::prelude::*;

+ 6 - 0
src/kernel/mem/page_table.rs

@@ -14,10 +14,13 @@ use super::{MMArea, Permission};
 const PA_P: usize = 0x001;
 const PA_RW: usize = 0x002;
 const PA_US: usize = 0x004;
+#[allow(dead_code)]
 const PA_PWT: usize = 0x008;
+#[allow(dead_code)]
 const PA_PCD: usize = 0x010;
 const PA_A: usize = 0x020;
 const PA_D: usize = 0x040;
+#[allow(dead_code)]
 const PA_PS: usize = 0x080;
 const PA_G: usize = 0x100;
 const PA_COW: usize = 0x200;
@@ -35,6 +38,7 @@ pub struct PageTable {
     page: Page,
 }
 
+#[allow(dead_code)]
 pub struct PTEIterator<'lt, const KERNEL: bool> {
     count: usize,
     i4: u16,
@@ -88,6 +92,7 @@ impl PTE {
         self.0 = pfn | attributes;
     }
 
+    #[allow(dead_code)]
     pub fn set_pfn(&mut self, pfn: usize) {
         self.set(pfn, self.attributes())
     }
@@ -228,6 +233,7 @@ impl PageTable {
         PTEIterator::new(&self.page, range.start().floor(), range.end().ceil())
     }
 
+    #[allow(dead_code)]
     pub fn iter_kernel(&self, range: VRange) -> KResult<PTEIterator<'_, true>> {
         PTEIterator::new(&self.page, range.start().floor(), range.end().ceil())
     }

+ 1 - 0
src/kernel/mem/phys.rs

@@ -3,6 +3,7 @@ use core::fmt;
 pub trait PhysPtr {
     fn as_ptr<T>(&self) -> *mut T;
 
+    #[allow(dead_code)]
     fn as_ref<'lifetime, T>(&self) -> &'lifetime T {
         unsafe { &*(self.as_ptr()) }
     }

+ 3 - 0
src/kernel/syscall.rs

@@ -181,6 +181,7 @@ use super::task::Thread;
 
 pub(self) use {arg_register, define_syscall32, format_expand, register_syscall, syscall32_call};
 
+#[allow(dead_code)]
 pub(self) struct SyscallHandler {
     handler: fn(&mut InterruptContext, &mut ExtendedContext) -> usize,
     name: &'static str,
@@ -192,6 +193,7 @@ pub(self) fn register_syscall_handler(
     name: &'static str,
 ) {
     // SAFETY: `SYSCALL_HANDLERS` is never modified after initialization.
+    #[allow(static_mut_refs)]
     let syscall = unsafe { SYSCALL_HANDLERS.get_mut(no) }.unwrap();
     assert!(
         syscall.replace(SyscallHandler { handler, name }).is_none(),
@@ -218,6 +220,7 @@ pub fn handle_syscall32(
     ext_ctx: &mut ExtendedContext,
 ) {
     // SAFETY: `SYSCALL_HANDLERS` are never modified after initialization.
+    #[allow(static_mut_refs)]
     let syscall = unsafe { SYSCALL_HANDLERS.get(no) }.and_then(Option::as_ref);
 
     match syscall {

+ 2 - 0
src/kernel/syscall/sysinfo.rs

@@ -49,12 +49,14 @@ fn do_newuname(buffer: *mut NewUTSName) -> KResult<()> {
     buffer.write(uname)
 }
 
+#[allow(dead_code)]
 #[derive(Clone, Copy)]
 struct TimeVal {
     sec: u64,
     usec: u64,
 }
 
+#[allow(dead_code)]
 #[derive(Clone, Copy)]
 struct TimeSpec {
     sec: u64,

+ 1 - 0
src/kernel/task/kstack.rs

@@ -4,6 +4,7 @@ use crate::kernel::{
 };
 use arch::InterruptContext;
 
+#[allow(dead_code)]
 pub struct KernelStack {
     pages: Page,
     bottom: usize,

+ 8 - 0
src/kernel/terminal.rs

@@ -28,16 +28,24 @@ const VQUIT: usize = 1;
 const VERASE: usize = 2;
 const VKILL: usize = 3;
 const VEOF: usize = 4;
+#[allow(dead_code)]
 const VTIME: usize = 5;
 const VMIN: usize = 6;
+#[allow(dead_code)]
 const VSWTC: usize = 7;
+#[allow(dead_code)]
 const VSTART: usize = 8;
+#[allow(dead_code)]
 const VSTOP: usize = 9;
 const VSUSP: usize = 10;
 const VEOL: usize = 11;
+#[allow(dead_code)]
 const VREPRINT: usize = 12;
+#[allow(dead_code)]
 const VDISCARD: usize = 13;
+#[allow(dead_code)]
 const VWERASE: usize = 14;
+#[allow(dead_code)]
 const VLNEXT: usize = 15;
 const VEOL2: usize = 16;
 

+ 1 - 0
src/kernel/timer.rs

@@ -13,6 +13,7 @@ impl Ticks {
         self.0 / 100
     }
 
+    #[allow(dead_code)]
     pub fn in_msecs(&self) -> usize {
         self.0 * 10
     }

+ 1 - 0
src/kernel/user.rs

@@ -1,5 +1,6 @@
 pub mod dataflow;
 
+#[allow(unused_imports)]
 pub use dataflow::{UserBuffer, UserString};
 
 pub type UserPointer<'a, T> = dataflow::UserPointer<'a, T, true>;

+ 1 - 0
src/kernel/vfs/dentry.rs

@@ -60,6 +60,7 @@ impl core::fmt::Debug for Dentry {
 }
 
 const D_DIRECTORY: u64 = 1;
+#[allow(dead_code)]
 const D_MOUNTPOINT: u64 = 2;
 const D_SYMLINK: u64 = 4;
 const D_REGULAR: u64 = 8;

+ 1 - 0
src/kernel/vfs/filearray.rs

@@ -70,6 +70,7 @@ impl FileArray {
         })
     }
 
+    #[allow(dead_code)]
     pub fn new_shared(other: &Arc<Self>) -> Arc<Self> {
         other.clone()
     }

+ 1 - 0
src/kernel/vfs/mod.rs

@@ -71,6 +71,7 @@ impl FsContext {
         })
     }
 
+    #[allow(dead_code)]
     pub fn new_shared(other: &Arc<Self>) -> Arc<Self> {
         other.clone()
     }

+ 6 - 1
src/kernel/vfs/mount.rs

@@ -40,6 +40,7 @@ lazy_static! {
 
 static mut ROOTFS: Option<Arc<Dentry>> = None;
 
+#[allow(dead_code)]
 pub struct Mount {
     vfs: Arc<dyn Vfs>,
     root: Arc<Dentry>,
@@ -79,6 +80,7 @@ pub fn register_filesystem(fstype: &str, creator: Arc<dyn MountCreator>) -> KRes
     }
 }
 
+#[allow(dead_code)]
 struct MountPointData {
     mount: Mount,
     source: String,
@@ -198,6 +200,9 @@ pub fn init_vfs() -> KResult<()> {
 
 impl Dentry {
     pub fn kernel_root_dentry() -> Arc<Dentry> {
-        unsafe { ROOTFS.as_ref().cloned().unwrap() }
+        #[allow(static_mut_refs)]
+        unsafe {
+            ROOTFS.as_ref().cloned().unwrap()
+        }
     }
 }

+ 1 - 0
src/kernel/vfs/vfs.rs

@@ -2,6 +2,7 @@ use crate::prelude::*;
 
 use super::DevId;
 
+#[allow(dead_code)]
 pub trait Vfs: Send + Sync + AsAny {
     fn io_blksize(&self) -> usize;
     fn fs_devid(&self) -> DevId;

+ 3 - 5
src/net/netdev.rs

@@ -20,6 +20,7 @@ pub enum LinkSpeed {
 
 pub type Mac = [u8; 6];
 
+#[allow(dead_code)]
 pub trait Netdev: Send {
     fn up(&mut self) -> Result<(), u32>;
     fn send(&mut self, data: &[u8]) -> Result<(), u32>;
@@ -54,8 +55,7 @@ impl Ord for dyn Netdev {
 
 lazy_static! {
     static ref NETDEVS_ID: Spin<u32> = Spin::new(0);
-    static ref NETDEVS: Spin<BTreeMap<u32, Arc<Mutex<dyn Netdev>>>> =
-        Spin::new(BTreeMap::new());
+    static ref NETDEVS: Spin<BTreeMap<u32, Arc<Mutex<dyn Netdev>>>> = Spin::new(BTreeMap::new());
 }
 
 pub fn alloc_id() -> u32 {
@@ -66,9 +66,7 @@ pub fn alloc_id() -> u32 {
     retval
 }
 
-pub fn register_netdev(
-    netdev: impl Netdev + 'static,
-) -> Result<Arc<Mutex<dyn Netdev>>, u32> {
+pub fn register_netdev(netdev: impl Netdev + 'static) -> Result<Arc<Mutex<dyn Netdev>>, u32> {
     let devid = netdev.id();
 
     let mut netdevs = NETDEVS.lock();

+ 1 - 0
src/path.rs

@@ -10,6 +10,7 @@ pub struct PathIterator<'lt> {
     rem: &'lt [u8],
 }
 
+#[allow(dead_code)]
 impl<'lt> Path<'lt> {
     pub fn new(all: &'lt [u8]) -> KResult<Self> {
         if all.is_empty() {

+ 3 - 0
src/prelude.rs

@@ -32,6 +32,7 @@ pub(crate) use alloc::{boxed::Box, string::String, vec, vec::Vec};
 pub(crate) use core::{any::Any, fmt::Write, marker::PhantomData, str};
 use core::{mem::ManuallyDrop, ops::Deref};
 
+#[allow(unused_imports)]
 pub use crate::sync::{Locked, Mutex, RwSemaphore, Semaphore, Spin};
 
 pub struct BorrowedArc<'lt, T: ?Sized> {
@@ -48,6 +49,7 @@ impl<'lt, T: ?Sized> BorrowedArc<'lt, T> {
         }
     }
 
+    #[allow(dead_code)]
     pub fn new(ptr: &'lt *const T) -> Self {
         assert!(!ptr.is_null());
         Self {
@@ -81,6 +83,7 @@ impl<'lt, T: ?Sized> AsRef<Arc<T>> for BorrowedArc<'lt, T> {
     }
 }
 
+#[allow(dead_code)]
 pub trait AsAny: Send + Sync {
     fn as_any(&self) -> &dyn Any;
     fn as_any_mut(&mut self) -> &mut dyn Any;

+ 1 - 0
src/rcu.rs

@@ -13,6 +13,7 @@ use alloc::sync::Arc;
 
 use lazy_static::lazy_static;
 
+#[allow(dead_code)]
 pub struct RCUReadGuard<'data, T: 'data> {
     value: T,
     guard: Guard<'data, (), RwSemaphoreStrategy, false>,