diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-18 02:49:50 +0000 |
commit | 9835e2ae736235810b4ea1c162ca5e65c547e770 (patch) | |
tree | 3fcebf40ed70e581d776a8a4c65923e8ec20e026 /vendor/rustix/src/backend/libc/conv.rs | |
parent | Releasing progress-linux version 1.70.0+dfsg2-1~progress7.99u1. (diff) | |
download | rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.tar.xz rustc-9835e2ae736235810b4ea1c162ca5e65c547e770.zip |
Merging upstream version 1.71.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/rustix/src/backend/libc/conv.rs')
-rw-r--r-- | vendor/rustix/src/backend/libc/conv.rs | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/vendor/rustix/src/backend/libc/conv.rs b/vendor/rustix/src/backend/libc/conv.rs index 1e74ea9ba..b827d0bbc 100644 --- a/vendor/rustix/src/backend/libc/conv.rs +++ b/vendor/rustix/src/backend/libc/conv.rs @@ -88,20 +88,22 @@ pub(super) fn ret_u32(raw: c::c_int) -> io::Result<u32> { } #[inline] -pub(super) fn ret_ssize_t(raw: c::ssize_t) -> io::Result<c::ssize_t> { +pub(super) fn ret_usize(raw: c::ssize_t) -> io::Result<usize> { if raw == -1 { Err(io::Errno::last_os_error()) } else { - Ok(raw) + debug_assert!(raw >= 0); + Ok(raw as usize) } } #[inline] -pub(super) fn syscall_ret_ssize_t(raw: c::c_long) -> io::Result<c::ssize_t> { +pub(super) fn syscall_ret_usize(raw: c::c_long) -> io::Result<usize> { if raw == -1 { Err(io::Errno::last_os_error()) } else { - Ok(raw as c::ssize_t) + debug_assert!(raw >= 0); + Ok(raw as c::ssize_t as usize) } } @@ -210,13 +212,13 @@ pub(super) fn send_recv_len(len: usize) -> i32 { /// Convert the return value of a `send` or `recv` call. #[cfg(not(windows))] #[inline] -pub(super) fn ret_send_recv(len: isize) -> io::Result<c::ssize_t> { - ret_ssize_t(len) +pub(super) fn ret_send_recv(len: isize) -> io::Result<usize> { + ret_usize(len) } /// Convert the return value of a `send` or `recv` call. #[cfg(windows)] #[inline] -pub(super) fn ret_send_recv(len: i32) -> io::Result<c::ssize_t> { - ret_ssize_t(len as isize) +pub(super) fn ret_send_recv(len: i32) -> io::Result<usize> { + ret_usize(len as isize) } |