From c6f68646d9cab335d47ca532b29cfcbae74bee73 Mon Sep 17 00:00:00 2001 From: Yuuki Takano Date: Tue, 18 Nov 2025 18:42:07 +0900 Subject: [PATCH 1/6] use nightly-2025-11-16 Signed-off-by: Yuuki Takano --- .github/workflows/rust.yml | 4 ++-- .vscode/settings.json | 12 ++++++------ Makefile | 2 +- docker/Dockerfile | 4 ++-- targets/aarch64-kernel.json | 4 ++-- targets/x86_64-kernel.json | 4 ++-- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 182410484..ba86b81c7 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -19,9 +19,9 @@ jobs: - uses: actions/checkout@v3 - name: Install Rust nightly - run: rustup toolchain install nightly-2025-05-22 + run: rustup toolchain install nightly-2025-11-16 - name: Use Rust nightly - run: rustup default nightly-2025-05-22 + run: rustup default nightly-2025-11-16 - name: Add Rust components run: rustup component add rust-src llvm-tools-preview clippy rustfmt - name: Add Rust targets diff --git a/.vscode/settings.json b/.vscode/settings.json index 23d4766b7..bdae02be9 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,13 +5,13 @@ // For AArch64 Virt // "rust-analyzer.cargo.buildScripts.overrideCommand": [ // "cargo", - // "+nightly-2025-05-22", + // "+nightly-2025-11-16", // "check_no_std", // "--target=targets/aarch64-kernel.json", // ], // "rust-analyzer.check.overrideCommand": [ // "cargo", - // "+nightly-2025-05-22", + // "+nightly-2025-11-16", // "check_no_std", // "--target=targets/aarch64-kernel.json", // ], @@ -21,13 +21,13 @@ // For x86_64 "rust-analyzer.cargo.buildScripts.overrideCommand": [ "cargo", - "+nightly-2025-05-22", + "+nightly-2025-11-16", "check_no_std", "--target=targets/x86_64-kernel.json", ], "rust-analyzer.check.overrideCommand": [ "cargo", - "+nightly-2025-05-22", + "+nightly-2025-11-16", "check_no_std", "--target=targets/x86_64-kernel.json", ], @@ -37,14 +37,14 @@ // For Linux // "rust-analyzer.cargo.buildScripts.overrideCommand": [ // "cargo", - // "+nightly-2025-05-22", + // "+nightly-2025-11-16", // "check_std", // "--quiet", // "--message-format=json" // ], // "rust-analyzer.check.overrideCommand": [ // "cargo", - // "+nightly-2025-05-22", + // "+nightly-2025-11-16", // "check_std", // "--quiet", // "--message-format=json" diff --git a/Makefile b/Makefile index e017042b4..cf0f49e35 100644 --- a/Makefile +++ b/Makefile @@ -55,7 +55,7 @@ X86_64_LD=$(LINKERDIR)/x86_64-link.lds RV32_LD=$(LINKERDIR)/rv32-link.lds RV64_LD=$(LINKERDIR)/rv64-link.lds -RUSTV=nightly-2025-05-22 +RUSTV=nightly-2025-11-16 all: aarch64 x86_64 riscv32 riscv64 std diff --git a/docker/Dockerfile b/docker/Dockerfile index 84115f27e..dc551b7c2 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -16,8 +16,8 @@ RUN . /usr/local/cargo/env && \ cargo install mdbook-mermaid RUN . /usr/local/cargo/env && \ - rustup toolchain install nightly-2025-04-29 && \ - rustup default nightly-2025-04-29 && \ + rustup toolchain install nightly-2025-11-16 && \ + rustup default nightly-2025-11-16 && \ rustup component add rust-src llvm-tools-preview && \ rustup target add x86_64-unknown-none aarch64-unknown-none riscv32imac-unknown-none-elf diff --git a/targets/aarch64-kernel.json b/targets/aarch64-kernel.json index 7c1b6525f..54a5b0821 100644 --- a/targets/aarch64-kernel.json +++ b/targets/aarch64-kernel.json @@ -24,8 +24,8 @@ "max-atomic-width": 128, "os": "none", "relocation-model": "static", - "target-c-int-width": "32", + "target-c-int-width": 32, "target-endian": "little", - "target-pointer-width": "64", + "target-pointer-width": 64, "vendor": "TIER IV, inc." } \ No newline at end of file diff --git a/targets/x86_64-kernel.json b/targets/x86_64-kernel.json index ede73dbea..03a5aab02 100644 --- a/targets/x86_64-kernel.json +++ b/targets/x86_64-kernel.json @@ -3,8 +3,8 @@ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", - "target-pointer-width": "64", - "target-c-int-width": "32", + "target-pointer-width": 64, + "target-c-int-width": 32, "os": "none", "executables": true, "linker-flavor": "ld.lld", From 1f181664894ff766ca1759b5d663a5a0c957bff7 Mon Sep 17 00:00:00 2001 From: Yuuki Takano Date: Wed, 19 Nov 2025 11:29:51 +0900 Subject: [PATCH 2/6] clippy Signed-off-by: Yuuki Takano --- README.md | 4 +-- awkernel_async_lib/src/dag/graph.rs | 33 +++---------------- .../src/dag/graph/iter_format.rs | 2 +- awkernel_async_lib_verified/src/ringq.rs | 2 +- awkernel_drivers/src/pcie/nvme/nvme_regs.rs | 15 +++++---- awkernel_lib/src/arch/x86_64/acpi/dmar.rs | 2 +- .../src/arch/x86_64/acpi/dmar/atsr.rs | 2 +- .../src/arch/x86_64/acpi/dmar/dhrd.rs | 2 +- .../src/arch/x86_64/acpi/dmar/rmrr.rs | 2 +- .../src/arch/x86_64/acpi/dmar/satc.rs | 2 +- .../src/arch/x86_64/acpi/dmar/sidp.rs | 2 +- awkernel_lib/src/arch/x86_64/acpi/srat.rs | 2 +- awkernel_lib/src/context/x86_64.rs | 2 +- awkernel_lib/src/device_tree/traits.rs | 2 +- awkernel_lib/src/heap.rs | 2 +- awkernel_lib/src/net/ether.rs | 2 +- awkernel_lib/src/unwind.rs | 2 +- kernel/src/arch/x86_64/kernel_main.rs | 7 ++-- smoltcp/src/storage/assembler.rs | 2 +- 19 files changed, 35 insertions(+), 54 deletions(-) diff --git a/README.md b/README.md index 7bde87be4..f9de27cc1 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ It can execute async/await applications in kernel space safely. ```text $ sudo apt install clang qemu-system-arm qemu-system-x86 qemu-system-misc python3-pyelftools -$ rustup toolchain install nightly-2025-05-22 -$ rustup default nightly-2025-05-22 +$ rustup toolchain install nightly-2025-11-16 +$ rustup default nightly-2025-11-16 $ rustup component add rust-src llvm-tools-preview $ rustup target add x86_64-unknown-none aarch64-unknown-none riscv64gc-unknown-none-elf riscv32imac-unknown-none-elf ``` diff --git a/awkernel_async_lib/src/dag/graph.rs b/awkernel_async_lib/src/dag/graph.rs index ca3be159c..9953b4c8a 100644 --- a/awkernel_async_lib/src/dag/graph.rs +++ b/awkernel_async_lib/src/dag/graph.rs @@ -525,7 +525,7 @@ where /// not borrow from the graph. /// /// [1]: struct.Neighbors.html#method.detach - pub fn neighbors(&self, a: NodeIndex) -> Neighbors { + pub fn neighbors(&self, a: NodeIndex) -> Neighbors<'_, E, Ix> { self.neighbors_directed(a, Outgoing) } @@ -546,7 +546,7 @@ where /// not borrow from the graph. /// /// [1]: struct.Neighbors.html#method.detach - pub fn neighbors_directed(&self, a: NodeIndex, dir: Direction) -> Neighbors { + pub fn neighbors_directed(&self, a: NodeIndex, dir: Direction) -> Neighbors<'_, E, Ix> { let mut iter = self.neighbors_undirected(a); let k = dir.index(); iter.next[1 - k] = EdgeIndex::end(); @@ -567,7 +567,7 @@ where /// not borrow from the graph. /// /// [1]: struct.Neighbors.html#method.detach - pub fn neighbors_undirected(&self, a: NodeIndex) -> Neighbors { + pub fn neighbors_undirected(&self, a: NodeIndex) -> Neighbors<'_, E, Ix> { Neighbors { skip_start: a, edges: &self.edges, @@ -589,7 +589,7 @@ where /// just the nodes without edges. /// /// The whole iteration computes in **O(|V|)** time where V is the set of nodes. - pub fn externals(&self, dir: Direction) -> Externals { + pub fn externals(&self, dir: Direction) -> Externals<'_, N, Ix> { Externals { iter: self.nodes.iter().enumerate(), dir, @@ -607,7 +607,7 @@ where /// Create an iterator over all edges, in indexed order. /// /// Iterator element type is `EdgeReference`. - pub fn edge_references(&self) -> EdgeReferences { + pub fn edge_references(&self) -> EdgeReferences<'_, E, Ix> { EdgeReferences { iter: self.edges.iter().enumerate(), } @@ -691,29 +691,6 @@ where clone_fields!(Neighbors, skip_start, edges, next,); } -/// A “walker” object that can be used to step through the edge list of a node. -/// -/// Created with [`.detach()`](struct.Neighbors.html#method.detach). -/// -/// The walker does not borrow from the graph, so it lets you step through -/// neighbors or incident edges while also mutating graph weights. -pub struct WalkNeighbors { - skip_start: NodeIndex, - next: [EdgeIndex; 2], -} - -impl Clone for WalkNeighbors -where - Ix: IndexType, -{ - fn clone(&self) -> Self { - WalkNeighbors { - skip_start: self.skip_start, - next: self.next, - } - } -} - /// Iterator over the node indices of a graph. #[derive(Clone, Debug)] pub struct NodeIndices { diff --git a/awkernel_async_lib/src/dag/graph/iter_format.rs b/awkernel_async_lib/src/dag/graph/iter_format.rs index adf6112ae..b2ee4b69a 100644 --- a/awkernel_async_lib/src/dag/graph/iter_format.rs +++ b/awkernel_async_lib/src/dag/graph/iter_format.rs @@ -110,7 +110,7 @@ pub struct Format<'a, I> { } pub trait IterFormatExt: Iterator { - fn format(self, separator: &str) -> Format + fn format(self, separator: &str) -> Format<'_, Self> where Self: Sized, { diff --git a/awkernel_async_lib_verified/src/ringq.rs b/awkernel_async_lib_verified/src/ringq.rs index b33c1fe6c..3dd67410e 100644 --- a/awkernel_async_lib_verified/src/ringq.rs +++ b/awkernel_async_lib_verified/src/ringq.rs @@ -87,7 +87,7 @@ impl RingQ { /// Get a iterator. #[inline(always)] - pub fn iter(&self) -> IterRingQ { + pub fn iter(&self) -> IterRingQ<'_, T> { IterRingQ { ringq: self, pos: self.head, diff --git a/awkernel_drivers/src/pcie/nvme/nvme_regs.rs b/awkernel_drivers/src/pcie/nvme/nvme_regs.rs index 0e6d907df..3c35a8a79 100644 --- a/awkernel_drivers/src/pcie/nvme/nvme_regs.rs +++ b/awkernel_drivers/src/pcie/nvme/nvme_regs.rs @@ -11,19 +11,19 @@ pub const NVME_VS: usize = 0x0008; /* Version */ pub const NVME_INTMC: usize = 0x0010; /* Interrupt Mask Clear */ pub const NVME_CC: usize = 0x0014; /* Controller Configuration */ -pub const NVME_CC_IOCQES: fn(u32) -> u32 = |_v| (((_v) & 0xf) << 20); +pub const NVME_CC_IOCQES: fn(u32) -> u32 = |_v| ((_v) & 0xf) << 20; pub const NVME_CC_IOCQES_MASK: u32 = 0xf << 20; -pub const NVME_CC_IOSQES: fn(u32) -> u32 = |_v| (((_v) & 0xf) << 16); +pub const NVME_CC_IOSQES: fn(u32) -> u32 = |_v| ((_v) & 0xf) << 16; pub const NVME_CC_IOSQES_MASK: u32 = 0xf << 16; -pub const NVME_CC_SHN: fn(u32) -> u32 = |_v| (((_v) & 0x3) << 14); +pub const NVME_CC_SHN: fn(u32) -> u32 = |_v| ((_v) & 0x3) << 14; pub const NVME_CC_SHN_MASK: u32 = 0x3 << 14; pub const NVME_CC_SHN_NONE: u32 = 0; -pub const NVME_CC_AMS: fn(u32) -> u32 = |_v| (((_v) & 0x7) << 11); +pub const NVME_CC_AMS: fn(u32) -> u32 = |_v| ((_v) & 0x7) << 11; pub const NVME_CC_AMS_MASK: u32 = 0x7 << 11; pub const NVME_CC_AMS_RR: u32 = 0; /* round-robin */ -pub const NVME_CC_MPS: fn(u32) -> u32 = |_v| ((((_v) - 12) & 0xf) << 7); +pub const NVME_CC_MPS: fn(u32) -> u32 = |_v| (((_v) - 12) & 0xf) << 7; pub const NVME_CC_MPS_MASK: u32 = 0xf << 7; -pub const NVME_CC_CSS: fn(u32) -> u32 = |_v| (((_v) & 0x7) << 4); +pub const NVME_CC_CSS: fn(u32) -> u32 = |_v| ((_v) & 0x7) << 4; pub const NVME_CC_CSS_MASK: u32 = 0x7 << 4; pub const NVME_CC_CSS_NVM: u32 = 0; pub const NVME_CC_EN: u32 = 1 << 0; @@ -34,7 +34,7 @@ pub const NVME_CSTS_RDY: u32 = 1 << 0; pub const NVME_AQA: usize = 0x0024; /* Admin Queue Attributes */ /* Admin Completion Queue Size */ -pub const NVME_AQA_ACQS: fn(u32) -> u32 = |_v| (((_v) - 1) << 16); +pub const NVME_AQA_ACQS: fn(u32) -> u32 = |_v| ((_v) - 1) << 16; /* Admin Submission Queue Size */ pub const NVME_AQA_ASQS: fn(u32) -> u32 = |_v| (_v) - 1; pub const NVME_ASQ: usize = 0x0028; /* Admin Submission Queue Base Address */ @@ -249,6 +249,7 @@ pub struct ComQueue { pub _phase: u16, } +#[allow(dead_code)] // may be used in the future, remove this line if used #[repr(C)] #[derive(Debug, Clone, Copy, Default)] pub struct SubQueueEntryIo { diff --git a/awkernel_lib/src/arch/x86_64/acpi/dmar.rs b/awkernel_lib/src/arch/x86_64/acpi/dmar.rs index 784258858..6bebb1833 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/dmar.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/dmar.rs @@ -113,7 +113,7 @@ impl<'a> Iterator for DmarEntryIter<'a> { } impl Dmar { - pub fn entries(&self) -> DmarEntryIter { + pub fn entries(&self) -> DmarEntryIter<'_> { DmarEntryIter { pointer: unsafe { (self as *const Dmar as *const u8).add(mem::size_of::()) }, remaining_length: self diff --git a/awkernel_lib/src/arch/x86_64/acpi/dmar/atsr.rs b/awkernel_lib/src/arch/x86_64/acpi/dmar/atsr.rs index 48ac5d22e..2614ff5a1 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/dmar/atsr.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/dmar/atsr.rs @@ -15,7 +15,7 @@ pub struct DmarAtsr { } impl DmarAtsr { - pub fn device_scopes(&self) -> DeviceScopeIter { + pub fn device_scopes(&self) -> DeviceScopeIter<'_> { DeviceScopeIter { pointer: unsafe { (self as *const DmarAtsr as *const u8).add(mem::size_of::()) diff --git a/awkernel_lib/src/arch/x86_64/acpi/dmar/dhrd.rs b/awkernel_lib/src/arch/x86_64/acpi/dmar/dhrd.rs index eefb37b61..3196a7db8 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/dmar/dhrd.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/dmar/dhrd.rs @@ -16,7 +16,7 @@ pub struct DmarDrhd { } impl DmarDrhd { - pub fn device_scopes(&self) -> DeviceScopeIter { + pub fn device_scopes(&self) -> DeviceScopeIter<'_> { DeviceScopeIter { pointer: unsafe { (self as *const DmarDrhd as *const u8).add(mem::size_of::()) diff --git a/awkernel_lib/src/arch/x86_64/acpi/dmar/rmrr.rs b/awkernel_lib/src/arch/x86_64/acpi/dmar/rmrr.rs index 26ef925d1..f2a0e30a9 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/dmar/rmrr.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/dmar/rmrr.rs @@ -17,7 +17,7 @@ pub struct DmarRmrr { } impl DmarRmrr { - pub fn device_scopes(&self) -> DeviceScopeIter { + pub fn device_scopes(&self) -> DeviceScopeIter<'_> { DeviceScopeIter { pointer: unsafe { (self as *const DmarRmrr as *const u8).add(mem::size_of::()) diff --git a/awkernel_lib/src/arch/x86_64/acpi/dmar/satc.rs b/awkernel_lib/src/arch/x86_64/acpi/dmar/satc.rs index a1b536272..18ec7ac0e 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/dmar/satc.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/dmar/satc.rs @@ -15,7 +15,7 @@ pub struct DmarSatc { } impl DmarSatc { - pub fn device_scopes(&self) -> DeviceScopeIter { + pub fn device_scopes(&self) -> DeviceScopeIter<'_> { DeviceScopeIter { pointer: unsafe { (self as *const DmarSatc as *const u8).add(mem::size_of::()) diff --git a/awkernel_lib/src/arch/x86_64/acpi/dmar/sidp.rs b/awkernel_lib/src/arch/x86_64/acpi/dmar/sidp.rs index b3544cbc7..620ba9036 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/dmar/sidp.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/dmar/sidp.rs @@ -14,7 +14,7 @@ pub struct DmarSidp { } impl DmarSidp { - pub fn device_scopes(&self) -> DeviceScopeIter { + pub fn device_scopes(&self) -> DeviceScopeIter<'_> { DeviceScopeIter { pointer: unsafe { (self as *const DmarSidp as *const u8).add(mem::size_of::()) diff --git a/awkernel_lib/src/arch/x86_64/acpi/srat.rs b/awkernel_lib/src/arch/x86_64/acpi/srat.rs index c96d46a0f..bd0167544 100644 --- a/awkernel_lib/src/arch/x86_64/acpi/srat.rs +++ b/awkernel_lib/src/arch/x86_64/acpi/srat.rs @@ -143,7 +143,7 @@ unsafe impl AcpiTable for Srat { } impl Srat { - pub fn entries(&self) -> SratEntryIter { + pub fn entries(&self) -> SratEntryIter<'_> { SratEntryIter { pointer: unsafe { (self as *const Srat as *const u8).add(mem::size_of::()) }, remaining_length: self diff --git a/awkernel_lib/src/context/x86_64.rs b/awkernel_lib/src/context/x86_64.rs index b3d8b010a..8d9a44254 100644 --- a/awkernel_lib/src/context/x86_64.rs +++ b/awkernel_lib/src/context/x86_64.rs @@ -48,7 +48,7 @@ impl crate::context::Context for Context { self.r12 = arg as u64; self.r13 = entry as usize as u64; - let entry_point_addr = entry_point as usize as u64; + let entry_point_addr = entry_point as *const () as u64; unsafe { core::arch::asm!("mov {}, rsp", lateout(reg) self.r15); diff --git a/awkernel_lib/src/device_tree/traits.rs b/awkernel_lib/src/device_tree/traits.rs index c10cedb4f..b60827fe4 100644 --- a/awkernel_lib/src/device_tree/traits.rs +++ b/awkernel_lib/src/device_tree/traits.rs @@ -7,5 +7,5 @@ pub trait HasNamedChildNode { fn has_children(&self) -> bool; /// Look for a child by its name - fn find_child(&self, name: &str) -> Option<&DeviceTreeNode>; + fn find_child(&self, name: &str) -> Option<&DeviceTreeNode<'_, A>>; } diff --git a/awkernel_lib/src/heap.rs b/awkernel_lib/src/heap.rs index 513d0e48d..c3b8df9f4 100644 --- a/awkernel_lib/src/heap.rs +++ b/awkernel_lib/src/heap.rs @@ -255,7 +255,7 @@ impl Talloc { /// Save the configuration and it will be restored when dropping `Guard`. #[inline] - pub fn save(&self) -> Guard { + pub fn save(&self) -> Guard<'_> { let (index, cpu_id) = Self::cpu_index(); let mask = 1 << cpu_id; let flag = mask & self.flags[index].load(Ordering::Relaxed); diff --git a/awkernel_lib/src/net/ether.rs b/awkernel_lib/src/net/ether.rs index 49558c15b..33b5bbea1 100644 --- a/awkernel_lib/src/net/ether.rs +++ b/awkernel_lib/src/net/ether.rs @@ -59,7 +59,7 @@ pub struct EtherExtracted<'a> { pub transport: TransportHdr<'a>, } -pub fn extract_headers(buf: &[u8]) -> Result { +pub fn extract_headers(buf: &[u8]) -> Result, &'static str> { let mut remain = buf.len(); if core::mem::size_of::() > remain { diff --git a/awkernel_lib/src/unwind.rs b/awkernel_lib/src/unwind.rs index 027d295a4..6d232f43b 100644 --- a/awkernel_lib/src/unwind.rs +++ b/awkernel_lib/src/unwind.rs @@ -14,7 +14,7 @@ where use alloc::boxed::Box; #[cfg(not(feature = "std"))] -pub fn catch_unwind(f: F) -> Result> +pub fn catch_unwind(f: F) -> Result> where F: FnOnce() -> R, { diff --git a/kernel/src/arch/x86_64/kernel_main.rs b/kernel/src/arch/x86_64/kernel_main.rs index 25418ea03..b3bbc163d 100644 --- a/kernel/src/arch/x86_64/kernel_main.rs +++ b/kernel/src/arch/x86_64/kernel_main.rs @@ -417,9 +417,12 @@ fn write_boot_images(offset: u64, mpboot_start: u64) { // Write non_primary_kernel_main. log::info!( "write the kernel entry of 0x{:08x} to 0x{main_addr:08x}", - non_primary_kernel_main as usize + non_primary_kernel_main as *const () as usize + ); + write_volatile( + main_addr.as_mut_ptr(), + non_primary_kernel_main as *const () as usize, ); - write_volatile(main_addr.as_mut_ptr(), non_primary_kernel_main as usize); // Write CR3. log::info!("write CR3 of 0x{cr3:08x} to 0x{cr3_phy_addr:08x}"); diff --git a/smoltcp/src/storage/assembler.rs b/smoltcp/src/storage/assembler.rs index 5a4dff13d..088d21c8d 100644 --- a/smoltcp/src/storage/assembler.rs +++ b/smoltcp/src/storage/assembler.rs @@ -327,7 +327,7 @@ impl Assembler { /// |--- 100 ---|--- 200 ---|--- 100 ---| /// /// An offset of 1500 would return the ranges: ``(1500, 1600), (1800, 1900)`` - pub fn iter_data(&self, first_offset: usize) -> AssemblerIter { + pub fn iter_data(&self, first_offset: usize) -> AssemblerIter<'_> { AssemblerIter::new(self, first_offset) } } From d72a76708f5757e37b661aa6e2af2fb245701008 Mon Sep 17 00:00:00 2001 From: Yuuki Takano Date: Wed, 19 Nov 2025 11:33:22 +0900 Subject: [PATCH 3/6] clippy Signed-off-by: Yuuki Takano --- awkernel_async_lib/src/dag/visit.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/awkernel_async_lib/src/dag/visit.rs b/awkernel_async_lib/src/dag/visit.rs index 4a853c831..529a5420f 100644 --- a/awkernel_async_lib/src/dag/visit.rs +++ b/awkernel_async_lib/src/dag/visit.rs @@ -133,7 +133,7 @@ IntoEdgeReferences! {delegate_impl [] } trait_template! { /// The graph’s `NodeId`s map to indices - #[allow(clippy::needless_arbitrary_self_type)] + #[allow(clippy::needless_arbitrary_self_type, dead_code)] pub trait NodeIndexable : GraphBase { @section self /// Return an upper bound of the node indices in the graph @@ -150,7 +150,7 @@ NodeIndexable! {delegate_impl []} trait_template! { /// A graph with a known node count. -#[allow(clippy::needless_arbitrary_self_type)] +#[allow(clippy::needless_arbitrary_self_type, dead_code)] pub trait NodeCount : GraphBase { @section self fn node_count(self: &Self) -> usize; @@ -244,7 +244,7 @@ where trait_template! { /// A graph that can create a map that tracks the visited status of its nodes. -#[allow(clippy::needless_arbitrary_self_type)] +#[allow(clippy::needless_arbitrary_self_type, dead_code)] pub trait Visitable : GraphBase { @section type /// The associated map type From b91052dd8f500e60514629e95925d59bf7df0fb2 Mon Sep 17 00:00:00 2001 From: Yuuki Takano Date: Wed, 19 Nov 2025 11:42:06 +0900 Subject: [PATCH 4/6] clippy Signed-off-by: Yuuki Takano --- awkernel_lib/src/arch/rv32/frame_allocator.rs | 2 +- awkernel_lib/src/arch/rv32/vm.rs | 18 +++++++++--------- awkernel_lib/src/arch/rv64/frame_allocator.rs | 2 +- awkernel_lib/src/arch/rv64/vm.rs | 18 +++++++++--------- 4 files changed, 20 insertions(+), 20 deletions(-) diff --git a/awkernel_lib/src/arch/rv32/frame_allocator.rs b/awkernel_lib/src/arch/rv32/frame_allocator.rs index e0466bede..09a524862 100644 --- a/awkernel_lib/src/arch/rv32/frame_allocator.rs +++ b/awkernel_lib/src/arch/rv32/frame_allocator.rs @@ -44,7 +44,7 @@ pub fn init_page_allocator() { } if let Some(allocator_ref) = allocator.as_mut() { allocator_ref.init( - PhyAddr::from_usize(ekernel as usize).ceil(), + PhyAddr::from_usize(ekernel as *const () as usize).ceil(), PhyAddr::from_usize(MEMORY_END as usize).floor(), ); } else { diff --git a/awkernel_lib/src/arch/rv32/vm.rs b/awkernel_lib/src/arch/rv32/vm.rs index 36369631c..48de7708a 100644 --- a/awkernel_lib/src/arch/rv32/vm.rs +++ b/awkernel_lib/src/arch/rv32/vm.rs @@ -201,8 +201,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(stext as usize), - VirtAddr::from_usize(etext as usize), + VirtAddr::from_usize(stext as *const () as usize), + VirtAddr::from_usize(etext as *const () as usize), MapType::Identical, MapPermission::R | MapPermission::X, ), @@ -214,8 +214,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(srodata as usize), - VirtAddr::from_usize(erodata as usize), + VirtAddr::from_usize(srodata as *const () as usize), + VirtAddr::from_usize(erodata as *const () as usize), MapType::Identical, MapPermission::R, ), @@ -227,8 +227,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(sdata as usize), - VirtAddr::from_usize(edata as usize), + VirtAddr::from_usize(sdata as *const () as usize), + VirtAddr::from_usize(edata as *const () as usize), MapType::Identical, MapPermission::R | MapPermission::W, ), @@ -240,8 +240,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(sbss_with_stack as usize), - VirtAddr::from_usize(ebss as usize), + VirtAddr::from_usize(sbss_with_stack as *const () as usize), + VirtAddr::from_usize(ebss as *const () as usize), MapType::Identical, MapPermission::R | MapPermission::W, ), @@ -253,7 +253,7 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(ekernel as usize), + VirtAddr::from_usize(ekernel as *const () as usize), VirtAddr::from_usize(super::address::MEMORY_END as usize), MapType::Identical, MapPermission::R | MapPermission::W, diff --git a/awkernel_lib/src/arch/rv64/frame_allocator.rs b/awkernel_lib/src/arch/rv64/frame_allocator.rs index e0466bede..09a524862 100644 --- a/awkernel_lib/src/arch/rv64/frame_allocator.rs +++ b/awkernel_lib/src/arch/rv64/frame_allocator.rs @@ -44,7 +44,7 @@ pub fn init_page_allocator() { } if let Some(allocator_ref) = allocator.as_mut() { allocator_ref.init( - PhyAddr::from_usize(ekernel as usize).ceil(), + PhyAddr::from_usize(ekernel as *const () as usize).ceil(), PhyAddr::from_usize(MEMORY_END as usize).floor(), ); } else { diff --git a/awkernel_lib/src/arch/rv64/vm.rs b/awkernel_lib/src/arch/rv64/vm.rs index bb330ad66..ed2d32de8 100644 --- a/awkernel_lib/src/arch/rv64/vm.rs +++ b/awkernel_lib/src/arch/rv64/vm.rs @@ -201,8 +201,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(stext as usize), - VirtAddr::from_usize(etext as usize), + VirtAddr::from_usize(stext as *const () as usize), + VirtAddr::from_usize(etext as *const () as usize), MapType::Identical, MapPermission::R | MapPermission::X, ), @@ -214,8 +214,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(srodata as usize), - VirtAddr::from_usize(erodata as usize), + VirtAddr::from_usize(srodata as *const () as usize), + VirtAddr::from_usize(erodata as *const () as usize), MapType::Identical, MapPermission::R, ), @@ -227,8 +227,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(sdata as usize), - VirtAddr::from_usize(edata as usize), + VirtAddr::from_usize(sdata as *const () as usize), + VirtAddr::from_usize(edata as *const () as usize), MapType::Identical, MapPermission::R | MapPermission::W, ), @@ -240,8 +240,8 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(sbss_with_stack as usize), - VirtAddr::from_usize(ebss as usize), + VirtAddr::from_usize(sbss_with_stack as *const () as usize), + VirtAddr::from_usize(ebss as *const () as usize), MapType::Identical, MapPermission::R | MapPermission::W, ), @@ -253,7 +253,7 @@ impl MemorySet { } memory_set.push( MapArea::new( - VirtAddr::from_usize(ekernel as usize), + VirtAddr::from_usize(ekernel as *const () as usize), VirtAddr::from_usize(super::address::MEMORY_END as usize), MapType::Identical, MapPermission::R | MapPermission::W, From 897907c70634e45e342ec95c4e3b074f719ab5f3 Mon Sep 17 00:00:00 2001 From: Yuuki Takano Date: Wed, 19 Nov 2025 12:01:00 +0900 Subject: [PATCH 5/6] clippy Signed-off-by: Yuuki Takano --- awkernel_async_lib/src/time_interval.rs | 9 ++------- awkernel_drivers/src/pcie/intel/igb/igb_hw.rs | 7 +++---- awkernel_drivers/src/pcie/intel/igc.rs | 4 ++-- .../src/pcie/intel/ixgbe/ixgbe_operations.rs | 2 +- awkernel_drivers/src/pcie/virtio/virtio_net.rs | 2 +- awkernel_lib/src/device_tree/prop.rs | 2 +- awkernel_lib/src/file/fatfs/boot_sector.rs | 4 +++- awkernel_lib/src/file/fatfs/file.rs | 4 ++-- awkernel_lib/src/file/fatfs/table.rs | 5 +---- awkernel_lib/src/unwind.rs | 2 +- kernel/src/arch/aarch64/types.rs | 2 +- 11 files changed, 18 insertions(+), 25 deletions(-) diff --git a/awkernel_async_lib/src/time_interval.rs b/awkernel_async_lib/src/time_interval.rs index 9b8dd09a9..96ce16219 100644 --- a/awkernel_async_lib/src/time_interval.rs +++ b/awkernel_async_lib/src/time_interval.rs @@ -40,7 +40,7 @@ use core::{ use futures::Stream; use futures::StreamExt; -#[derive(Debug, Clone, Copy, PartialEq, Eq)] +#[derive(Default, Debug, Clone, Copy, PartialEq, Eq)] #[allow(unused)] pub enum MissedTickBehavior { /// Ticks as fast as possible until caught up. @@ -50,6 +50,7 @@ pub enum MissedTickBehavior { /// Expected ticks: | 1 | 2 | 3 | 4 | 5 | 6 | /// Actual ticks: | work -----| delay | work | work | work -| work -----| /// ``` + #[default] Burst, /// Ticks at the next available interval after the delay. @@ -71,12 +72,6 @@ pub enum MissedTickBehavior { Skip, } -impl Default for MissedTickBehavior { - fn default() -> Self { - Self::Burst - } -} - /// Creates a new interval that ticks at the specified `period`. /// The first tick completes immediately. /// diff --git a/awkernel_drivers/src/pcie/intel/igb/igb_hw.rs b/awkernel_drivers/src/pcie/intel/igb/igb_hw.rs index 6a92916e5..661dae9de 100644 --- a/awkernel_drivers/src/pcie/intel/igb/igb_hw.rs +++ b/awkernel_drivers/src/pcie/intel/igb/igb_hw.rs @@ -6005,9 +6005,8 @@ impl IgbHw { // operation, while the smaller eeproms are capable of an // 8-byte PAGE WRITE operation. Break the inner loop to pass // new address - if (((offset + widx as u32) * 2) - % self.eeprom.page_size.ok_or(IgbDriverErr::EEPROM)? as u32) - == 0 + if ((offset + widx as u32) * 2) + .is_multiple_of(self.eeprom.page_size.ok_or(IgbDriverErr::EEPROM)? as u32) { self.standby_eeprom(info)?; break; @@ -6215,7 +6214,7 @@ impl IgbHw { let mut i = 0; let mut add; while i < data.len() { - let act_offset = if (offset + i as u32) % 2 != 0 { + let act_offset = if !(offset + i as u32).is_multiple_of(2) { add = 1; bank_offset as u32 + (offset + i as u32 - 1) * 2 } else { diff --git a/awkernel_drivers/src/pcie/intel/igc.rs b/awkernel_drivers/src/pcie/intel/igc.rs index 2a15579bf..cbae69247 100644 --- a/awkernel_drivers/src/pcie/intel/igc.rs +++ b/awkernel_drivers/src/pcie/intel/igc.rs @@ -1024,8 +1024,8 @@ fn igc_allocate_queues( info: &PCIeInfo, irqs: &[IRQ], ) -> Result<(Vec, BTreeMap), PCIeDeviceErr> { - assert!(core::mem::size_of::() % PAGESIZE == 0); - assert!(core::mem::size_of::() % PAGESIZE == 0); + assert!(core::mem::size_of::().is_multiple_of(PAGESIZE)); + assert!(core::mem::size_of::().is_multiple_of(PAGESIZE)); let mut irq_to_queue = BTreeMap::new(); let mut que = Vec::with_capacity(irqs.len()); diff --git a/awkernel_drivers/src/pcie/intel/ixgbe/ixgbe_operations.rs b/awkernel_drivers/src/pcie/intel/ixgbe/ixgbe_operations.rs index 57c9998f5..aa436e2db 100644 --- a/awkernel_drivers/src/pcie/intel/ixgbe/ixgbe_operations.rs +++ b/awkernel_drivers/src/pcie/intel/ixgbe/ixgbe_operations.rs @@ -2251,7 +2251,7 @@ pub fn hic_unlocked( } // Calculate length in DWORDs. We must be DWORD aligned - if length % (core::mem::size_of::() as u32) != 0 { + if !length.is_multiple_of(core::mem::size_of::() as u32) { log::debug!("Buffer length failure, not aligned to dword"); return Err(InvalidArgument); } diff --git a/awkernel_drivers/src/pcie/virtio/virtio_net.rs b/awkernel_drivers/src/pcie/virtio/virtio_net.rs index bf34035e6..b2a26f7bd 100644 --- a/awkernel_drivers/src/pcie/virtio/virtio_net.rs +++ b/awkernel_drivers/src/pcie/virtio/virtio_net.rs @@ -1069,7 +1069,7 @@ impl VirtioNetInner { let should_kick = { let queue_idx = (vq_idx / 2) as usize; let mut node = MCSNode::new(); - let vq = if vq_idx % 2 == 0 { + let vq = if vq_idx.is_multiple_of(2) { &mut self.virtqueues[queue_idx].rx.lock(&mut node) } else { &mut self.virtqueues[queue_idx].tx.lock(&mut node) diff --git a/awkernel_lib/src/device_tree/prop.rs b/awkernel_lib/src/device_tree/prop.rs index 75bbf39de..0651d4433 100644 --- a/awkernel_lib/src/device_tree/prop.rs +++ b/awkernel_lib/src/device_tree/prop.rs @@ -274,7 +274,7 @@ impl<'a, A: Allocator + Clone> NodeProperty<'a, A> { } } _ => { - let a = raw_value.len() % BLOCK_SIZE == 0; + let a = raw_value.len().is_multiple_of(BLOCK_SIZE); let b = *safe_index(raw_value, 0)? != b'\0' && *safe_index(raw_value, raw_value.len() - 1)? == b'\0' && raw_value.is_ascii(); diff --git a/awkernel_lib/src/file/fatfs/boot_sector.rs b/awkernel_lib/src/file/fatfs/boot_sector.rs index 4b3e0fb8d..23d0ef334 100644 --- a/awkernel_lib/src/file/fatfs/boot_sector.rs +++ b/awkernel_lib/src/file/fatfs/boot_sector.rs @@ -228,7 +228,9 @@ impl BiosParameterBlock { ); return Err(Error::CorruptedFileSystem); } - if (u32::from(self.root_entries) * DIR_ENTRY_SIZE) % u32::from(self.bytes_per_sector) != 0 { + if (u32::from(self.root_entries) * DIR_ENTRY_SIZE) + .is_multiple_of(u32::from(self.bytes_per_sector)) + { log::warn!("Root entries should fill sectors fully"); } Ok(()) diff --git a/awkernel_lib/src/file/fatfs/file.rs b/awkernel_lib/src/file/fatfs/file.rs index 495b04f6f..e40fa6a70 100644 --- a/awkernel_lib/src/file/fatfs/file.rs +++ b/awkernel_lib/src/file/fatfs/file.rs @@ -305,7 +305,7 @@ impl Read for File { @@ -391,7 +391,7 @@ impl Write for File fat.read_u16_le(), _ => fat.read_u8().map(u16::from), }; - let packed_val = match res { - Err(err) => return Err(err.into()), - Ok(n) => n, - }; + let packed_val = res?; let val = match cluster & 1 { 0 => packed_val & 0x0FFF, _ => (packed_val << 8) | (prev_packed_val >> 12), diff --git a/awkernel_lib/src/unwind.rs b/awkernel_lib/src/unwind.rs index 6d232f43b..5acd92a50 100644 --- a/awkernel_lib/src/unwind.rs +++ b/awkernel_lib/src/unwind.rs @@ -1,7 +1,7 @@ use core::any::Any; #[cfg(feature = "std")] -pub fn catch_unwind(f: F) -> Result> +pub fn catch_unwind(f: F) -> Result> where F: FnOnce() -> R, { diff --git a/kernel/src/arch/aarch64/types.rs b/kernel/src/arch/aarch64/types.rs index 476b8ddf2..816944612 100644 --- a/kernel/src/arch/aarch64/types.rs +++ b/kernel/src/arch/aarch64/types.rs @@ -1,7 +1,7 @@ use core::fmt; pub fn ceiling_div(size: usize, units: usize) -> usize { - (size / units) + (size % units != 0) as usize + (size / units) + (!size.is_multiple_of(units) as usize) } pub fn align_up(length: usize, alignment: usize) -> usize { From b09cabe1c65ac684f903837ff1f85b4670fbf98b Mon Sep 17 00:00:00 2001 From: Yuuki Takano Date: Wed, 19 Nov 2025 12:08:21 +0900 Subject: [PATCH 6/6] add negation Signed-off-by: Yuuki Takano --- awkernel_lib/src/file/fatfs/boot_sector.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awkernel_lib/src/file/fatfs/boot_sector.rs b/awkernel_lib/src/file/fatfs/boot_sector.rs index 23d0ef334..976a5fb0a 100644 --- a/awkernel_lib/src/file/fatfs/boot_sector.rs +++ b/awkernel_lib/src/file/fatfs/boot_sector.rs @@ -228,7 +228,7 @@ impl BiosParameterBlock { ); return Err(Error::CorruptedFileSystem); } - if (u32::from(self.root_entries) * DIR_ENTRY_SIZE) + if !(u32::from(self.root_entries) * DIR_ENTRY_SIZE) .is_multiple_of(u32::from(self.bytes_per_sector)) { log::warn!("Root entries should fill sectors fully");