mirror of
https://github.com/DragonOS-Community/DragonOS.git
synced 2025-06-20 10:06:31 +00:00
修复内核的clippy检查报错 (#637)
修复内核的clippy检查报错 --------- Co-authored-by: Samuel Dai <947309196@qq.com> Co-authored-by: Donkey Kane <109840258+xiaolin2004@users.noreply.github.com> Co-authored-by: themildwind <107623059+themildwind@users.noreply.github.com> Co-authored-by: GnoCiYeH <heyicong@dragonos.org> Co-authored-by: MemoryShore <105195940+MemoryShore@users.noreply.github.com> Co-authored-by: 曾俊 <110876916+ZZJJWarth@users.noreply.github.com> Co-authored-by: sun5etop <146408999+sun5etop@users.noreply.github.com> Co-authored-by: hmt <114841534+1037827920@users.noreply.github.com> Co-authored-by: laokengwt <143977175+laokengwt@users.noreply.github.com> Co-authored-by: TTaq <103996388+TTaq@users.noreply.github.com> Co-authored-by: Jomo <2512364506@qq.com> Co-authored-by: Samuel Dai <samuka007@qq.com> Co-authored-by: sspphh <112558065+sspphh@users.noreply.github.com>
This commit is contained in:
@ -340,26 +340,26 @@ impl X86_64MMArch {
|
||||
let mb2_count = mb2_count as usize;
|
||||
let mut areas_count = 0usize;
|
||||
let mut total_mem_size = 0usize;
|
||||
for i in 0..mb2_count {
|
||||
for info_entry in mb2_mem_info.iter().take(mb2_count) {
|
||||
// Only use the memory area if its type is 1 (RAM)
|
||||
if mb2_mem_info[i].type_ == 1 {
|
||||
if info_entry.type_ == 1 {
|
||||
// Skip the memory area if its len is 0
|
||||
if mb2_mem_info[i].len == 0 {
|
||||
if info_entry.len == 0 {
|
||||
continue;
|
||||
}
|
||||
|
||||
total_mem_size += mb2_mem_info[i].len as usize;
|
||||
total_mem_size += info_entry.len as usize;
|
||||
|
||||
mem_block_manager()
|
||||
.add_block(
|
||||
PhysAddr::new(mb2_mem_info[i].addr as usize),
|
||||
mb2_mem_info[i].len as usize,
|
||||
PhysAddr::new(info_entry.addr as usize),
|
||||
info_entry.len as usize,
|
||||
)
|
||||
.unwrap_or_else(|e| {
|
||||
kwarn!(
|
||||
"Failed to add memory block: base={:#x}, size={:#x}, error={:?}",
|
||||
mb2_mem_info[i].addr,
|
||||
mb2_mem_info[i].len,
|
||||
info_entry.addr,
|
||||
info_entry.len,
|
||||
e
|
||||
);
|
||||
});
|
||||
@ -521,7 +521,7 @@ pub fn test_buddy() {
|
||||
let mut random_size = 0u64;
|
||||
unsafe { x86::random::rdrand64(&mut random_size) };
|
||||
// 一次最多申请4M
|
||||
random_size = random_size % (1024 * 4096);
|
||||
random_size %= 1024 * 4096;
|
||||
if random_size == 0 {
|
||||
continue;
|
||||
}
|
||||
@ -551,19 +551,19 @@ pub fn test_buddy() {
|
||||
allocated_frame_count.data() * MMArch::PAGE_SIZE,
|
||||
)
|
||||
};
|
||||
for i in 0..slice.len() {
|
||||
slice[i] = ((i + unsafe { rdtsc() } as usize) % 256) as u8;
|
||||
for (i, item) in slice.iter_mut().enumerate() {
|
||||
*item = ((i + unsafe { rdtsc() } as usize) % 256) as u8;
|
||||
}
|
||||
|
||||
// 随机释放一个内存块
|
||||
if v.len() > 0 {
|
||||
if !v.is_empty() {
|
||||
let mut random_index = 0u64;
|
||||
unsafe { x86::random::rdrand64(&mut random_index) };
|
||||
// 70%概率释放
|
||||
if random_index % 10 > 7 {
|
||||
continue;
|
||||
}
|
||||
random_index = random_index % v.len() as u64;
|
||||
random_index %= v.len() as u64;
|
||||
let random_index = random_index as usize;
|
||||
let (paddr, allocated_frame_count) = v.remove(random_index);
|
||||
assert!(addr_set.remove(&paddr));
|
||||
@ -622,7 +622,7 @@ impl FrameAllocator for LockedFrameAllocator {
|
||||
|
||||
/// 获取内核地址默认的页面标志
|
||||
pub unsafe fn kernel_page_flags<A: MemoryManagementArch>(virt: VirtAddr) -> PageFlags<A> {
|
||||
let info: X86_64MMBootstrapInfo = BOOTSTRAP_MM_INFO.clone().unwrap();
|
||||
let info: X86_64MMBootstrapInfo = BOOTSTRAP_MM_INFO.unwrap();
|
||||
|
||||
if virt.data() >= info.kernel_code_start && virt.data() < info.kernel_code_end {
|
||||
// Remap kernel code execute
|
||||
@ -676,7 +676,7 @@ impl LowAddressRemapping {
|
||||
let (_, _, flusher) = mapper
|
||||
.unmap_phys(vaddr, true)
|
||||
.expect("Failed to unmap frame");
|
||||
if flush == false {
|
||||
if !flush {
|
||||
flusher.ignore();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user