Fix many clippy lints
This commit is contained in:
committed by
Mathew John Roberts
parent
b7456d5bcc
commit
ee1260363c
@@ -1,3 +1,5 @@
|
||||
#![allow(clippy::unwrap_used)] // the build script can panic
|
||||
|
||||
use std::{env, path::Path, process::Command};
|
||||
use toml::Table;
|
||||
|
||||
@@ -94,5 +96,5 @@ fn main() {
|
||||
_ => (),
|
||||
}
|
||||
|
||||
let _ = parse_kconfig(&*arch_str);
|
||||
let _ = parse_kconfig(&arch_str);
|
||||
}
|
||||
|
||||
@@ -20,13 +20,7 @@ struct BuddyEntry<A> {
|
||||
|
||||
impl<A> Clone for BuddyEntry<A> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
base: self.base,
|
||||
size: self.size,
|
||||
skip: self.skip,
|
||||
used: self.used,
|
||||
phantom: PhantomData,
|
||||
}
|
||||
*self
|
||||
}
|
||||
}
|
||||
impl<A> Copy for BuddyEntry<A> {}
|
||||
@@ -69,6 +63,7 @@ impl<A: Arch> BuddyEntry<A> {
|
||||
}
|
||||
}
|
||||
|
||||
#[expect(clippy::unit_arg)]
|
||||
unsafe fn set_usage(&self, page: usize, usage: BuddyUsage) -> Option<()> {
|
||||
unsafe {
|
||||
let addr = self.usage_addr(page)?;
|
||||
@@ -104,7 +99,7 @@ impl<A: Arch> BuddyAllocator<A> {
|
||||
// by the bump allocator
|
||||
let mut offset = bump_allocator.offset();
|
||||
for old_area in bump_allocator.areas().iter() {
|
||||
let mut area = old_area.clone();
|
||||
let mut area = *old_area;
|
||||
if offset >= area.size {
|
||||
offset -= area.size;
|
||||
continue;
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
#![expect(clippy::identity_op)]
|
||||
|
||||
// Page attribute table is indexed by PAT(7) PCD(4) PWT(3)
|
||||
pub(crate) const _PAT_WB: usize = (0b0 << 7) + (0b00 << 3);
|
||||
pub(crate) const _PAT_WT: usize = (0b0 << 7) + (0b01 << 3);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#![no_std]
|
||||
#![allow(clippy::new_without_default)]
|
||||
|
||||
pub use crate::{allocator::*, arch::*, page::*};
|
||||
|
||||
@@ -38,6 +39,7 @@ impl PhysicalAddress {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[expect(clippy::should_implement_trait)]
|
||||
#[inline(always)]
|
||||
pub fn add(self, offset: usize) -> Self {
|
||||
Self(self.0 + offset)
|
||||
@@ -66,6 +68,7 @@ impl VirtualAddress {
|
||||
self.0
|
||||
}
|
||||
|
||||
#[expect(clippy::should_implement_trait)]
|
||||
#[inline(always)]
|
||||
pub fn add(self, offset: usize) -> Self {
|
||||
Self(self.0 + offset)
|
||||
|
||||
@@ -24,6 +24,7 @@ impl<A: Arch> PageFlush<A> {
|
||||
A::invalidate(self.virt);
|
||||
}
|
||||
|
||||
#[expect(clippy::forget_non_drop)]
|
||||
pub unsafe fn ignore(self) {
|
||||
mem::forget(self);
|
||||
}
|
||||
|
||||
@@ -84,9 +84,7 @@ impl<A: Arch, F> PageMapper<A, F> {
|
||||
let old_entry = p1.entry(i)?;
|
||||
let old_phys = old_entry.address().ok()?;
|
||||
let old_flags = old_entry.flags();
|
||||
let Some((new_phys, new_flags)) = f(old_phys, old_flags) else {
|
||||
return None;
|
||||
};
|
||||
let (new_phys, new_flags) = f(old_phys, old_flags)?;
|
||||
// TODO: Higher-level PageEntry::new interface?
|
||||
let new_entry = PageEntry::new(new_phys.data(), new_flags.data());
|
||||
p1.set_entry(i, new_entry);
|
||||
|
||||
@@ -73,7 +73,8 @@ pub(super) fn init(madt: Madt) {
|
||||
allocate_p2frame(4)
|
||||
.expect("no more frames in acpi stack_start")
|
||||
.base(),
|
||||
).data();
|
||||
)
|
||||
.data();
|
||||
let stack_end = stack_start + (PAGE_SIZE << 4);
|
||||
|
||||
let pcr_ptr = crate::arch::gdt::allocate_and_init_pcr(cpu_id, stack_end);
|
||||
@@ -97,6 +98,7 @@ pub(super) fn init(madt: Madt) {
|
||||
ap_ready.write(0);
|
||||
ap_args_ptr.write(&args as *const _ as u64);
|
||||
ap_page_table.write(page_table_physaddr as u64);
|
||||
#[expect(clippy::fn_to_numeric_cast)]
|
||||
ap_code.write(kstart_ap as u64);
|
||||
|
||||
// TODO: Is this necessary (this fence)?
|
||||
|
||||
+3
-5
@@ -17,12 +17,10 @@ pub struct Rsdp {
|
||||
|
||||
impl Rsdp {
|
||||
pub unsafe fn get_rsdp(already_supplied_rsdp: Option<*const u8>) -> Option<Rsdp> {
|
||||
if let Some(rsdp_ptr) = already_supplied_rsdp {
|
||||
already_supplied_rsdp.map(|rsdp_ptr| {
|
||||
// TODO: Validate
|
||||
Some(unsafe { *(rsdp_ptr as *const Rsdp) })
|
||||
} else {
|
||||
None
|
||||
}
|
||||
unsafe { *(rsdp_ptr as *const Rsdp) }
|
||||
})
|
||||
}
|
||||
|
||||
/// Get the RSDT or XSDT address
|
||||
|
||||
@@ -39,9 +39,16 @@ pub struct AltReloc {
|
||||
pub unsafe fn early_init(bsp: bool) {
|
||||
unsafe {
|
||||
let relocs_offset = crate::kernel_executable_offsets::__altrelocs_start();
|
||||
// __altrelocs_end > __altrelocs_start so this cannot overflow
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
let relocs_size = crate::kernel_executable_offsets::__altrelocs_end() - relocs_offset;
|
||||
|
||||
assert_eq!(relocs_size % size_of::<AltReloc>(), 0);
|
||||
// AltReloc is not a ZST so the modulo and division will never panic
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
{
|
||||
assert_eq!(relocs_size % size_of::<AltReloc>(), 0)
|
||||
}
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
let relocs = core::slice::from_raw_parts(
|
||||
relocs_offset as *const AltReloc,
|
||||
relocs_size / size_of::<AltReloc>(),
|
||||
@@ -106,6 +113,8 @@ pub unsafe fn early_init(bsp: bool) {
|
||||
})
|
||||
.expect("CPUID said AVX was supported but there's no state info");
|
||||
|
||||
// 16 * size_of::<u128>() is well below usize::MAX
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
if state.size() as usize != 16 * core::mem::size_of::<u128>() {
|
||||
warn!("Unusual AVX state size {}", state.size());
|
||||
}
|
||||
@@ -218,6 +227,11 @@ unsafe fn overwrite(relocs: &[AltReloc], enable: KcpuFeatures) {
|
||||
dst.copy_from_slice(altcode);
|
||||
|
||||
for chunk in dst_nops.chunks_mut(NOPS_TABLE.len()) {
|
||||
// `chunk.len() - 1` is always in bounds because we are chunking by
|
||||
// `NOPS_TABLE.len()`
|
||||
#[expect(clippy::indexing_slicing)]
|
||||
// `chunk.len()` will never be 0
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
chunk.copy_from_slice(NOPS_TABLE[chunk.len() - 1]);
|
||||
}
|
||||
trace!("feature {} new {:x?} altcode {:x?}", name, code, altcode);
|
||||
@@ -228,6 +242,11 @@ unsafe fn overwrite(relocs: &[AltReloc], enable: KcpuFeatures) {
|
||||
// Not strictly necessary, but reduces the number of instructions using longer nop
|
||||
// instructions.
|
||||
for chunk in padded.chunks_mut(NOPS_TABLE.len()) {
|
||||
// `chunk.len() - 1` is always in bounds because we are chunking by
|
||||
// `NOPS_TABLE.len()`
|
||||
#[expect(clippy::indexing_slicing)]
|
||||
// `chunk.len()` will never be 0
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
chunk.copy_from_slice(NOPS_TABLE[chunk.len() - 1]);
|
||||
}
|
||||
|
||||
@@ -282,6 +301,8 @@ mod xsave {
|
||||
pub fn kfx_size() -> usize {
|
||||
#[cfg(not(cpu_feature_never = "xsave"))]
|
||||
{
|
||||
// This wont overflow
|
||||
#[expect(clippy::arithmetic_side_effects)]
|
||||
match xsave::info() {
|
||||
Some(info) => FXSAVE_SIZE + XSAVE_HEADER_SIZE + info.xsave_size as usize,
|
||||
None => FXSAVE_SIZE,
|
||||
|
||||
@@ -133,7 +133,7 @@ impl InterruptStack {
|
||||
pub fn trace(&self) {
|
||||
self.dump();
|
||||
unsafe {
|
||||
panic::user_stack_trace(&self);
|
||||
panic::user_stack_trace(self);
|
||||
panic::stack_trace();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -282,6 +282,8 @@ fn init_pcr(pcr: &mut ProcessorControlRegion, stack_end: usize) {
|
||||
pcr.gdt[GDT_TSS].set_offset(tss_lo);
|
||||
pcr.gdt[GDT_TSS].set_limit(size_of::<TaskStateSegment>() as u32 + IOBITMAP_SIZE);
|
||||
|
||||
// GDT is aligned to 8 bytes
|
||||
#[expect(clippy::cast_ptr_alignment)]
|
||||
unsafe {
|
||||
(&mut pcr.gdt[GDT_TSS_HIGH] as *mut GdtEntry)
|
||||
.cast::<u32>()
|
||||
|
||||
@@ -91,6 +91,12 @@ impl Context {
|
||||
|
||||
const INT_REGS_SIZE: usize = core::mem::size_of::<InterruptStack>();
|
||||
|
||||
// Kstack::initial_top() is always at least 8 byte aligned. assertion to be safe
|
||||
debug_assert!(
|
||||
(stack_top as usize).is_multiple_of(8),
|
||||
"Kstack not 8 byte aligned"
|
||||
);
|
||||
#[expect(clippy::cast_ptr_alignment)]
|
||||
unsafe {
|
||||
if userspace_allowed {
|
||||
// Zero-initialize InterruptStack registers.
|
||||
|
||||
@@ -2450,6 +2450,8 @@ pub fn try_correcting_page_tables(
|
||||
Ok(())
|
||||
}
|
||||
|
||||
// TODO: maybe refactor the return type into a struct/typedef?
|
||||
#[expect(clippy::type_complexity)]
|
||||
/// XXX: This require passing L3 addr_space_guard.
|
||||
/// Caller must ensure there's no other lock being held at this point.
|
||||
/// Caller also need to provide clean token for the new AddrSpace.
|
||||
|
||||
+11
-11
@@ -216,19 +216,19 @@ pub fn switch(token: &mut CleanLockToken) -> SwitchResult {
|
||||
if switch_context_opt.is_none() {
|
||||
let mut this_contexts = contexts_mut(token.token());
|
||||
let (this_contexts, mut token) = this_contexts.token_split();
|
||||
if let Some(mut free_contexts) = free_contexts_try(token.token()) {
|
||||
if let Some(context) = free_contexts.pop_last() {
|
||||
// Check if we can run this free context immediately
|
||||
if let Some(next_context) = context.upgrade() {
|
||||
let mut next_context_guard = unsafe { next_context.write_arc() };
|
||||
if let UpdateResult::CanSwitch =
|
||||
unsafe { update_runnable(&mut next_context_guard, cpu_id, switch_time) }
|
||||
{
|
||||
switch_context_opt = Some(next_context_guard);
|
||||
}
|
||||
if let Some(mut free_contexts) = free_contexts_try(token.token())
|
||||
&& let Some(context) = free_contexts.pop_last()
|
||||
{
|
||||
// Check if we can run this free context immediately
|
||||
if let Some(next_context) = context.upgrade() {
|
||||
let mut next_context_guard = unsafe { next_context.write_arc() };
|
||||
if let UpdateResult::CanSwitch =
|
||||
unsafe { update_runnable(&mut next_context_guard, cpu_id, switch_time) }
|
||||
{
|
||||
switch_context_opt = Some(next_context_guard);
|
||||
}
|
||||
this_contexts.insert(context);
|
||||
}
|
||||
this_contexts.insert(context);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ bitflags! {
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[repr(packed(4))]
|
||||
#[repr(C, packed(4))]
|
||||
pub struct SerialPort<T: Io> {
|
||||
/// Data register, read to receive, write to send
|
||||
data: T,
|
||||
|
||||
+1
-1
@@ -218,7 +218,7 @@ pub fn diag_uart_range<'a>(dtb: &'a Fdt) -> Option<(PhysicalAddress, usize, bool
|
||||
.and_then(NodeProperty::as_str)?;
|
||||
|
||||
let mut reg = uart_node.reg()?;
|
||||
let memory = reg.nth(0)?;
|
||||
let memory = reg.next()?;
|
||||
let address = get_mmio_address(dtb, &uart_node, &memory)?;
|
||||
|
||||
Some((
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#![feature(btree_cursors)]
|
||||
#![cfg_attr(not(test), no_std)]
|
||||
#![cfg_attr(not(test), no_main)]
|
||||
#![allow(clippy::new_without_default)]
|
||||
|
||||
#[macro_use]
|
||||
extern crate alloc;
|
||||
|
||||
|
||||
+2
-6
@@ -102,8 +102,7 @@ impl RingBuffer {
|
||||
}))
|
||||
}
|
||||
}
|
||||
const NULL: AtomicPtr<RingBuffer> = AtomicPtr::new(core::ptr::null_mut());
|
||||
pub static BUFS: [AtomicPtr<RingBuffer>; 4] = [NULL; 4];
|
||||
pub static BUFS: [AtomicPtr<RingBuffer>; 4] = [const { AtomicPtr::new(core::ptr::null_mut()) }; 4];
|
||||
|
||||
pub const PROFILE_TOGGLEABLE: bool = true;
|
||||
pub static IS_PROFILING: AtomicBool = AtomicBool::new(false);
|
||||
@@ -138,10 +137,7 @@ pub fn drain_buffer(cpu_num: LogicalCpuId, buf: UserSliceWo) -> Result<usize> {
|
||||
return Ok(0);
|
||||
};
|
||||
let byte_slices = src.peek().map(|words| {
|
||||
core::slice::from_raw_parts(
|
||||
words.as_ptr().cast::<u8>(),
|
||||
words.len() * size_of::<usize>(),
|
||||
)
|
||||
core::slice::from_raw_parts(words.as_ptr().cast::<u8>(), size_of_val(words))
|
||||
});
|
||||
|
||||
let copied_1 = buf.copy_common_bytes_from_slice(byte_slices[0])?;
|
||||
|
||||
+5
-5
@@ -43,14 +43,14 @@ pub struct DebugScheme;
|
||||
|
||||
#[repr(usize)]
|
||||
enum SpecialFds {
|
||||
Default = !0,
|
||||
NoPreserve = !0 - 1,
|
||||
DisableGraphicalDebug = !0 - 2,
|
||||
Default = -1isize as usize,
|
||||
NoPreserve = -2isize as usize,
|
||||
DisableGraphicalDebug = -3isize as usize,
|
||||
|
||||
#[cfg(feature = "profiling")]
|
||||
CtlProfiling = !0 - 3,
|
||||
CtlProfiling = -4isize as usize,
|
||||
|
||||
SchemeRoot = !0 - 4,
|
||||
SchemeRoot = -5isize as usize,
|
||||
}
|
||||
|
||||
impl KernelScheme for DebugScheme {
|
||||
|
||||
+2
-2
@@ -42,7 +42,7 @@ impl DtbScheme {
|
||||
DATA.call_once(|| {
|
||||
data_init = true;
|
||||
|
||||
Box::from(DTB_BINARY.get().map(|&d| d).unwrap_or(&[]))
|
||||
Box::from(DTB_BINARY.get().copied().unwrap_or(&[]))
|
||||
});
|
||||
|
||||
if !data_init {
|
||||
@@ -176,7 +176,7 @@ impl KernelScheme for DtbScheme {
|
||||
st_mode: MODE_FILE,
|
||||
st_uid: 0,
|
||||
st_gid: 0,
|
||||
st_size: data.len().try_into().unwrap_or(u64::max_value()),
|
||||
st_size: data.len().try_into().unwrap_or(u64::MAX),
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
+5
-6
@@ -7,7 +7,7 @@ use core::{
|
||||
sync::atomic::{AtomicUsize, Ordering},
|
||||
};
|
||||
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use alloc::{borrow::ToOwned, string::String, vec::Vec};
|
||||
|
||||
use hashbrown::{hash_map::DefaultHashBuilder, HashMap};
|
||||
use smallvec::SmallVec;
|
||||
@@ -428,10 +428,9 @@ impl crate::scheme::KernelScheme for IrqScheme {
|
||||
if let &Handle::Irq {
|
||||
irq: handle_irq, ..
|
||||
} = handle
|
||||
&& handle_irq > BASE_IRQ_COUNT
|
||||
{
|
||||
if handle_irq > BASE_IRQ_COUNT {
|
||||
set_reserved(LogicalCpuId::BSP, irq_to_vector(handle_irq), false);
|
||||
}
|
||||
set_reserved(LogicalCpuId::BSP, irq_to_vector(handle_irq), false);
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
@@ -527,10 +526,10 @@ impl crate::scheme::KernelScheme for IrqScheme {
|
||||
|
||||
let scheme_path = match handle {
|
||||
Handle::Irq { irq, .. } => format!("irq:{}", irq),
|
||||
Handle::Bsp => format!("irq:bsp"),
|
||||
Handle::Bsp => "irq:bsp".to_owned(),
|
||||
Handle::Avail(cpu_id) => format!("irq:cpu-{:2x}", cpu_id.get()),
|
||||
Handle::Phandle(phandle, _) => format!("irq:phandle-{}", phandle),
|
||||
Handle::TopLevel => format!("irq:"),
|
||||
Handle::TopLevel => "irq:".to_owned(),
|
||||
_ => return Err(Error::new(EBADF)),
|
||||
}
|
||||
.into_bytes();
|
||||
|
||||
+4
-7
@@ -226,13 +226,10 @@ impl SchemeList {
|
||||
let scheme = handles().write(token.token()).remove(&SchemeId(id));
|
||||
|
||||
assert!(scheme.is_some());
|
||||
match scheme {
|
||||
Some(Handle::Scheme(KernelSchemes::User(user))) => {
|
||||
if let Some(user) = Arc::into_inner(user.inner) {
|
||||
user.into_drop(token);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
if let Some(Handle::Scheme(KernelSchemes::User(user))) = scheme
|
||||
&& let Some(user) = Arc::into_inner(user.inner)
|
||||
{
|
||||
user.into_drop(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+9
-11
@@ -136,18 +136,16 @@ impl KernelScheme for PipeScheme {
|
||||
};
|
||||
|
||||
if can_remove {
|
||||
match { PIPES.write(token.token()).remove(&key) } {
|
||||
Some(Handle::Pipe(pipe)) => {
|
||||
if let Some(pipe) = Arc::into_inner(pipe) {
|
||||
{
|
||||
pipe.read_condition.into_drop(token);
|
||||
}
|
||||
{
|
||||
pipe.write_condition.into_drop(token);
|
||||
}
|
||||
}
|
||||
let handle = PIPES.write(token.token()).remove(&key);
|
||||
if let Some(Handle::Pipe(pipe)) = handle
|
||||
&& let Some(pipe) = Arc::into_inner(pipe)
|
||||
{
|
||||
{
|
||||
pipe.read_condition.into_drop(token);
|
||||
}
|
||||
{
|
||||
pipe.write_condition.into_drop(token);
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -85,8 +85,8 @@ fn try_stop_context<T>(
|
||||
"process can't have been restarted, we stopped it!"
|
||||
);
|
||||
|
||||
let (mut context, token) = context.token_split();
|
||||
let ret = callback(&mut context, token);
|
||||
let (context, token) = context.token_split();
|
||||
let ret = callback(context, token);
|
||||
|
||||
context.status = prev_status;
|
||||
|
||||
@@ -514,7 +514,7 @@ impl KernelScheme for ProcScheme {
|
||||
let requested_dst_base = (map.address != 0 || fixed).then_some(requested_dst_page);
|
||||
|
||||
let mut src_addr_space_guard = addrspace.acquire_write(token.downgrade());
|
||||
let (mut src_addr_space, lock_token) = src_addr_space_guard.token_split();
|
||||
let (src_addr_space, lock_token) = src_addr_space_guard.token_split();
|
||||
|
||||
let src_page_count = NonZeroUsize::new(src_span.count).ok_or(Error::new(EINVAL))?;
|
||||
|
||||
@@ -544,7 +544,7 @@ impl KernelScheme for ProcScheme {
|
||||
|dst_page, _, dst_mapper, flusher| {
|
||||
Grant::borrow(
|
||||
Arc::clone(addrspace),
|
||||
&mut src_addr_space,
|
||||
src_addr_space,
|
||||
src_span.base,
|
||||
dst_page,
|
||||
src_span.count,
|
||||
@@ -1408,7 +1408,7 @@ impl ContextHandle {
|
||||
Ok(grants_read * mem::size_of::<GrantDesc>())
|
||||
}
|
||||
|
||||
ContextHandle::Filetable { data, .. } => read_from(buf, &data, offset),
|
||||
ContextHandle::Filetable { data, .. } => read_from(buf, data, offset),
|
||||
ContextHandle::MmapMinAddr(addrspace) => {
|
||||
let mut token = token.token();
|
||||
let addr = addrspace.acquire_read(token.downgrade());
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use alloc::{
|
||||
borrow::ToOwned,
|
||||
string::{String, ToString},
|
||||
vec::Vec,
|
||||
};
|
||||
@@ -55,11 +56,9 @@ pub fn resource(token: &mut CleanLockToken) -> Result<Vec<u8>> {
|
||||
|
||||
let cpu_string = match context.cpu_id {
|
||||
Some(cpu_id) => {
|
||||
format!("{}", cpu_id)
|
||||
}
|
||||
_ => {
|
||||
format!("?")
|
||||
format!("{cpu_id}")
|
||||
}
|
||||
_ => "?".to_owned(),
|
||||
};
|
||||
let affinity = context.sched_affinity.to_string();
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ fn get_cpu_stats() -> String {
|
||||
total_kernel += stat.kernel;
|
||||
total_idle += stat.idle;
|
||||
total_irq += stat.irq;
|
||||
let _ = write!(&mut cpu_data, "cpu{} {}\n", id.get(), stat);
|
||||
let _ = writeln!(&mut cpu_data, "cpu{} {}", id.get(), stat);
|
||||
}
|
||||
format!(
|
||||
"cpu {total_user} {total_nice} {total_kernel} {total_idle} {total_irq}\n\
|
||||
|
||||
+2
-2
@@ -166,7 +166,7 @@ impl KernelScheme for TimeScheme {
|
||||
let mut bytes_read = 0;
|
||||
|
||||
for current_chunk in buf.in_exact_chunks(mem::size_of::<TimeSpec>()) {
|
||||
let arch_time = match (handle.clock.clone(), handle.kind.clone()) {
|
||||
let arch_time = match (handle.clock, handle.kind.clone()) {
|
||||
(CLOCK_REALTIME, TimeSchemeKind::Default | TimeSchemeKind::ClockGettime) => {
|
||||
time::realtime(token)
|
||||
}
|
||||
@@ -211,7 +211,7 @@ impl KernelScheme for TimeScheme {
|
||||
for current_chunk in buf.in_exact_chunks(mem::size_of::<TimeSpec>()) {
|
||||
let time = unsafe { current_chunk.read_exact::<TimeSpec>()? };
|
||||
|
||||
match (handle.clock.clone(), handle.kind.clone()) {
|
||||
match (handle.clock, handle.kind.clone()) {
|
||||
(_, TimeSchemeKind::Default | TimeSchemeKind::Timer) => {
|
||||
timeout::register(
|
||||
GlobalSchemes::Time.scheme_id(),
|
||||
|
||||
+22
-22
@@ -68,7 +68,7 @@ enum Response {
|
||||
}
|
||||
|
||||
impl Response {
|
||||
fn as_regular(self) -> Result<usize> {
|
||||
fn into_regular(self) -> Result<usize> {
|
||||
match self {
|
||||
Response::Regular(res, _, _) => res,
|
||||
Response::Fd(_) | Response::MultipleFds(_) => Err(Error::new(EIO)),
|
||||
@@ -1082,7 +1082,7 @@ impl UserInner {
|
||||
//let mapping_is_lazy = map.flags.contains(MapFlags::MAP_LAZY);
|
||||
let mapping_is_lazy = false;
|
||||
|
||||
let base_page_opt = (!mapping_is_lazy).then_some(response.as_regular()?);
|
||||
let base_page_opt = (!mapping_is_lazy).then_some(response.into_regular()?);
|
||||
|
||||
let file_ref = GrantFileRef {
|
||||
description: desc,
|
||||
@@ -1443,7 +1443,7 @@ impl KernelScheme for UserScheme {
|
||||
) {
|
||||
Ok(res) => {
|
||||
address.release(token)?;
|
||||
res.as_regular()
|
||||
res.into_regular()
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = address.release(token);
|
||||
@@ -1464,7 +1464,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()
|
||||
.into_regular()
|
||||
.map(|o| o as u64)
|
||||
}
|
||||
|
||||
@@ -1479,7 +1479,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()?;
|
||||
.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1502,7 +1502,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()?;
|
||||
.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1523,7 +1523,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()
|
||||
.into_regular()
|
||||
}
|
||||
|
||||
fn fevent(
|
||||
@@ -1542,7 +1542,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()
|
||||
.into_regular()
|
||||
.map(EventFlags::from_bits_truncate)
|
||||
}
|
||||
|
||||
@@ -1564,7 +1564,7 @@ impl KernelScheme for UserScheme {
|
||||
) {
|
||||
Ok(res) => {
|
||||
address.release(token)?;
|
||||
res.as_regular()
|
||||
res.into_regular()
|
||||
}
|
||||
Err(err) => {
|
||||
let _ = address.release(token);
|
||||
@@ -1592,7 +1592,7 @@ impl KernelScheme for UserScheme {
|
||||
) {
|
||||
Ok(res) => {
|
||||
address.release(token)?;
|
||||
res.as_regular()
|
||||
res.into_regular()
|
||||
}
|
||||
Err(err) => {
|
||||
let _ = address.release(token);
|
||||
@@ -1613,7 +1613,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()?;
|
||||
.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1628,7 +1628,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()?;
|
||||
.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -1722,7 +1722,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result
|
||||
}
|
||||
@@ -1755,7 +1755,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
|
||||
result
|
||||
@@ -1789,7 +1789,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
|
||||
result
|
||||
@@ -1812,7 +1812,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result
|
||||
}
|
||||
@@ -1846,7 +1846,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result
|
||||
}
|
||||
@@ -1863,7 +1863,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result.map(|_| ())
|
||||
}
|
||||
@@ -1880,7 +1880,7 @@ impl KernelScheme for UserScheme {
|
||||
address.span(),
|
||||
token,
|
||||
)?
|
||||
.as_regular();
|
||||
.into_regular();
|
||||
address.release(token)?;
|
||||
result.map(|_| ())
|
||||
}
|
||||
@@ -1915,7 +1915,7 @@ impl KernelScheme for UserScheme {
|
||||
token,
|
||||
)?;
|
||||
|
||||
res.as_regular()?;
|
||||
res.into_regular()?;
|
||||
Ok(())
|
||||
}
|
||||
fn kcall(
|
||||
@@ -1954,7 +1954,7 @@ impl KernelScheme for UserScheme {
|
||||
match inner.call_inner(Vec::new(), sqe, address.span(), token) {
|
||||
Ok(res) => {
|
||||
address.release(token)?;
|
||||
res.as_regular()
|
||||
res.into_regular()
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = address.release(token);
|
||||
@@ -2039,7 +2039,7 @@ impl KernelScheme for UserScheme {
|
||||
&mut PageSpan::empty(),
|
||||
token,
|
||||
)?
|
||||
.as_regular()
|
||||
.into_regular()
|
||||
}
|
||||
fn kfdread(
|
||||
&self,
|
||||
|
||||
+4
-16
@@ -474,10 +474,7 @@ impl<L: Level, T> RwLock<L, T> {
|
||||
&'a self,
|
||||
lock_token: LockToken<'a, LP>,
|
||||
) -> Option<RwLockReadGuard<'a, L, T>> {
|
||||
let inner = match self.inner.try_read() {
|
||||
Some(inner) => inner,
|
||||
None => return None,
|
||||
};
|
||||
let inner = self.inner.try_read()?;
|
||||
Some(RwLockReadGuard {
|
||||
inner,
|
||||
lock_token: LockToken::downgraded(lock_token),
|
||||
@@ -488,10 +485,7 @@ impl<L: Level, T> RwLock<L, T> {
|
||||
&'a self,
|
||||
lock_token: LockToken<'a, LP>,
|
||||
) -> Option<RwLockWriteGuard<'a, L, T>> {
|
||||
let inner = match self.inner.try_write() {
|
||||
Some(inner) => inner,
|
||||
None => return None,
|
||||
};
|
||||
let inner = self.inner.try_write()?;
|
||||
Some(RwLockWriteGuard {
|
||||
inner,
|
||||
lock_token: LockToken::downgraded(lock_token),
|
||||
@@ -526,10 +520,7 @@ impl<L: Level, T> RwLock<L, T> {
|
||||
}
|
||||
}
|
||||
};
|
||||
RwLockWriteGuard {
|
||||
inner,
|
||||
lock_token: lock_token,
|
||||
}
|
||||
RwLockWriteGuard { inner, lock_token }
|
||||
}
|
||||
|
||||
/// Arcquires the lock_token to replace older LockUpgradableGuard.
|
||||
@@ -559,10 +550,7 @@ impl<L: Level, T> RwLock<L, T> {
|
||||
}
|
||||
}
|
||||
};
|
||||
RwLockUpgradableGuard {
|
||||
inner,
|
||||
lock_token: lock_token,
|
||||
}
|
||||
RwLockUpgradableGuard { inner, lock_token }
|
||||
}
|
||||
|
||||
// Unsafe due to not using token, currently required by context::switch
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
use alloc::{string::String, vec::Vec};
|
||||
use alloc::{borrow::ToOwned, string::String, vec::Vec};
|
||||
use core::{ascii, fmt::Debug, mem};
|
||||
|
||||
use super::{
|
||||
@@ -187,7 +187,7 @@ pub fn format_call(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, g
|
||||
c,
|
||||
d
|
||||
),
|
||||
SYS_YIELD => format!("yield()"),
|
||||
SYS_YIELD => "yield()".to_owned(),
|
||||
_ => format!(
|
||||
"UNKNOWN{} {:#X}({:#X}, {:#X}, {:#X}, {:#X}, {:#X}, {:#X})",
|
||||
a, a, b, c, d, e, f, g
|
||||
|
||||
+1
-1
@@ -120,7 +120,7 @@ pub fn openat(
|
||||
.add_file(
|
||||
FileDescriptor {
|
||||
description: new_description,
|
||||
cloexec: flags as usize & O_CLOEXEC == O_CLOEXEC,
|
||||
cloexec: flags & O_CLOEXEC == O_CLOEXEC,
|
||||
},
|
||||
&mut token,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user