From eaf51ccb24008995f85c9d7b25eb3d0684356378 Mon Sep 17 00:00:00 2001 From: Zhang Junyang Date: Wed, 19 Jun 2024 08:22:41 +0000 Subject: [PATCH] Fix multiple dead code problems --- kernel/aster-nix/src/fs/exfat/dentry.rs | 25 ++++++++++--------- .../process/program_loader/elf/elf_file.rs | 7 ++++++ kernel/aster-nix/src/syscall/clock_gettime.rs | 1 + kernel/aster-nix/src/syscall/open.rs | 1 + kernel/aster-nix/src/syscall/utimens.rs | 1 + osdk/src/config/manifest.rs | 1 + 6 files changed, 24 insertions(+), 12 deletions(-) diff --git a/kernel/aster-nix/src/fs/exfat/dentry.rs b/kernel/aster-nix/src/fs/exfat/dentry.rs index ba42781da..15085c8b7 100644 --- a/kernel/aster-nix/src/fs/exfat/dentry.rs +++ b/kernel/aster-nix/src/fs/exfat/dentry.rs @@ -1,8 +1,5 @@ // SPDX-License-Identifier: MPL-2.0 -#![allow(dead_code)] -#![allow(unused_variables)] - use core::{fmt::Display, ops::Range}; use aster_frame::mm::VmIo; @@ -58,18 +55,25 @@ impl ExfatDentry { const EXFAT_UNUSED: u8 = 0x00; +#[allow(dead_code)] const EXFAT_INVAL: u8 = 0x80; const EXFAT_BITMAP: u8 = 0x81; +#[allow(dead_code)] const EXFAT_UPCASE: u8 = 0x82; +#[allow(dead_code)] const EXFAT_VOLUME: u8 = 0x83; const EXFAT_FILE: u8 = 0x85; +#[allow(dead_code)] const EXFAT_GUID: u8 = 0xA0; +#[allow(dead_code)] const EXFAT_PADDING: u8 = 0xA1; +#[allow(dead_code)] const EXFAT_ACLTAB: u8 = 0xA2; const EXFAT_STREAM: u8 = 0xC0; const EXFAT_NAME: u8 = 0xC1; +#[allow(dead_code)] const EXFAT_ACL: u8 = 0xC2; const EXFAT_VENDOR_EXT: u8 = 0xE0; @@ -201,6 +205,7 @@ impl ExfatDentrySet { /// Stream dentry index. const ES_IDX_STREAM: usize = 1; /// Name dentry index. + #[allow(dead_code)] const ES_IDX_FIRST_FILENAME: usize = 2; pub(super) fn new(dentries: Vec, should_checksum_match: bool) -> Result { @@ -216,7 +221,7 @@ impl ExfatDentrySet { fs: Arc, name: &str, inode_type: InodeType, - mode: InodeMode, + _mode: InodeMode, ) -> Result { let attrs = { if inode_type == InodeType::Dir { @@ -298,7 +303,7 @@ impl ExfatDentrySet { let mut dentries = Vec::::with_capacity(num_secondary + 1); dentries.push(ExfatDentry::File(*file_dentry)); - for i in 0..num_secondary { + for _i in 0..num_secondary { let dentry_result = iter.next(); if dentry_result.is_none() { return_errno!(Errno::ENOENT); @@ -477,7 +482,7 @@ impl Iterator for ExfatDentryIterator { let read_result = self.page_cache.read_bytes(byte_start, &mut dentry_buf); - if let Err(e) = read_result { + if let Err(_e) = read_result { return Some(Err(Error::with_message( Errno::EIO, "Unable to read dentry from page cache.", @@ -656,7 +661,7 @@ impl ExfatName { fn push_char( &mut self, value: UTF16Char, - upcase_table: Arc>, + _upcase_table: Arc>, ) -> Result<()> { if !Self::is_valid_char(value) { return_errno_with_message!(Errno::EINVAL, "not a valid char") @@ -682,10 +687,6 @@ impl ExfatName { } } - pub fn len(&self) -> usize { - self.0.len() - } - pub fn checksum(&self) -> u16 { let bytes = self .0 @@ -696,7 +697,7 @@ impl ExfatName { calc_checksum_16(&bytes, EMPTY_RANGE, 0) } - pub fn from_str(name: &str, upcase_table: Arc>) -> Result { + pub fn from_str(name: &str, _upcase_table: Arc>) -> Result { let name = ExfatName(name.encode_utf16().collect()); // upcase_table.lock().transform_to_upcase(&mut name.0)?; name.verify()?; diff --git a/kernel/aster-nix/src/process/program_loader/elf/elf_file.rs b/kernel/aster-nix/src/process/program_loader/elf/elf_file.rs index 24e923d95..c4f819931 100644 --- a/kernel/aster-nix/src/process/program_loader/elf/elf_file.rs +++ b/kernel/aster-nix/src/process/program_loader/elf/elf_file.rs @@ -165,16 +165,23 @@ impl ElfHeader { pub struct HeaderPt2_64 { pub type_: Type_, pub machine: Machine_, + #[allow(dead_code)] pub version: u32, pub entry_point: u64, pub ph_offset: u64, + #[allow(dead_code)] pub sh_offset: u64, + #[allow(dead_code)] pub flags: u32, + #[allow(dead_code)] pub header_size: u16, pub ph_entry_size: u16, pub ph_count: u16, + #[allow(dead_code)] pub sh_entry_size: u16, + #[allow(dead_code)] pub sh_count: u16, + #[allow(dead_code)] pub sh_str_index: u16, } diff --git a/kernel/aster-nix/src/syscall/clock_gettime.rs b/kernel/aster-nix/src/syscall/clock_gettime.rs index 6283fdf89..52bd6947a 100644 --- a/kernel/aster-nix/src/syscall/clock_gettime.rs +++ b/kernel/aster-nix/src/syscall/clock_gettime.rs @@ -63,6 +63,7 @@ pub enum ClockId { pub enum DynamicClockIdInfo { Pid(u32, DynamicClockType), Tid(u32, DynamicClockType), + #[allow(dead_code)] Fd(u32), } diff --git a/kernel/aster-nix/src/syscall/open.rs b/kernel/aster-nix/src/syscall/open.rs index 2e1ab598d..533dccc28 100644 --- a/kernel/aster-nix/src/syscall/open.rs +++ b/kernel/aster-nix/src/syscall/open.rs @@ -57,6 +57,7 @@ pub fn sys_creat(path_addr: Vaddr, mode: u16) -> Result { } /// File for output busybox ash log. +#[allow(dead_code)] struct BusyBoxTraceFile; impl FileLike for BusyBoxTraceFile { diff --git a/kernel/aster-nix/src/syscall/utimens.rs b/kernel/aster-nix/src/syscall/utimens.rs index 8e26e82e1..87b8f1c23 100644 --- a/kernel/aster-nix/src/syscall/utimens.rs +++ b/kernel/aster-nix/src/syscall/utimens.rs @@ -83,6 +83,7 @@ pub fn sys_utimensat( trait UtimeExt { fn utime_now() -> Self; + #[allow(dead_code)] fn utime_omit() -> Self; fn is_utime_now(&self) -> bool; fn is_utime_omit(&self) -> bool; diff --git a/osdk/src/config/manifest.rs b/osdk/src/config/manifest.rs index dabb186b4..2cb750e63 100644 --- a/osdk/src/config/manifest.rs +++ b/osdk/src/config/manifest.rs @@ -32,6 +32,7 @@ pub enum ProjectType { /// The osdk manifest from configuration file `OSDK.toml`. #[derive(Debug, Clone)] pub struct TomlManifest { + #[allow(dead_code)] pub project_type: Option, pub default_scheme: Scheme, pub map: HashMap,