maint: fix clippy warnings

This commit is contained in:
2025-07-17 17:47:24 +03:00
parent b8e7430353
commit 3b1bdea1dd
84 changed files with 269 additions and 261 deletions
+1 -1
View File
@@ -25,7 +25,7 @@ pub fn load_somewhere(
let file_info: &FileInfo = file.get_info(&mut info_buffer).unwrap();
let size = file_info.file_size();
let page_count = (size + 0xFFF) / 0x1000;
let page_count = size.div_ceil(0x1000);
let base = bs.allocate_pages(
AllocateType::MaxAddress(MAXIMUM_ADDRESS),
+1 -1
View File
@@ -66,7 +66,7 @@ impl MemoryDescriptorExt for MemoryDescriptor {
}
}
pub fn memory_map(bs: &BootServices) -> Result<MemoryMap, Error> {
pub fn memory_map(bs: &BootServices) -> Result<MemoryMap<'_>, Error> {
bs.memory_map(unsafe { &mut MMAP_BUFFER.data })
}
+1 -1
View File
@@ -5,7 +5,7 @@ fn build_fp_context_obj() {
let out_dir = env::var("OUT_DIR").unwrap();
println!("cargo:rerun-if-changed={}", FP_CONTEXT_S);
println!("cargo:rerun-if-changed={FP_CONTEXT_S}");
cc::Build::new()
.out_dir(&out_dir)
+1
View File
@@ -1,3 +1,4 @@
#![allow(clippy::missing_safety_doc)]
use aarch64_cpu::{
asm::barrier,
registers::{MAIR_EL1, SCTLR_EL1, TCR_EL1},
+3 -3
View File
@@ -1,5 +1,5 @@
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
pub struct Entry {
pub limit_lo: u16,
pub base_lo: u16,
@@ -10,7 +10,7 @@ pub struct Entry {
}
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
pub struct Pointer {
pub limit: u16,
pub offset: usize,
@@ -121,7 +121,7 @@ mod imp {
use super::{Entry, Pointer};
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
pub struct Tss {
_0: u32,
rsp0: u64,
+3 -3
View File
@@ -15,7 +15,7 @@ fn build_x86_64() {
const DEFAULT_8086_AS: &str = "nasm";
const AP_BOOTSTRAP_S: &str = "src/arch/x86_64/boot/ap_boot.S";
println!("cargo:rerun-if-changed={}", AP_BOOTSTRAP_S);
println!("cargo:rerun-if-changed={AP_BOOTSTRAP_S}");
let out_dir = env::var("OUT_DIR").unwrap();
let assembler = env::var("AS8086").unwrap_or(DEFAULT_8086_AS.to_owned());
@@ -35,7 +35,7 @@ fn build_x86_64() {
if !output.status.success() {
io::stderr().write_all(&output.stderr).ok();
panic!("{}: could not assemble {}", assembler, AP_BOOTSTRAP_S);
panic!("{assembler}: could not assemble {AP_BOOTSTRAP_S}");
}
}
@@ -93,6 +93,6 @@ fn main() {
"x86_64" => build_x86_64(),
"aarch64" => (),
"riscv64" => (),
_ => panic!("Unknown target arch: {:?}", arch),
_ => panic!("Unknown target arch: {arch:?}"),
}
}
+6
View File
@@ -35,6 +35,9 @@ unsafe impl Allocator for AcpiAllocator {
}
// TODO don't map memory as device if not necessary
/// # Safety
///
/// Allows direct reads from physical memory, unsafe
pub unsafe fn read_memory<T>(address: PhysicalAddress) -> T {
let io =
unsafe { DeviceMemoryMapping::map(address, size_of::<T>(), Default::default()).unwrap() };
@@ -49,6 +52,9 @@ pub unsafe fn read_memory<T>(address: PhysicalAddress) -> T {
}
}
/// # Safety
///
/// Allows direct writes to physical memory, unsafe
pub unsafe fn write_memory<T>(address: PhysicalAddress, value: T) {
let io =
unsafe { DeviceMemoryMapping::map(address, size_of::<T>(), Default::default()).unwrap() };
+1 -1
View File
@@ -129,7 +129,7 @@ impl PrpList {
list: None,
}),
_ => {
let count = (size + 0xFFF) / 0x1000;
let count = size.div_ceil(0x1000);
let list =
DmaBuffer::new_slice_with(dma, |i| base.add((i + 1) * 0x1000), count - 1)
.map_err(NvmeError::MemoryError)?;
+5 -9
View File
@@ -71,10 +71,10 @@ impl ScsiEnclosure {
// Probe LUNs
for i in 0..lun_count {
if this.probe_lun(i as u8).await {
if let Ok(unit) = ScsiUnit::setup(this.clone(), i as u8).await {
*this.units[i].write() = Some(unit);
}
if this.probe_lun(i as u8).await
&& let Ok(unit) = ScsiUnit::setup(this.clone(), i as u8).await
{
*this.units[i].write() = Some(unit);
}
}
@@ -117,11 +117,7 @@ impl ScsiEnclosure {
attempts -= 1;
}
if attempts == 0 {
false
} else {
true
}
attempts != 0
}
async fn poll(self: &Arc<Self>) {
+1 -1
View File
@@ -44,7 +44,7 @@ impl ScsiTransportWrapper {
return Err(Error::InvalidArgument);
}
let lba_bytes = (lba as u32).to_be_bytes();
let lba_count = (lba_count as u16).to_be_bytes();
let lba_count = lba_count.to_be_bytes();
// Issue a READ (10) command
let request_buffer = [
0x28,
+2 -2
View File
@@ -1,7 +1,7 @@
//! PCI/PCIe bus interfaces
#![no_std]
#![feature(let_chains, decl_macro)]
#![allow(clippy::missing_transmute_annotations)]
#![allow(clippy::missing_transmute_annotations, clippy::identity_op)]
extern crate alloc;
@@ -466,7 +466,7 @@ impl PciBusManager {
for segment in this.segments.iter_mut() {
for device in segment.devices.iter_mut() {
let mut device = device.lock();
if !f(&mut *device)? {
if !f(&mut device)? {
return Ok(());
}
}
+1 -1
View File
@@ -374,7 +374,7 @@ pub trait PciConfigurationSpace {
/// Locates a capability within this configuration space
fn capability<C: PciCapability>(&self) -> Option<C::CapabilityData<'_, Self>> {
self.capability_iter().find_map(|(id, offset, len)| {
if id.map_or(false, |id| id == C::ID) && C::check(self, offset, len) {
if id == Some(C::ID) && C::check(self, offset, len) {
Some(C::data(self, offset, len))
} else {
None
@@ -131,7 +131,7 @@ impl Bbb {
&mut self,
buffer: DmaSliceMut<'_, MaybeUninit<u8>>,
) -> Result<usize, Error> {
if buffer.len() == 0 {
if buffer.is_empty() {
return Ok(0);
}
let len = self
@@ -36,7 +36,7 @@ async fn extract_class_info(device: &UsbDeviceAccess) -> Result<Option<UsbClassI
let device_info = &device.info;
let config_info = device.query_configuration_info(0).await?;
if config_info.interfaces.len() >= 1 {
if !config_info.interfaces.is_empty() {
let if_info = &config_info.interfaces[0];
let class = if device_info.device_class == UsbDeviceClass::FromInterface {
+1 -2
View File
@@ -160,8 +160,7 @@ impl Fat32FsInfo {
let signature0 = &self.bytes[0..4];
let signature1 = &self.bytes[484..488];
signature0 == &Self::SIGNATURE0.to_le_bytes()
&& signature1 == &Self::SIGNATURE1.to_le_bytes()
signature0 == Self::SIGNATURE0.to_le_bytes() && signature1 == Self::SIGNATURE1.to_le_bytes()
}
}
+2 -2
View File
@@ -303,7 +303,7 @@ impl CommonImpl for DirectoryNode {
}
fn metadata(&self, _node: &NodeRef) -> Result<Metadata, Error> {
Ok(self.metadata.clone())
Ok(self.metadata)
}
fn set_metadata(&self, _node: &NodeRef, _metadata: &Metadata) -> Result<(), Error> {
@@ -357,7 +357,7 @@ impl DirectoryImpl for DirectoryNode {
}
fn len(&self, _node: &NodeRef) -> Result<usize, Error> {
Ok((self.size_bytes.unwrap_or(0) as u32 / DIRENT_SIZE as u32) as usize)
Ok((self.size_bytes.unwrap_or(0) / DIRENT_SIZE as u32) as usize)
}
}
+1
View File
@@ -54,6 +54,7 @@ impl Fat32Fs {
) -> Result<NodeRef, Error> {
let mut cached = true;
for option in options {
#[allow(clippy::single_match)]
match option {
FilesystemMountOption::Sync => cached = false,
_ => (),
+1 -1
View File
@@ -16,7 +16,7 @@ pub(crate) struct TarIterator<'a> {
zero_blocks: usize,
}
#[repr(packed)]
#[repr(C, packed)]
pub(crate) struct TarEntry {
pub name: TarString<100>,
pub mode: OctalField<8>,
+1 -1
View File
@@ -127,7 +127,7 @@ pub fn register_interface(
NetworkInterfaceType::Ethernet => {
static LAST_ETHERNET_ID: AtomicUsize = AtomicUsize::new(0);
let eth_id = LAST_ETHERNET_ID.fetch_add(1, Ordering::SeqCst);
format!("eth{}", eth_id).into_boxed_str()
format!("eth{eth_id}").into_boxed_str()
}
NetworkInterfaceType::Loopback => "lo".into(),
};
+2 -2
View File
@@ -133,7 +133,7 @@ impl Route {
pub fn insert(route: Self) -> Result<(), Error> {
// TODO check for conflicts
log::debug!("Add route: {}", route);
log::debug!("Add route: {route}");
ROUTES.write().push(route);
Ok(())
}
@@ -143,7 +143,7 @@ impl fmt::Display for Route {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{} ", self.subnet)?;
if let Some(gw) = self.gateway {
write!(f, " via {}", gw)?;
write!(f, " via {gw}")?;
}
Ok(())
}
+1 -1
View File
@@ -262,7 +262,7 @@ fn describe_route(route: &Route) -> RouteInfo {
interface_name: interface.name.clone(),
interface_id: route.interface,
subnet: route.subnet,
gateway: route.gateway.map(Into::into),
gateway: route.gateway,
}
}
@@ -110,9 +110,9 @@ impl LocalPacketSocket {
///
/// 1. If this socket is bound to a name, the name will be used
/// 2. Otherwise:
/// 2.1. If `remote` is "known" by this socket, the address in the table will be used
/// 2.2. Otherwise, this socket is "paired" with the remote by generating a new anonymous
/// address unique to that socket
/// 2.1. If `remote` is "known" by this socket, the address in the table will be used
/// 2.2. Otherwise, this socket is "paired" with the remote by generating a new anonymous
/// address unique to that socket
fn get_send_info(
self: &Arc<Self>,
remote: &OwnedAddress,
+2 -2
View File
@@ -81,7 +81,7 @@ impl RawSocket {
};
for id in ids {
if except.map_or(false, |i| i == *id) {
if except == Some(*id) {
continue;
}
@@ -210,7 +210,7 @@ impl Socket for RawSocket {
if message.payload.len() > 1024 {
return Err(Error::InvalidArgument);
}
let mut builder = TxPacketBuilder::new(&*interface, message.payload.len())?;
let mut builder = TxPacketBuilder::new(&interface, message.payload.len())?;
builder.push_bytes(message.payload)?;
// false to prevent loopback
builder.transmit(Some(self.id))?;
+8 -8
View File
@@ -320,14 +320,14 @@ impl InterruptHandler for Rtl8139 {
let rx_len_1 = unsafe { rx.buffer[rx_pos + 3].assume_init() };
let rx_len = u16::from_le_bytes([rx_len_0, rx_len_1]) as usize;
if rx_len >= 16 {
if let Ok(mut packet_buf) = DmaBuffer::new_uninit_slice(&*self.dma, rx_len) {
packet_buf.copy_from_slice(&rx.buffer[rx_pos + 4..rx_pos + rx_len + 4]);
let packet_buf = unsafe { DmaBuffer::assume_init_slice(packet_buf) };
// let packet_buf = unsafe { packet_buf.assume_init_slice() };
let packet = RxPacket::new(packet_buf, 0, nic);
ygg_driver_net_core::receive_packet(packet).ok();
}
if rx_len >= 16
&& let Ok(mut packet_buf) = DmaBuffer::new_uninit_slice(&*self.dma, rx_len)
{
packet_buf.copy_from_slice(&rx.buffer[rx_pos + 4..rx_pos + rx_len + 4]);
let packet_buf = unsafe { DmaBuffer::assume_init_slice(packet_buf) };
// let packet_buf = unsafe { packet_buf.assume_init_slice() };
let packet = RxPacket::new(packet_buf, 0, nic);
ygg_driver_net_core::receive_packet(packet).ok();
}
// rx_len + 4, aligned to 4 bytes
+1 -1
View File
@@ -197,7 +197,7 @@ impl RxRing {
let index = self.rd % self.entries.len();
let entry = &mut self.entries[index];
if let Some(_) = entry.rx_completed() {
if entry.rx_completed().is_some() {
// Grab the current buffer (the one just written to by the DMA), replace it
// with the newly allocated one, and mark the descriptor as DMA-owned again
let new_buffer = DmaBuffer::new_uninit_slice(dma, 4096)?;
+2 -2
View File
@@ -143,14 +143,14 @@ impl UsbControlPipe for ControlPipe {
setup: ControlTransferSetup,
buffer: &[u8],
) -> Result<usize, UsbError> {
let mut dma_buffer =
let dma_buffer =
DmaBuffer::from_slice(&*self.xhci.dma, buffer).map_err(UsbError::MemoryError)?;
self.ring
.control_transfer(
self.xhci.as_ref(),
setup,
ControlDataStage::Out(&mut dma_buffer),
ControlDataStage::Out(&dma_buffer),
)
.await
}
+3 -3
View File
@@ -161,9 +161,9 @@ pub fn portsc_to_neutral(
portsc.bitand(RO_MASK | RWS_MASK)
}
impl Into<u8> for PortNumber {
fn into(self) -> u8 {
self.0
impl From<PortNumber> for u8 {
fn from(value: PortNumber) -> Self {
value.0
}
}
+1
View File
@@ -1,3 +1,4 @@
#![allow(clippy::new_without_default)]
#![no_std]
extern crate alloc;
+3 -5
View File
@@ -131,7 +131,7 @@ impl Node {
let inner = self
.device
.or_init_with(|| match Self::probe_single(&self, &mut cx) {
.or_init_with(|| match Self::probe_single(self, &mut cx) {
Some(probed) => NodeDevice::Present(probed),
None => NodeDevice::Missing,
});
@@ -270,11 +270,9 @@ impl Node {
}
fn make_init_context(&self) -> DeviceInitContext {
let cx = DeviceInitContext {
DeviceInitContext {
dma_allocator: Arc::new(DummyDmaAllocator),
};
cx
}
}
/// Returns an iterator over the node's children
@@ -44,6 +44,9 @@ pub trait DevicePageTableLevel {
None
}
/// # Safety
///
/// Removes validity of memory regions, unsafe.
unsafe fn remove_mapping(&mut self, base: usize, page_count: usize) {
let base_index = (base - Self::VIRTUAL_BASE) / Self::Level::SIZE;
for i in 0..page_count {
@@ -62,6 +65,9 @@ impl<N: DevicePageTableLevel, L: DevicePageTableLevel> DevicePageManager<N, L> {
Self { normal, large }
}
/// # Safety
///
/// Provides ability to map arbitrary ranges of memory, unsafe.
pub unsafe fn map_device_pages<A: KernelTableManager>(
&mut self,
base: PhysicalAddress,
@@ -112,6 +118,9 @@ impl<N: DevicePageTableLevel, L: DevicePageTableLevel> DevicePageManager<N, L> {
}
}
/// # Safety
///
/// Removes validity of memory regions, unsafe.
pub unsafe fn unmap_device_pages<A: KernelTableManager>(
&mut self,
mapping: &RawDeviceMemoryMapping<A>,
+8
View File
@@ -135,6 +135,10 @@ impl<T> PageBox<T, GlobalPhysicalAllocator> {
Ok(result)
}
/// # Safety
///
/// Unsafe: converts a raw physical address back into a [PageBox]. Only intended to be used
/// for allocations previously converted to [PhysicalAddress] via [PageBox::into_physical_raw].
pub unsafe fn from_physical_raw(address: PhysicalAddress) -> PageBox<T> {
PageBox::from_physical_raw_in(address)
}
@@ -249,6 +253,10 @@ impl<T, A: PhysicalMemoryAllocator<Address = PhysicalAddress>> PageBox<T, A> {
Ok(result)
}
/// # Safety
///
/// Unsafe: converts a raw physical address back into a [PageBox]. Only intended to be used
/// for allocations previously converted to [PhysicalAddress] via [PageBox::into_physical_raw].
pub unsafe fn from_physical_raw_in(address: PhysicalAddress) -> PageBox<T, A> {
let page_count = size_of::<T>().div_ceil(L3_PAGE_SIZE);
let value = address.virtualize() as *mut T;
+3
View File
@@ -24,6 +24,9 @@ impl Utf16LeStr {
Ok(unsafe { Self::from_utf16le_unchecked(raw) })
}
/// # Safety
///
/// Does not validate the validity of the UTF-16 sequence.
pub unsafe fn from_utf16le_unchecked(raw: &[u8]) -> &Self {
core::mem::transmute(raw)
}
+1 -1
View File
@@ -200,7 +200,7 @@ impl log::Log for RingLoggerSink {
let result = if record.target() == ":raw" || record.target() == ":program" {
write!(write, "{}", record.args())
} else {
write!(write, "{}\n", record.args())
writeln!(write, "{}", record.args())
};
if let Ok(()) = result {
@@ -26,9 +26,9 @@ pub(crate) async fn probe_mbr(dev: &Arc<dyn BlockDevice>) -> Result<Option<Vec<P
return Ok(None);
}
for i in 0..4 {
for (i, entry) in entries[0..4].iter_mut().enumerate() {
let s = 446 + i * size_of::<PartitionEntry>();
entries[i] = bytemuck::pod_read_unaligned(&mbr[s..s + size_of::<PartitionEntry>()]);
*entry = bytemuck::pod_read_unaligned(&mbr[s..s + size_of::<PartitionEntry>()]);
}
let mut partitions = vec![];
+1 -1
View File
@@ -65,7 +65,7 @@ impl DisplayConsole for FramebufferConsole {
let cw = inner.char_width;
let ch = inner.char_height;
let bytes_per_line = (font.width() as usize + 7) / 8;
let bytes_per_line = (font.width() as usize).div_ceil(8);
let mut iter = state.buffer.flush_rows();
+6
View File
@@ -151,6 +151,9 @@ impl<T> DmaBuffer<T> {
})
}
/// # Safety
///
/// Same precautions apply as for [MaybeUninit].
pub unsafe fn assume_init(buffer: DmaBuffer<MaybeUninit<T>>) -> DmaBuffer<T> {
let host_pointer = buffer.host_pointer;
let host_physical = buffer.host_physical;
@@ -169,6 +172,9 @@ impl<T> DmaBuffer<T> {
}
}
/// # Safety
///
/// Same precautions apply as for [MaybeUninit].
pub unsafe fn assume_init_slice(buffer: DmaBuffer<[MaybeUninit<T>]>) -> DmaBuffer<[T]> {
let host_pointer = buffer.host_pointer;
let host_physical = buffer.host_physical;
+1 -1
View File
@@ -222,7 +222,7 @@ impl Process {
let id = thread.id;
if let Some(sysfs_node) = self.sysfs_node.read().as_ref() {
thread.add_sysfs_node(&sysfs_node);
thread.add_sysfs_node(sysfs_node);
}
inner.register_thread(thread.clone());
+1 -1
View File
@@ -20,7 +20,7 @@ pub fn enqueue(task: Arc<Task>) -> Result<(), Error> {
/// Spawns a background worker to execute the tasks from the global queue
pub fn spawn_async_worker(index: usize) -> Result<(), Error> {
let name = format!("[async-worker-{}]", index);
let name = format!("[async-worker-{index}]");
let thread = Thread::new_kthread(
name,
+2 -2
View File
@@ -318,7 +318,7 @@ impl Thread {
/// Returns `true` if the thread is a child of given process
pub fn is_child_of(&self, pid: ProcessId) -> bool {
self.process.map_or(false, |p| p == pid)
self.process == Some(pid)
}
/// Returns the thread's parent process reference
@@ -513,7 +513,7 @@ impl Thread {
/// Returns `true` if the thread is a tracee of given process
pub fn is_tracee_of(&self, pid: ProcessId) -> bool {
self.debug.lock().tracer.map_or(false, |p| p == pid)
self.debug.lock().tracer == Some(pid)
}
pub fn attach_trace(&self, tracer: ProcessId) -> Result<(), Error> {
+2 -2
View File
@@ -86,7 +86,7 @@ enum FileInner {
Char(CharFile),
Socket(SocketWrapper),
AnonymousPipe(PipeEnd),
Poll(FdPoll),
Poll(Arc<FdPoll>),
Timer(TimerFile),
SharedMemory(Arc<SharedMemory>),
PtySlave(TerminalHalfWrapper<PseudoTerminalSlave>),
@@ -134,7 +134,7 @@ impl File {
/// Constructs a new poll channel file
pub fn new_poll_channel() -> Arc<Self> {
Self::from_inner(FileInner::Poll(FdPoll::new()))
Self::from_inner(FileInner::Poll(Arc::new(FdPoll::new())))
}
/// Creates a buffer of shared memory and associates a [File] with it
+1 -1
View File
@@ -53,7 +53,7 @@ unsafe extern "C" fn relocate_kernel(image_base: i64, rela_start: usize, rela_en
let value = match rela.r_info as u32 {
abi::R_AARCH64_RELATIVE => rela.r_addend + image_base,
_ => loop {},
_ => ArchitectureImpl::halt(),
};
slot.write_volatile(value);
+1 -1
View File
@@ -168,7 +168,7 @@ impl InterruptHandler for Gicv2m {
impl MessageInterruptController for Gicv2m {
fn handle_msi(&self, _vector: usize) {
loop {}
todo!()
}
fn register_msi_range(
+1 -1
View File
@@ -51,7 +51,7 @@ unsafe extern "C" fn relocate_kernel(image_base: i64, rela_start: usize, rela_en
let value = match rela.r_info as u32 {
abi::R_RISCV_RELATIVE => rela.r_addend + image_base,
_ => loop {},
_ => ArchitectureImpl::halt(),
};
slot.write_volatile(value);
+2 -2
View File
@@ -60,7 +60,7 @@ impl ExceptionKind {
/// Exception table entry
#[allow(dead_code)]
#[derive(Clone, Copy)]
#[repr(packed)]
#[repr(C, packed)]
pub struct Entry {
base_lo: u16,
selector: u16,
@@ -72,7 +72,7 @@ pub struct Entry {
}
#[allow(dead_code)]
#[repr(packed)]
#[repr(C, packed)]
struct Pointer {
limit: u16,
offset: usize,
+7 -9
View File
@@ -302,15 +302,13 @@ impl X86_64 {
if let Err(error) = ygg_driver_acpi::switch_to_acpi(acpi) {
log::error!("ACPI initialization error: {error:?}");
} else {
if let Err(error) =
ygg_driver_acpi::add_event_handler(&FixedEvent::POWER_BUTTON, |_| {
log::info!("Power button pressed!");
EventAction::Nothing
})
{
log::error!("Couldn't set ACPI power button handler: {error:?}");
}
} else if let Err(error) =
ygg_driver_acpi::add_event_handler(&FixedEvent::POWER_BUTTON, |_| {
log::info!("Power button pressed!");
EventAction::Nothing
})
{
log::error!("Couldn't set ACPI power button handler: {error:?}");
}
if let Ok(mcfg) = acpi.find_table::<Mcfg>() {
+1 -1
View File
@@ -58,7 +58,7 @@ impl ClockController for Bcm2835Aux {
regs.AUX_ENABLES.modify(AUX_ENABLES::MU_ENABLE::SET);
Ok(())
}
None => loop {},
None => todo!(),
_ => Err(Error::InvalidArgument),
}
}
+1 -1
View File
@@ -98,7 +98,7 @@ impl Aoncrg {
use ClockParent::*;
use ClockRegister::*;
const CLOCK_MAP: &[(&'static str, ClockRegister)] = &[
const CLOCK_MAP: &[(&str, ClockRegister)] = &[
/* 0 */ ("clk_osc", FixedDiv(4, Ext(PARENT_OSC))),
/* 1 */ ("clk_aon_apb_func", Unimp),
/* 2 */ ("clk_gmac5_ahb", Gate(31, Ext(PARENT_STG_AXIAHB))),
+1 -1
View File
@@ -80,7 +80,7 @@ impl Syscrg {
}
fn map_clock_index(index: u32) -> Option<(&'static str, ClockRegister)> {
const CLOCKS: &[(&'static str, ClockRegister)] = &const {
const CLOCKS: &[(&str, ClockRegister)] = &const {
use ClockParent::*;
use ClockRegister::*;
+4 -4
View File
@@ -55,8 +55,8 @@ impl<'de> Deserialize<'de> for () {
impl<const N: usize, T: Serialize> Serialize for [T; N] {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
for i in 0..N {
self[i].serialize(serializer)?;
for item in self[0..N].iter() {
item.serialize(serializer)?;
}
Ok(())
}
@@ -65,8 +65,8 @@ impl<const N: usize, T: Serialize> Serialize for [T; N] {
impl<'de, const N: usize, T: Deserialize<'de>> Deserialize<'de> for [T; N] {
fn deserialize<D: Deserializer<'de>>(deserializer: &mut D) -> Result<Self, D::Error> {
let mut array = [const { MaybeUninit::uninit() }; N];
for i in 0..N {
array[i].write(Deserialize::deserialize(deserializer)?);
for item in array[0..N].iter_mut() {
item.write(Deserialize::deserialize(deserializer)?);
}
Ok(unsafe { MaybeUninit::array_assume_init(array) })
}
+1 -1
View File
@@ -46,7 +46,7 @@ impl fmt::Display for MacAddress {
if i != 0 {
write!(f, ":")?;
}
write!(f, "{:02X}", octet)?;
write!(f, "{octet:02X}")?;
}
Ok(())
+3 -3
View File
@@ -90,12 +90,12 @@ impl SyscallRegister for ExitCode {
impl Serialize for ExitCode {
fn serialize<S: Serializer>(&self, serializer: &mut S) -> Result<(), S::Error> {
match self {
&Self::Exited(status) => {
match *self {
Self::Exited(status) => {
serializer.write_u8(0)?;
status.serialize(serializer)
}
&Self::BySignal(signal) => {
Self::BySignal(signal) => {
serializer.write_u8(1)?;
signal.serialize(serializer)
}
+2 -2
View File
@@ -25,8 +25,8 @@ where
Assert<{ M % 64 == 0 }>: IsTrue,
{
pub fn new() -> Option<NonNull<Self>> {
let data_page_count = (M * N + 0xFFF) / 0x1000;
let info_page_count = (size_of::<Self>() + 0xFFF) / 0x1000;
let data_page_count = (M * N).div_ceil(0x1000);
let info_page_count = size_of::<Self>().div_ceil(0x1000);
let data = P::map_pages(data_page_count)?;
let info = P::map_pages(info_page_count)?;
+1 -1
View File
@@ -7,7 +7,7 @@ use abi_generator::{
};
fn add_file<'a>(build: &'a mut cc::Build, name: &'a str) -> &'a mut cc::Build {
println!("cargo:rerun-if-changed={}", name);
println!("cargo:rerun-if-changed={name}");
build.file(name)
}
+5 -1
View File
@@ -7,7 +7,11 @@
naked_functions,
let_chains
)]
#![allow(clippy::new_without_default, clippy::missing_transmute_annotations)]
#![allow(
clippy::new_without_default,
clippy::missing_transmute_annotations,
clippy::identity_op
)]
use std::{fs, mem::MaybeUninit, os::yggdrasil::real_binary_path, path::Path, process::ExitCode};
@@ -27,6 +27,7 @@ static CURRENT_WORKSPACE: AtomicUsize = AtomicUsize::new(0);
const WHITE: u32 = 0xFFFFFFFF;
const BLACK: u32 = 0xFF000000;
#[allow(clippy::too_many_arguments)]
fn draw_string(
dt: &mut [u32],
font: &PcScreenFont,
+2 -1
View File
@@ -1,4 +1,5 @@
#![cfg_attr(target_os = "yggdrasil", feature(yggdrasil_os, rustc_private))]
#![allow(clippy::single_match, clippy::collapsible_else_if)]
#![feature(map_many_mut, iter_chain)]
use std::{
@@ -48,7 +49,7 @@ pub struct Server<'a> {
_pd: PhantomData<&'a ()>,
}
impl<'a> Server<'a> {
impl Server<'_> {
fn new() -> Result<Self, Error> {
Ok(Self {
input_state: InputState::default(),
+1 -1
View File
@@ -73,7 +73,7 @@ impl<'de> Deserialize<'de> for Color {
{
struct V;
impl<'de> Visitor<'de> for V {
impl Visitor<'_> for V {
type Value = Color;
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
+2 -2
View File
@@ -78,6 +78,7 @@ impl DrawState {
}
}
#[allow(clippy::too_many_arguments)]
fn draw_character(
dt: &mut [u32],
cx: usize,
@@ -110,7 +111,6 @@ impl DrawState {
return;
}
let c = cell.char as char;
let font = match (cell.attrs.bold, cell.attrs.italic) {
(true, true) => &fonts.bold_italic,
(false, true) => &fonts.italic,
@@ -118,7 +118,7 @@ impl DrawState {
(false, false) => &fonts.regular,
};
font.map_glyph(c, |x, y, v| {
font.map_glyph(cell.char, |x, y, v| {
let v = v.min(1.0);
let r = blend(fg.r, bg.r, v);
let g = blend(fg.g, bg.g, v);
+11 -13
View File
@@ -83,14 +83,12 @@ impl Utf8Decoder {
let ch = str.chars().next().unwrap();
self.len = 0;
Some(ch)
} else if self.len == 4 {
// Got 4 bytes and could not decode a single character
self.len = 0;
Some('\u{25A1}')
} else {
if self.len == 4 {
// Got 4 bytes and could not decode a single character
self.len = 0;
Some('\u{25A1}')
} else {
None
}
None
}
}
}
@@ -284,7 +282,7 @@ impl State {
fn update_fg_color(&mut self) {
if let Some(fg_index) = self.fg_index {
self.attributes.fg = Color::from_escape(&*CONFIG, self.attributes.bold, fg_index)
self.attributes.fg = Color::from_escape(&CONFIG, self.attributes.bold, fg_index)
.unwrap_or(self.default_attributes.fg);
}
}
@@ -345,7 +343,7 @@ impl State {
}
_ => {
self.buffer
.set_cell(self.cursor, GridCell::new(ch as char, self.attributes));
.set_cell(self.cursor, GridCell::new(ch, self.attributes));
self.cursor.col += 1;
true
}
@@ -378,7 +376,7 @@ impl State {
fn handle_ctlseq(&mut self, byte: u8, c: char) -> bool {
let redraw = match c {
'h' if byte == b'?' => match self.esc_args.get(0).copied().unwrap_or(0) {
'h' if byte == b'?' => match self.esc_args.first().copied().unwrap_or(0) {
25 => {
// Cursor visible
self.cursor_visible = true;
@@ -391,7 +389,7 @@ impl State {
}
_ => false,
},
'l' if byte == b'?' => match self.esc_args.get(0).copied().unwrap_or(0) {
'l' if byte == b'?' => match self.esc_args.first().copied().unwrap_or(0) {
25 => {
// Cursor not visible
self.cursor_visible = false;
@@ -408,7 +406,7 @@ impl State {
_ => false,
},
'q' => {
match self.esc_args.get(0).copied().unwrap_or(0) {
match self.esc_args.first().copied().unwrap_or(0) {
3 | 4 => self.cursor_style = CursorStyle::Underline,
5 | 6 => self.cursor_style = CursorStyle::Bar,
_ => self.cursor_style = CursorStyle::Block,
@@ -500,7 +498,7 @@ impl State {
if vt_color == 9 {
self.attributes.bg = self.default_attributes.bg;
} else {
self.attributes.bg = Color::from_escape(&*CONFIG, false, vt_color)
self.attributes.bg = Color::from_escape(&CONFIG, false, vt_color)
.unwrap_or(self.default_attributes.bg);
}
false
@@ -44,7 +44,7 @@ pub struct Window<'a> {
on_key_released: Box<dyn OnKeyReleased>,
}
impl<'a> Window<'a> {
impl Window<'_> {
pub fn new_with_info(application: &Application, info: CreateWindowInfo) -> Result<Self, Error> {
let mut connection = application.connection.lock().unwrap();
+1 -4
View File
@@ -35,10 +35,7 @@ pub struct Receiver<T> {
impl Error {
pub fn is_would_block(&self) -> bool {
match self {
Self::Io(error) if error.kind() == io::ErrorKind::WouldBlock => true,
_ => false,
}
matches!(self, Self::Io(error) if error.kind() == io::ErrorKind::WouldBlock)
}
}
+2 -2
View File
@@ -72,7 +72,7 @@ fn generate_header(config_path: impl AsRef<Path>, header_output: impl AsRef<Path
if !header_path.exists() || !content_matches(&header_path, &output) {
if let Some(parent) = header_path.parent() {
fs::create_dir_all(&parent).expect("Could not create header directory");
fs::create_dir_all(parent).expect("Could not create header directory");
}
fs::write(&header_path, &output[..]).expect("Could not write header");
}
@@ -95,7 +95,7 @@ fn compile_crt0(arch: &str, output_dir: impl AsRef<Path>) {
};
command
.arg(format!("--target={}-unknown-none", arch))
.arg(format!("--target={arch}-unknown-none"))
.arg("-nostdlib")
.arg("-fPIC")
.arg("-c");
+1 -1
View File
@@ -229,7 +229,7 @@ pub fn handle_kernel_argument(arg: usize) -> Vec<CString> {
args.push(c_arg);
}
if let Some(arg0) = args.get(0) {
if let Some(arg0) = args.first() {
let invocation_name_str = arg0.to_str().unwrap();
let invocation_name = arg0.clone();
let invocation_name_short_str =
@@ -10,7 +10,7 @@ unsafe extern "C" fn basename(path: *mut c_char) -> *mut c_char {
return DOT;
}
let path_str = path.cast_const().ensure_str();
if path_str == "" {
if path_str.is_empty() {
DOT
} else if path_str == "/" {
path
@@ -56,7 +56,7 @@ fn fmt_float_exp<W: Write + fmt::Write>(
}
fn fmt_float_string(val: c_double, precision: usize) -> String {
let string = format!("{:.p$}", val, p = precision);
let string = format!("{val:.precision$}");
// TODO trim
string
}
@@ -24,6 +24,7 @@ unsafe extern "C" fn strcasecmp_l(
todo!()
}
#[allow(clippy::unnecessary_cast)]
#[no_mangle]
unsafe extern "C" fn strncasecmp(s1: *const c_char, s2: *const c_char, n: usize) -> c_int {
if s1.is_null() {
@@ -6,12 +6,12 @@ use core::ffi::c_uchar;
pub fn is(wc: usize) -> c_uchar {
if wc < 0x20000 {
return (table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1;
(table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1
} else if wc < 0x2fffe {
1
} else {
0
}
if wc < 0x2fffe {
return 1;
}
return 0;
}
const table: [c_uchar; 3904] = [
@@ -370,7 +370,7 @@ pub fn casemap(mut c: u32, dir: i32) -> wint_t {
/* lookup entry in two-level base-6 table */
let mut v: c_uint = tab[(tab[b as usize] as u32 * 86 + x) as usize] as c_uint;
let mt: [c_uint; 3] = [2048, 342, 57];
v = (v * mt[y as usize] >> 11) % 6;
v = (v * (mt[y as usize] >> 11)) % 6;
/* use the bit vector out of the tables as an index into
* a block-specific set of rules and decode the rule into
@@ -413,5 +413,6 @@ pub fn casemap(mut c: u32, dir: i32) -> wint_t {
xn -= xn / 2;
}
}
return c0;
c0
}
@@ -78,7 +78,7 @@ unsafe extern "C" fn iswlower(wc: wint_t) -> c_int {
#[no_mangle]
unsafe extern "C" fn iswprint(wc: wint_t) -> c_int {
if wc < 0xff {
c_int::from((wc + 1 & 0x7f) >= 0x21)
c_int::from(((wc + 1) & 0x7f) >= 0x21)
} else if wc < 0x2028
|| wc.wrapping_sub(0x202a) < 0xd800 - 0x202a
|| wc.wrapping_sub(0xe000) < 0xfff9 - 0xe000
@@ -7,9 +7,10 @@ use core::ffi::c_uchar;
pub fn is(wc: usize) -> c_uchar {
if wc < 0x20000 {
return (table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1;
(table[(table[wc >> 8] as usize) * 32 + ((wc & 255) >> 3)] >> (wc & 7)) & 1
} else {
0
}
return 0;
}
const table: [c_uchar; 4000] = [
+2 -8
View File
@@ -300,10 +300,7 @@ impl FILE {
}
unsafe fn reading_locked(&self) -> bool {
!self.flags.contains(FileFlags::WRITE)
|| self
.last_operation
.map_or(false, |op| op == Direction::Read)
!self.flags.contains(FileFlags::WRITE) || self.last_operation == Some(Direction::Read)
}
pub fn reading(&self) -> bool {
@@ -311,10 +308,7 @@ impl FILE {
}
unsafe fn writing_locked(&self) -> bool {
!self.flags.contains(FileFlags::WRITE)
|| self
.last_operation
.map_or(false, |op| op == Direction::Write)
!self.flags.contains(FileFlags::WRITE) || self.last_operation == Some(Direction::Write)
}
pub fn writing(&self) -> bool {
+1 -1
View File
@@ -89,7 +89,7 @@ fn panic_handler(pi: &core::panic::PanicInfo) -> ! {
if this == 0 {
writeln!(printer, "* Main thread panicked *").ok();
} else {
writeln!(printer, "* Thread {} panicked*", this).ok();
writeln!(printer, "* Thread {this} panicked*").ok();
}
}
+1 -1
View File
@@ -109,7 +109,7 @@ unsafe extern "C" fn __assert_fail(file: *const c_char, line: c_int, message: *c
}
.unwrap_or("???");
writeln!(err, "Assertion failed: '{}' at {}:{}", expr, file, line).ok();
writeln!(err, "Assertion failed: '{expr}' at {file}:{line}").ok();
abort()
}
+3 -3
View File
@@ -43,7 +43,7 @@ fn signal_handler(signal: Signal) {
}
pub unsafe fn set(sig: c_int, handler: sig_handler_t) -> EResult<sig_handler_t> {
if sig < 0 || sig >= SIGNAL_MAX {
if !(0..SIGNAL_MAX).contains(&sig) {
return EResult::Err(Errno::EINVAL);
}
@@ -55,12 +55,12 @@ pub unsafe fn set(sig: c_int, handler: sig_handler_t) -> EResult<sig_handler_t>
_ if address == __sig_terminate as usize => todo!(),
_ if address == __sig_ignore as usize => todo!(),
// This is safe: handler essentially has the same type, just in a wrapper
_ => core::mem::transmute(handler),
_ => handler,
};
let old = table[sig as usize].replace(handler);
let old = match old {
Some(old) => core::mem::transmute(old),
Some(old) => old,
None => __sig_terminate as sig_handler_t,
};
EResult::Ok(old)
+1
View File
@@ -15,6 +15,7 @@ use crate::{
pub trait Pointer {
type Pointee;
#[allow(clippy::wrong_self_convention)]
fn is_null(self) -> bool;
}
+2 -4
View File
@@ -242,9 +242,7 @@ impl DhcpMessage {
}
fn as_dhcp_acknowledge(&self, requested_address: Ipv4Addr) -> Option<()> {
let Some(ty) = self.message_type() else {
return None;
};
let ty = self.message_type()?;
if ty != DhcpMessageType::Acknowledge {
return None;
@@ -555,7 +553,7 @@ fn configure_address(interface: &str, offer: DhcpOffer) -> Result<(), Error> {
netconf.add_route(
interface,
SubnetAddr::V4(SubnetV4Addr::UNSPECIFIED),
Some(router_address.into())
Some(router_address.into()),
)?;
Ok(())
}
+28 -33
View File
@@ -165,43 +165,38 @@ impl State {
let hint_style = Style::default().bg(Color::Blue).fg(Color::White);
let key_style = Style::default().bg(Color::Cyan).fg(Color::Black);
let rows = self
.processes
.iter()
.enumerate()
.map(|(i, process)| {
let style = if i == self.selection {
selected_style
} else {
normal_style
};
let rows = self.processes.iter().enumerate().flat_map(|(i, process)| {
let style = if i == self.selection {
selected_style
} else {
normal_style
};
let mut rows = vec![Row::new(vec![
Cell::from(format!("{}", process.pid)),
Cell::from(""),
Cell::from(process.name.as_str()),
])
.height(1)
.style(style)];
let mut rows = vec![Row::new(vec![
Cell::from(format!("{}", process.pid)),
Cell::from(""),
Cell::from(process.name.as_str()),
])
.height(1)
.style(style)];
if self.expanded.contains(&process.pid) {
let count = process.threads.len();
for (i, thread) in process.threads.iter().enumerate() {
let ch = if i == count - 1 { "" } else { "" };
rows.push(
Row::new(vec![
Cell::from(ch),
Cell::from(format!("{}", thread.tid)),
Cell::from(thread.name.as_str()),
])
.style(style),
);
}
if self.expanded.contains(&process.pid) {
let count = process.threads.len();
for (i, thread) in process.threads.iter().enumerate() {
let ch = if i == count - 1 { "" } else { "" };
rows.push(
Row::new(vec![
Cell::from(ch),
Cell::from(format!("{}", thread.tid)),
Cell::from(thread.name.as_str()),
])
.style(style),
);
}
}
rows
})
.flatten();
rows
});
let header = Row::new(vec![
Cell::from("PID"),
+5 -8
View File
@@ -363,11 +363,8 @@ impl TerminalTypesetter {
}
fn increment_list_index(&mut self) {
if let Some(last) = self.list_stack.last_mut() {
match last {
ListStyle::Numbered(index) => *index += 1,
_ => (),
}
if let Some(ListStyle::Numbered(index)) = self.list_stack.last_mut() {
*index += 1;
}
}
@@ -436,11 +433,11 @@ impl Typesetter for TerminalTypesetter {
self.hard_break(false);
self.indent += 1;
if let Some(last) = self.list_stack.last() {
match last {
&ListStyle::Bullet(p) => {
match *last {
ListStyle::Bullet(p) => {
self.line.prefix.push(p);
}
&ListStyle::Numbered(n) => {
ListStyle::Numbered(n) => {
self.line.prefix.push_str(&format!("{n}."));
}
}
+8 -8
View File
@@ -63,7 +63,7 @@ fn evaluate_conditional_body(
env: &mut Environment,
) -> (Outcome, Option<ExitCode>) {
while let Expression::Not(inner) = body {
body = &*inner;
body = inner;
}
let status = match body {
Expression::Binary(BinaryOperator::Equal, lhs, rhs)
@@ -109,7 +109,7 @@ pub fn evaluate_conditional(
conditional: &ConditionalExpression,
env: &mut Environment,
) -> (Outcome, Option<ExitCode>) {
evaluate_conditional_body(&*conditional.body, env)
evaluate_conditional_body(&conditional.body, env)
}
pub fn evaluate(expression: &Expression, env: &mut Environment) -> (Outcome, Option<ExitCode>) {
@@ -119,7 +119,7 @@ pub fn evaluate(expression: &Expression, env: &mut Environment) -> (Outcome, Opt
let mut setenvs = vec![];
expanded.elements.retain_mut(|e| {
if e.words.is_empty() {
setenvs.extend(e.envs.drain(..));
setenvs.append(&mut e.envs);
}
!e.words.is_empty()
});
@@ -169,7 +169,7 @@ pub fn evaluate(expression: &Expression, env: &mut Environment) -> (Outcome, Opt
},
// TODO redirects
Expression::For(for_expression) => {
let list = ExpandedPipelineElement::from_syntax(env, &*for_expression.list);
let list = ExpandedPipelineElement::from_syntax(env, &for_expression.list);
env.push_environment();
for word in list.words {
env.insert_current_literal(for_expression.variable, word);
@@ -183,23 +183,23 @@ pub fn evaluate(expression: &Expression, env: &mut Environment) -> (Outcome, Opt
(Outcome::ok(), None)
}
Expression::Binary(BinaryOperator::And, lhs, rhs) => {
let (lhs, exit) = evaluate(&*lhs, env);
let (lhs, exit) = evaluate(lhs, env);
if exit.is_some() {
return (lhs, exit);
}
if lhs.is_success() {
evaluate(&*rhs, env)
evaluate(rhs, env)
} else {
(lhs, exit)
}
}
Expression::Binary(BinaryOperator::Or, lhs, rhs) => {
let (lhs, exit) = evaluate(&*lhs, env);
let (lhs, exit) = evaluate(lhs, env);
if exit.is_some() {
return (lhs, exit);
}
if !lhs.is_success() {
evaluate(&*rhs, env)
evaluate(rhs, env)
} else {
(lhs, exit)
}
+1 -2
View File
@@ -20,8 +20,7 @@ impl ExpandedPipelineElement {
let mut words: Vec<_> = element
.words
.iter()
.map(|word| env.expand(word))
.flatten()
.flat_map(|word| env.expand(word))
.collect();
let mut envs = vec![];
+1 -1
View File
@@ -118,7 +118,7 @@ fn run(mut input: ShellInput, env: &mut Environment) -> Result<(), Error> {
continue;
}
command_text.push_str(&line.trim_matches([' ', '\t']));
command_text.push_str(line.trim_matches([' ', '\t']));
let expr = match syntax::parse::parse_toplevel(&command_text) {
Ok(("" | "\n", expr)) => expr,
Ok((rest, _)) => {
+5 -7
View File
@@ -23,14 +23,12 @@ impl Utf8Decoder {
let ch = str.chars().next().unwrap();
self.len = 0;
Some(ch)
} else if self.len == 4 {
// Got 4 bytes and could not decode a single character
self.len = 0;
Some('\u{25A1}')
} else {
if self.len == 4 {
// Got 4 bytes and could not decode a single character
self.len = 0;
Some('\u{25A1}')
} else {
None
}
None
}
}
}
+12 -17
View File
@@ -1,6 +1,10 @@
use std::fmt::Write;
use runtime::{abi::SyscallFunction, abi_lib::SyscallRegister, rt::io::{OpenOptions, SeekFrom}};
use runtime::{
abi::SyscallFunction,
abi_lib::SyscallRegister,
rt::io::{OpenOptions, SeekFrom},
};
use crate::tracer::{CommandTracer, SyscallTrace};
@@ -36,14 +40,14 @@ enum Result {
struct Formatter {
fun: &'static str,
args: &'static [Arg],
res: Result
res: Result,
}
impl Formatter {
const EMPTY: Self = Self {
fun: "",
args: &[],
res: Result::None
res: Result::None,
};
}
@@ -53,6 +57,7 @@ macro_rules! formatter_list {
$($syscall:ident => $name:ident ($($arg:ident),* $(,)?) $(-> $result:ident)?),+ $(,)?
]
) => {
#[allow(clippy::needless_update)]
const FORMATTERS: [Option<Formatter>; SYSCALL_MAX] = const {
let mut array = [None; SYSCALL_MAX];
@@ -258,9 +263,7 @@ impl Arg {
Arg::Hex => Some((format!("{:#x}", args[0]), 1)),
Arg::Oct => Some((format!("{:#o}", args[0]), 1)),
#[cfg(any(rust_analyzer, target_pointer_width = "64"))]
Arg::U64Dec => {
Some((format!("{}", args[0]), 1))
}
Arg::U64Dec => Some((format!("{}", args[0]), 1)),
Arg::Bool => {
let result = if args[0] == 0 {
"false".into()
@@ -335,9 +338,7 @@ impl Arg {
};
Some((result, 1))
}
Arg::Todo => {
Some(("...".into(), 1))
}
Arg::Todo => Some(("...".into(), 1)),
}
}
}
@@ -359,14 +360,8 @@ impl Result {
format!("{result:#x}")
}
}
Self::ResUnit => {
if result == 0 {
"<ok>"
} else {
"<error>"
}.into()
}
_ => return None
Self::ResUnit => if result == 0 { "<ok>" } else { "<error>" }.into(),
_ => return None,
})
}
}
+35 -34
View File
@@ -88,7 +88,8 @@ impl CommandTracer {
}
pub fn read_word(&mut self, address: usize) -> io::Result<usize> {
debug_control::<debug::ReadMemory>(self.tid, &mut self.buffer, &address).map_err(io::Error::from)
debug_control::<debug::ReadMemory>(self.tid, &mut self.buffer, &address)
.map_err(io::Error::from)
}
pub fn read_memory(&mut self, mut address: usize, buffer: &mut [u8]) -> io::Result<()> {
@@ -185,41 +186,41 @@ impl SyscallTrace {
#[cfg(any(target_arch = "riscv64", rust_analyzer))]
impl SyscallTrace {
fn from_parts(entry: &EnteredSyscall, exit_regs: &SavedFrame, exit: SystemTime) -> Self {
let function = entry.regs.an[0] as usize;
let function = entry.regs.an[0];
let args = [
entry.regs.an[1] as usize,
entry.regs.an[2] as usize,
entry.regs.an[3] as usize,
entry.regs.an[4] as usize,
entry.regs.an[5] as usize,
entry.regs.an[6] as usize,
entry.regs.an[1],
entry.regs.an[2],
entry.regs.an[3],
entry.regs.an[4],
entry.regs.an[5],
entry.regs.an[6],
];
let result = exit_regs.an[0] as usize;
let entry = entry.timestamp;
Self {
entry,
exit,
function,
args,
result
}
}
}
#[cfg(any(target_arch = "aarch64", rust_analyzer))]
impl SyscallTrace {
fn from_parts(entry: &EnteredSyscall, exit_regs: &SavedFrame, exit: SystemTime) -> Self {
let function = entry.regs.gp_regs[8];
let args = [
entry.regs.gp_regs[0] as usize,
entry.regs.gp_regs[1] as usize,
entry.regs.gp_regs[2] as usize,
entry.regs.gp_regs[3] as usize,
entry.regs.gp_regs[4] as usize,
entry.regs.gp_regs[5] as usize,
];
let result = exit_regs.gp_regs[0] as usize;
let result = exit_regs.an[0];
let entry = entry.timestamp;
Self {
entry,
exit,
function,
args,
result,
}
}
}
#[cfg(any(target_arch = "aarch64", rust_analyzer))]
impl SyscallTrace {
fn from_parts(entry: &EnteredSyscall, exit_regs: &SavedFrame, exit: SystemTime) -> Self {
let function = entry.regs.gp_regs[8];
let args = [
entry.regs.gp_regs[0],
entry.regs.gp_regs[1],
entry.regs.gp_regs[2],
entry.regs.gp_regs[3],
entry.regs.gp_regs[4],
entry.regs.gp_regs[5],
];
let result = exit_regs.gp_regs[0];
let entry = entry.timestamp;
Self {