Simplify LibcReturn

This commit is contained in:
topjohnwu
2025-09-08 10:55:57 -07:00
parent a75c335261
commit ea5fe7525d
7 changed files with 64 additions and 78 deletions
+2 -2
View File
@@ -64,7 +64,7 @@ fn file_set_prop(name: &Utf8CStr, value: Option<&Utf8CStr>) -> LoggedResult<()>
{
let mut f = unsafe {
mkstemp(tmp.as_mut_ptr())
.as_os_result("mkstemp", None, None)
.into_os_result("mkstemp", None, None)
.map(|fd| File::from_raw_fd(fd))?
};
f.write_all(value.as_bytes())?;
@@ -96,7 +96,7 @@ fn proto_write_props(props: &PersistentProperties) -> LoggedResult<()> {
{
let f = unsafe {
mkstemp(tmp.as_mut_ptr())
.as_os_result("mkstemp", None, None)
.into_os_result("mkstemp", None, None)
.map(|fd| File::from_raw_fd(fd))?
};
debug!("resetprop: encode with protobuf [{}]", tmp);
+3 -2
View File
@@ -201,9 +201,10 @@ impl SuAppContext<'_> {
events: libc::POLLIN,
revents: 0,
};
if unsafe { libc::poll(&mut pfd, 1, 70 * 1000).as_os_result("poll", None, None)? } == 0
if unsafe { libc::poll(&mut pfd, 1, 70 * 1000).into_os_result("poll", None, None)? }
== 0
{
Err(OsError::with_os_error(libc::ETIMEDOUT, "poll", None, None))?;
Err(OsError::new(libc::ETIMEDOUT, "poll", None, None))?;
}
fd
+1 -1
View File
@@ -84,7 +84,7 @@ fn resize_pty(outfd: i32) {
fn splice(fd_in: RawFd, fd_out: RawFd, len: usize, flags: u32) -> OsResult<'static, ssize_t> {
unsafe { libc::splice(fd_in, null_mut(), fd_out, null_mut(), len, flags) }
.as_os_result("splice", None, None)
.into_os_result("splice", None, None)
}
fn pump_via_copy(infd: RawFd, outfd: RawFd) -> LoggedResult<()> {