relibc: fix edition-2024 unsafe-op-in-unsafe-fn in epoll::convert_event

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.
This commit is contained in:
Red Bear OS
2026-07-26 17:11:18 +09:00
parent 79685cbe02
commit b80f8b470b
+14 -8
View File
@@ -136,17 +136,23 @@ impl PalEpoll for Sys {
} }
unsafe fn convert_event(event_ptr: *const Event, target_ptr: *mut epoll_event) -> bool { 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 { if event.id == syscall::EVENT_TIMEOUT_ID {
return false; return false;
} }
*target_ptr = epoll_event { unsafe {
events: event_flags_to_epoll(event.flags), *target_ptr = epoll_event {
data: epoll_data { events: event_flags_to_epoll(event.flags),
u64: event.data as u64, data: epoll_data {
}, u64: event.data as u64,
..Default::default() },
}; ..Default::default()
};
}
true true
} }