Skip to content

Commit a6b5b32

Browse files
committed
Use i32 in SystemError::Unknown instead of nix Errno
This way users of `drm` can match on constants from `libc`, or can convert it to the error types from any version of `nix` or `rustix`. This addresses a bit of awkwardness in Smithay/smithay#1162 and rust-windowing/softbuffer#164. This should eliminate nix as a "public dependency" of `drm`, though it's still exposed by `drm-ffi`.
1 parent 250fa4a commit a6b5b32

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drm-ffi/src/result.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,8 @@ pub enum SystemError {
3838

3939
/// Unknown system error.
4040
Unknown {
41-
/// Unknown [`nix::errno::Errno`] returned by the system call.
42-
errno: Errno,
41+
/// Unknown errno value returned by the system call.
42+
errno: i32,
4343
},
4444
}
4545

@@ -53,7 +53,7 @@ impl fmt::Display for SystemError {
5353
SystemError::PermissionDenied => "permission denied",
5454
SystemError::UnknownFourcc => "unknown fourcc",
5555
SystemError::Unknown { errno } => {
56-
return write!(fmt, "unknown system error: {}", errno)
56+
return write!(fmt, "unknown system error: {}", Errno::from_i32(*errno))
5757
}
5858
})
5959
}
@@ -69,7 +69,9 @@ impl From<Errno> for SystemError {
6969
Errno::EINVAL => SystemError::InvalidArgument,
7070
Errno::ENOTTY => SystemError::InvalidFileDescriptor,
7171
Errno::EACCES => SystemError::PermissionDenied,
72-
_ => SystemError::Unknown { errno },
72+
_ => SystemError::Unknown {
73+
errno: errno as i32,
74+
},
7375
}
7476
}
7577
}

0 commit comments

Comments
 (0)