Fix several warnings when ktest is enabled

This commit is contained in:
Yuke Peng
2024-08-15 23:26:29 +08:00
committed by Tate, Hongliang Tian
parent 0f9285d72b
commit 49692c2068
6 changed files with 8 additions and 8 deletions

View File

@ -433,7 +433,7 @@ mod test {
let rmdir_empty_dir = root.rmdir(parent_name); let rmdir_empty_dir = root.rmdir(parent_name);
assert!(rmdir_empty_dir.is_ok(), "Fail to remove an empty directory"); assert!(rmdir_empty_dir.is_ok(), "Fail to remove an empty directory");
let parent_inode_again = create_folder(root.clone(), parent_name); let _parent_inode_again = create_folder(root.clone(), parent_name);
create_file(parent_inode.clone(), child_name); create_file(parent_inode.clone(), child_name);
let lookup_result = parent_inode.lookup(child_name); let lookup_result = parent_inode.lookup(child_name);
assert!( assert!(
@ -984,7 +984,7 @@ mod test {
let mut file_names: Vec<String> = (0..file_num).map(|x| x.to_string()).collect(); let mut file_names: Vec<String> = (0..file_num).map(|x| x.to_string()).collect();
file_names.sort(); file_names.sort();
let mut file_inodes: Vec<Arc<dyn Inode>> = Vec::new(); let mut file_inodes: Vec<Arc<dyn Inode>> = Vec::new();
for (file_id, file_name) in file_names.iter().enumerate() { for (_file_id, file_name) in file_names.iter().enumerate() {
let inode = create_file(root.clone(), file_name); let inode = create_file(root.clone(), file_name);
file_inodes.push(inode); file_inodes.push(inode);
} }

View File

@ -5,7 +5,7 @@ use core::{ops::Range, time::Duration};
use time::{OffsetDateTime, PrimitiveDateTime, Time}; use time::{OffsetDateTime, PrimitiveDateTime, Time};
use super::fat::ClusterID; use super::fat::ClusterID;
use crate::{prelude::*, time::clocks::RealTimeClock}; use crate::prelude::*;
pub fn make_hash_index(cluster: ClusterID, offset: u32) -> usize { pub fn make_hash_index(cluster: ClusterID, offset: u32) -> usize {
(cluster as usize) << 32usize | (offset as usize & 0xffffffffusize) (cluster as usize) << 32usize | (offset as usize & 0xffffffffusize)
@ -59,6 +59,8 @@ impl DosTimestamp {
pub fn now() -> Result<Self> { pub fn now() -> Result<Self> {
#[cfg(not(ktest))] #[cfg(not(ktest))]
{ {
use crate::time::clocks::RealTimeClock;
DosTimestamp::from_duration(RealTimeClock::get().read_time()) DosTimestamp::from_duration(RealTimeClock::get().read_time())
} }

View File

@ -127,8 +127,6 @@ pub fn call_ostd_main() -> ! {
} }
#[cfg(ktest)] #[cfg(ktest)]
unsafe { unsafe {
use alloc::boxed::Box;
use crate::task::TaskOptions; use crate::task::TaskOptions;
crate::init(); crate::init();

View File

@ -245,7 +245,7 @@ mod test {
.alloc_contiguous() .alloc_contiguous()
.unwrap(); .unwrap();
let vm_segment_child = vm_segment_parent.range(0..1); let vm_segment_child = vm_segment_parent.range(0..1);
let dma_coherent_parent = DmaCoherent::map(vm_segment_parent, false); let _dma_coherent_parent = DmaCoherent::map(vm_segment_parent, false);
let dma_coherent_child = DmaCoherent::map(vm_segment_child, false); let dma_coherent_child = DmaCoherent::map(vm_segment_child, false);
assert!(dma_coherent_child.is_err()); assert!(dma_coherent_child.is_err());
} }

View File

@ -334,7 +334,7 @@ mod test {
.alloc_contiguous() .alloc_contiguous()
.unwrap(); .unwrap();
let vm_segment_child = vm_segment_parent.range(0..1); let vm_segment_child = vm_segment_parent.range(0..1);
let dma_stream_parent = let _dma_stream_parent =
DmaStream::map(vm_segment_parent, DmaDirection::Bidirectional, false); DmaStream::map(vm_segment_parent, DmaDirection::Bidirectional, false);
let dma_stream_child = DmaStream::map(vm_segment_child, DmaDirection::Bidirectional, false); let dma_stream_child = DmaStream::map(vm_segment_child, DmaDirection::Bidirectional, false);
assert!(dma_stream_child.is_err()); assert!(dma_stream_child.is_err());

View File

@ -120,7 +120,7 @@ fn test_alloc_dealloc() {
let mut contiguous_options = FrameAllocOptions::new(10); let mut contiguous_options = FrameAllocOptions::new(10);
contiguous_options.is_contiguous(true); contiguous_options.is_contiguous(true);
let mut remember_vec = Vec::new(); let mut remember_vec = Vec::new();
for i in 0..10 { for _ in 0..10 {
for i in 0..10 { for i in 0..10 {
let single_frame = single_options.alloc_single().unwrap(); let single_frame = single_options.alloc_single().unwrap();
if i % 3 == 0 { if i % 3 == 0 {