Skip to content
This repository was archived by the owner on Jul 17, 2025. It is now read-only.

Commit fc25186

Browse files
committed
Fix clippy warnings.
1 parent 561668b commit fc25186

File tree

15 files changed

+24
-36
lines changed

15 files changed

+24
-36
lines changed

kernel/src/arch/unix/process.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ impl crate::nrproc::ProcessManager for ArchProcessManagement {
111111
ArrayVec<Arc<Replica<'static, NrProcess<Self::Process>>>, MAX_PROCESSES>,
112112
MAX_NUMA_NODES,
113113
> {
114-
&*super::process::PROCESS_TABLE
114+
&super::process::PROCESS_TABLE
115115
}
116116
}
117117

@@ -227,13 +227,13 @@ impl Process for UnixProcess {
227227
}
228228

229229
fn get_executor(&mut self, _for_region: atopology::NodeId) -> Result<Box<Self::E>, KError> {
230-
Ok(Box::new(UnixThread::default()))
230+
Ok(Box::default())
231231
}
232232

233233
fn allocate_fd(&mut self) -> Option<(u64, &mut FileDescriptorEntry)> {
234234
if let Some(fid) = self.fds.iter().position(|fd| fd.is_none()) {
235235
self.fds[fid] = Some(Default::default());
236-
Some((fid as u64, self.fds[fid as usize].as_mut().unwrap()))
236+
Some((fid as u64, self.fds[fid].as_mut().unwrap()))
237237
} else {
238238
None
239239
}

kernel/src/arch/x86_64/vspace/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use core::ops::Bound::*;
77
use fallible_collections::btree::BTreeMap;
88
use lazy_static::lazy_static;
99
use spin::Mutex;
10-
use x86::current::paging::{PDFlags, PDPTFlags, PTFlags, PML4Flags, PML4Entry};
10+
use x86::current::paging::{PDFlags, PDPTFlags, PML4Entry, PML4Flags, PTFlags};
1111

1212
mod debug;
1313
pub mod page_table; /* TODO(encapsulation): This should be a private module but we break encapsulation in a few places */
@@ -18,7 +18,7 @@ use crate::error::KError;
1818
use crate::memory::{detmem::DA, vspace::*};
1919
use crate::memory::{Frame, PAddr, VAddr};
2020

21-
use page_table::{PT_LAYOUT, PageTable};
21+
use page_table::{PageTable, PT_LAYOUT};
2222

2323
lazy_static! {
2424
/// A handle to the initial kernel address space (created for us by the

kernel/src/environment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use crate::arch::{MAX_CORES, MAX_NUMA_NODES};
99
/// The core id of the current core (hardware thread).
1010
#[thread_local]
1111
pub(crate) static CORE_ID: Lazy<usize> =
12-
Lazy::new(|| atopology::MACHINE_TOPOLOGY.current_thread().id as usize);
12+
Lazy::new(|| atopology::MACHINE_TOPOLOGY.current_thread().id);
1313

1414
/// The NUMA node id of the current core (hardware thread).
1515
#[thread_local]

kernel/src/fs/cnrfs.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -590,7 +590,7 @@ impl Dispatch for MlnrKernelNode {
590590
.read()
591591
.get(&pid)
592592
.ok_or(KError::NoProcessFoundForPid)?;
593-
let _is_deleted = self.fs.delete(&filename)?;
593+
self.fs.delete(&filename)?;
594594
Ok(MlnrNodeResult::FileDeleted)
595595
}
596596

@@ -600,7 +600,7 @@ impl Dispatch for MlnrKernelNode {
600600
.read()
601601
.get(&pid)
602602
.ok_or(KError::NoProcessFoundForPid)?;
603-
let _is_renamed = self.fs.rename(&oldname, newname)?;
603+
self.fs.rename(&oldname, newname)?;
604604
Ok(MlnrNodeResult::FileRenamed)
605605
}
606606

@@ -610,7 +610,7 @@ impl Dispatch for MlnrKernelNode {
610610
.read()
611611
.get(&pid)
612612
.ok_or(KError::NoProcessFoundForPid)?;
613-
let _is_created = self.fs.mkdir(filename, modes)?;
613+
self.fs.mkdir(filename, modes)?;
614614
Ok(MlnrNodeResult::DirCreated)
615615
}
616616
}

kernel/src/fs/fd.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,7 @@ impl FileDescriptorTable {
7171
pub(crate) fn allocate_fd(&mut self) -> Option<(FileDescriptor, &mut FileDescriptorEntry)> {
7272
if let Some(fid) = self.table.iter().position(|fd| fd.is_none()) {
7373
self.table[fid] = Some(Default::default());
74-
Some((
75-
FileDescriptor::new(fid),
76-
self.table[fid as usize].as_mut().unwrap(),
77-
))
74+
Some((FileDescriptor::new(fid), self.table[fid].as_mut().unwrap()))
7875
} else {
7976
None
8077
}

kernel/src/fs/mnode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ impl MemNode {
106106
}
107107
// Return error if start-offset is greater than or equal to new-offset OR
108108
// new offset is greater than the file size.
109-
if offset >= new_offset || new_offset > self.get_file_size() as usize {
109+
if offset >= new_offset || new_offset > self.get_file_size() {
110110
return Err(KError::InvalidOffset);
111111
}
112112

kernel/src/graphviz.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'a> Id<'a> {
154154
}
155155

156156
pub(crate) fn as_slice(&'a self) -> &'a str {
157-
&*self.name
157+
&self.name
158158
}
159159

160160
pub(crate) fn name(self) -> Cow<'a, str> {
@@ -280,7 +280,7 @@ impl<'a> LabelText<'a> {
280280
Esc(s) => s,
281281
Label(s) => {
282282
if s.contains('\\') {
283-
(&*s).escape_default().to_string().into()
283+
(*s).escape_default().to_string().into()
284284
} else {
285285
s
286286
}

kernel/src/memory/global.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ impl GlobalMemory {
6969
// How many NUMA nodes are there in the system
7070
let max_affinity: usize = memory
7171
.iter()
72-
.map(|f| f.affinity as usize)
72+
.map(|f| f.affinity)
7373
.max()
7474
.expect("Need at least some frames")
7575
+ 1;

kernel/src/memory/mod.rs

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -264,19 +264,11 @@ impl KernelAllocator {
264264
let (gmanager, mut mem_manager, affinity) = match mem_type {
265265
MemType::Mem => {
266266
let affinity = { pcm.physical_memory.borrow().affinity };
267-
(
268-
pcm.gmanager.unwrap(),
269-
pcm.try_mem_manager()?,
270-
affinity as usize,
271-
)
267+
(pcm.gmanager.unwrap(), pcm.try_mem_manager()?, affinity)
272268
}
273269
MemType::PMem => {
274270
let affinity = { pcm.persistent_memory.borrow().affinity };
275-
(
276-
pcm.pgmanager.unwrap(),
277-
pcm.pmem_manager(),
278-
affinity as usize,
279-
)
271+
(pcm.pgmanager.unwrap(), pcm.pmem_manager(), affinity)
280272
}
281273
};
282274
let mut ncache = gmanager.node_caches[affinity].lock();
@@ -496,8 +488,7 @@ unsafe impl GlobalAlloc for KernelAllocator {
496488
Err(_e) => match pcm.gmanager {
497489
// Try adding frame to ncache.
498490
Some(gmanager) => {
499-
let mut ncache =
500-
gmanager.node_caches[frame.affinity as usize].lock();
491+
let mut ncache = gmanager.node_caches[frame.affinity].lock();
501492
ncache
502493
.release_base_page(frame)
503494
.expect("Can't deallocate frame");

kernel/src/memory/per_core.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ impl PerCoreMemory {
137137
debug_assert_eq!(arena.affinity, node);
138138

139139
core::mem::swap(&mut arena, current_arena);
140-
arenas[arena.affinity as usize].replace(arena);
140+
arenas[arena.affinity].replace(arena);
141141

142142
Ok(())
143143
} else {

0 commit comments

Comments
 (0)