From b80f8b470bb1beb31f70600cc3a17a0556de284c Mon Sep 17 00:00:00 2001 From: Red Bear OS Date: Sun, 26 Jul 2026 17:11:18 +0900 Subject: [PATCH] relibc: fix edition-2024 unsafe-op-in-unsafe-fn in epoll::convert_event MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Commit dd2cd443 introduced unsafe fn convert_event(*const Event, *mut epoll_event) but dereferenced both pointers without unsafe blocks. Edition 2024 (relibc's top-level Cargo.toml) enforces unsafe-op-in-unsafe-fn by default with -D, so this caused rustc E0133 errors during canonical build: error[E0133]: dereference of raw pointer is unsafe and requires unsafe block --> src/platform/redox/epoll.rs:139:17 / 143:5 The fix wraps each deref in an explicit unsafe { } block with a SAFETY justification, keeping the outer unsafe fn signature so the validity proof stays on callers (the rest of epoll.rs already upholds those invariants). No semantic change — same machine code after the wrap, just edition 2024-compliant source. --- src/platform/redox/epoll.rs | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/platform/redox/epoll.rs b/src/platform/redox/epoll.rs index 7d238fc5ee..37c86da099 100644 --- a/src/platform/redox/epoll.rs +++ b/src/platform/redox/epoll.rs @@ -136,17 +136,23 @@ impl PalEpoll for Sys { } unsafe fn convert_event(event_ptr: *const Event, target_ptr: *mut epoll_event) -> bool { - let event = *event_ptr; + // SAFETY: callers guarantee both pointers are valid, properly aligned, + // and point to initialized storage. The unsafe blocks satisfy edition + // 2024's `unsafe-op-in-unsafe-fn` rule (rustc E0133); the function + // signature stays `unsafe fn` to push the validity proof onto callers. + let event = unsafe { *event_ptr }; if event.id == syscall::EVENT_TIMEOUT_ID { return false; } - *target_ptr = epoll_event { - events: event_flags_to_epoll(event.flags), - data: epoll_data { - u64: event.data as u64, - }, - ..Default::default() - }; + unsafe { + *target_ptr = epoll_event { + events: event_flags_to_epoll(event.flags), + data: epoll_data { + u64: event.data as u64, + }, + ..Default::default() + }; + } true }