mirror of
https://github.com/kvorschk/Magisk.git
synced 2026-12-05 23:14:03 -05:00
Simplify LibcReturn
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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<()> {
|
||||
|
||||
Reference in New Issue
Block a user