Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion compio-driver/src/sys/fusion/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl super::Extra {
/// Fused [`OpCode`]
///
/// This trait encapsulates both operation for `io-uring` and `polling`
pub trait OpCode: PollOpCode + IourOpCode {}
pub unsafe trait OpCode: PollOpCode + IourOpCode {}

impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This blanket implementation must be marked as unsafe since it implements the unsafe trait OpCode. Change this to: unsafe impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {}

Suggested change
impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {}
unsafe impl<T: PollOpCode + IourOpCode + ?Sized> OpCode for T {}

Copilot uses AI. Check for mistakes.

Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/sys/iocp/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ pub enum OpType {
}

/// Abstraction of IOCP operations.
pub trait OpCode {
pub unsafe trait OpCode {
/// Determines that the operation is really overlapped defined by Windows
/// API. If not, the driver will try to operate it in another thread.
fn op_type(&self) -> OpType {
Expand Down
4 changes: 2 additions & 2 deletions compio-driver/src/sys/iocp/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ impl<
}
}

impl OpCode for CloseFile {
unsafe impl OpCode for CloseFile {
fn op_type(&self) -> OpType {
OpType::Blocking
}
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<S: AsFd> OpCode for ShutdownSocket<S> {
}
}

impl OpCode for CloseSocket {
unsafe impl OpCode for CloseSocket {
fn op_type(&self) -> OpType {
OpType::Blocking
}
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/sys/iour/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ impl From<io_uring::squeue::Entry128> for OpEntry {
}

/// Abstraction of io-uring operations.
pub trait OpCode {
pub unsafe trait OpCode {
/// Create submission entry.
fn create_entry(self: Pin<&mut Self>) -> OpEntry;

Expand Down
20 changes: 10 additions & 10 deletions compio-driver/src/sys/iour/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ impl<
}
}

impl OpCode for OpenFile {
unsafe impl OpCode for OpenFile {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::OpenAt::new(Fd(libc::AT_FDCWD), self.path.as_ptr())
.flags(self.flags | libc::O_CLOEXEC)
Expand All @@ -71,7 +71,7 @@ impl OpCode for OpenFile {
}
}

impl OpCode for CloseFile {
unsafe impl OpCode for CloseFile {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::Close::new(Fd(self.fd.as_fd().as_raw_fd()))
.build()
Expand Down Expand Up @@ -155,7 +155,7 @@ impl PathStat {
}
}

impl OpCode for PathStat {
unsafe impl OpCode for PathStat {
fn create_entry(mut self: Pin<&mut Self>) -> OpEntry {
let mut flags = libc::AT_EMPTY_PATH;
if !self.follow_symlink {
Expand Down Expand Up @@ -309,7 +309,7 @@ impl<S: AsFd> OpCode for Sync<S> {
}
}

impl OpCode for Unlink {
unsafe impl OpCode for Unlink {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::UnlinkAt::new(Fd(libc::AT_FDCWD), self.path.as_ptr())
.flags(if self.dir { libc::AT_REMOVEDIR } else { 0 })
Expand All @@ -318,7 +318,7 @@ impl OpCode for Unlink {
}
}

impl OpCode for CreateDir {
unsafe impl OpCode for CreateDir {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::MkDirAt::new(Fd(libc::AT_FDCWD), self.path.as_ptr())
.mode(self.mode)
Expand All @@ -327,7 +327,7 @@ impl OpCode for CreateDir {
}
}

impl OpCode for Rename {
unsafe impl OpCode for Rename {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::RenameAt::new(
Fd(libc::AT_FDCWD),
Expand All @@ -340,7 +340,7 @@ impl OpCode for Rename {
}
}

impl OpCode for Symlink {
unsafe impl OpCode for Symlink {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::SymlinkAt::new(
Fd(libc::AT_FDCWD),
Expand All @@ -352,7 +352,7 @@ impl OpCode for Symlink {
}
}

impl OpCode for HardLink {
unsafe impl OpCode for HardLink {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::LinkAt::new(
Fd(libc::AT_FDCWD),
Expand All @@ -365,7 +365,7 @@ impl OpCode for HardLink {
}
}

impl OpCode for CreateSocket {
unsafe impl OpCode for CreateSocket {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
if super::is_op_supported(opcode::Socket::CODE) {
opcode::Socket::new(
Expand Down Expand Up @@ -397,7 +397,7 @@ impl<S: AsFd> OpCode for ShutdownSocket<S> {
}
}

impl OpCode for CloseSocket {
unsafe impl OpCode for CloseSocket {
fn create_entry(self: Pin<&mut Self>) -> OpEntry {
opcode::Close::new(Fd(self.fd.as_fd().as_raw_fd()))
.build()
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/sys/poll/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl From<WaitArg> for Track {
/// `Some(OpType::Fd)` with same fds as the `WaitArg`s. Similarly, if
/// `pre_submit` returns `Decision::Aio`, `op_type` must return
/// `Some(OpType::Aio)` with the correct `aiocb` pointer.
pub trait OpCode {
pub unsafe trait OpCode {
/// Perform the operation before submit, and return [`Decision`] to
/// indicate whether submitting the operation to polling is required.
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision>;
Expand Down
20 changes: 10 additions & 10 deletions compio-driver/src/sys/poll/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ impl<
}
}

impl OpCode for OpenFile {
unsafe impl OpCode for OpenFile {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand All @@ -82,7 +82,7 @@ impl OpCode for OpenFile {
}
}

impl OpCode for CloseFile {
unsafe impl OpCode for CloseFile {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand Down Expand Up @@ -176,7 +176,7 @@ impl PathStat {
}
}

impl OpCode for PathStat {
unsafe impl OpCode for PathStat {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand Down Expand Up @@ -526,7 +526,7 @@ impl<S: AsFd> OpCode for Sync<S> {
}
}

impl OpCode for Unlink {
unsafe impl OpCode for Unlink {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand All @@ -541,7 +541,7 @@ impl OpCode for Unlink {
}
}

impl OpCode for CreateDir {
unsafe impl OpCode for CreateDir {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand All @@ -552,7 +552,7 @@ impl OpCode for CreateDir {
}
}

impl OpCode for Rename {
unsafe impl OpCode for Rename {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand All @@ -563,7 +563,7 @@ impl OpCode for Rename {
}
}

impl OpCode for Symlink {
unsafe impl OpCode for Symlink {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand All @@ -574,7 +574,7 @@ impl OpCode for Symlink {
}
}

impl OpCode for HardLink {
unsafe impl OpCode for HardLink {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand Down Expand Up @@ -645,7 +645,7 @@ impl CreateSocket {
}
}

impl OpCode for CreateSocket {
unsafe impl OpCode for CreateSocket {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand All @@ -667,7 +667,7 @@ impl<S: AsFd> OpCode for ShutdownSocket<S> {
}
}

impl OpCode for CloseSocket {
unsafe impl OpCode for CloseSocket {
fn pre_submit(self: Pin<&mut Self>) -> io::Result<Decision> {
Ok(Decision::Blocking)
}
Expand Down
2 changes: 1 addition & 1 deletion compio-driver/src/sys/stub/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ impl Extra {
}

/// Operations.
pub trait OpCode {}
pub unsafe trait OpCode {}

pub mod op;

Expand Down
20 changes: 10 additions & 10 deletions compio-driver/src/sys/stub/op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ impl<
{
}

impl OpCode for OpenFile {}
unsafe impl OpCode for OpenFile {}

impl OpCode for CloseFile {}
unsafe impl OpCode for CloseFile {}

impl<S: AsFd> OpCode for TruncateFile<S> {}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation of the unsafe trait OpCode must be marked with unsafe. Change this to: unsafe impl<S: AsFd> OpCode for TruncateFile {}

Suggested change
impl<S: AsFd> OpCode for TruncateFile<S> {}
unsafe impl<S: AsFd> OpCode for TruncateFile<S> {}

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -68,7 +68,7 @@ impl PathStat {
}
}

impl OpCode for PathStat {}
unsafe impl OpCode for PathStat {}

impl IntoInner for PathStat {
type Inner = Stat;
Expand Down Expand Up @@ -96,21 +96,21 @@ impl<T: IoVectoredBuf, S: AsFd> OpCode for WriteVectored<T, S> {}

impl<S: AsFd> OpCode for Sync<S> {}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation of the unsafe trait OpCode must be marked with unsafe. Change this to: unsafe impl<S: AsFd> OpCode for Sync {}

Suggested change
impl<S: AsFd> OpCode for Sync<S> {}
unsafe impl<S: AsFd> OpCode for Sync<S> {}

Copilot uses AI. Check for mistakes.

impl OpCode for Unlink {}
unsafe impl OpCode for Unlink {}

impl OpCode for CreateDir {}
unsafe impl OpCode for CreateDir {}

impl OpCode for Rename {}
unsafe impl OpCode for Rename {}

impl OpCode for Symlink {}
unsafe impl OpCode for Symlink {}

impl OpCode for HardLink {}
unsafe impl OpCode for HardLink {}

impl OpCode for CreateSocket {}
unsafe impl OpCode for CreateSocket {}

impl<S: AsFd> OpCode for ShutdownSocket<S> {}
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This implementation of the unsafe trait OpCode must be marked with unsafe. Change this to: unsafe impl<S: AsFd> OpCode for ShutdownSocket {}

Suggested change
impl<S: AsFd> OpCode for ShutdownSocket<S> {}
unsafe impl<S: AsFd> OpCode for ShutdownSocket<S> {}

Copilot uses AI. Check for mistakes.

impl OpCode for CloseSocket {}
unsafe impl OpCode for CloseSocket {}

impl<S: AsFd> OpCode for Accept<S> {}

Comment on lines 115 to 116
Copy link

Copilot AI Jan 28, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These implementations of the unsafe trait OpCode must be marked with unsafe. Change to: unsafe impl<S: AsFd> OpCode for Accept {} and unsafe impl<S: AsFd> OpCode for Connect {}

Copilot uses AI. Check for mistakes.
Expand Down
2 changes: 1 addition & 1 deletion compio-process/src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ impl WaitProcess {
}
}

impl OpCode for WaitProcess {
unsafe impl OpCode for WaitProcess {
fn op_type(&self) -> OpType {
OpType::Event(self.child.as_raw_handle() as _)
}
Expand Down
2 changes: 1 addition & 1 deletion compio-runtime/tests/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ fn win32_event() {
event: OwnedHandle,
}

impl OpCode for WaitEvent {
unsafe impl OpCode for WaitEvent {
fn op_type(&self) -> OpType {
OpType::Event(self.event.as_raw_handle() as _)
}
Expand Down
Loading