Skip to content

Commit f21bd7a

Browse files
committed
Use/fix ret_* helpers for certain libc functions
- use ret_usize() instead of ret_send_recv() for c::recvmsg(), as it always returns c::ssize_t - use ret_usize() instead of ret_send_recv() for c::sendmsg(), as it always returns c::ssize_t - change the ret_send_recv() used on OSes different than Windows, Redox, and wasi to take c::ssize_t as parameter, as it is what c::recv(), c::send(), c::recvfrom(), and c::sendto() return on most/all of those OSes
1 parent d51b195 commit f21bd7a

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/backend/libc/conv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ pub(super) fn send_recv_len(len: usize) -> i32 {
170170
/// Convert the return value of a `send` or `recv` call.
171171
#[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))]
172172
#[inline]
173-
pub(super) fn ret_send_recv(len: isize) -> io::Result<usize> {
173+
pub(super) fn ret_send_recv(len: c::ssize_t) -> io::Result<usize> {
174174
ret_usize(len)
175175
}
176176

src/backend/libc/net/syscalls.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ pub(crate) fn recvmsg(
329329

330330
with_recv_msghdr(&mut storage, iov, control, |msghdr| {
331331
let result = unsafe {
332-
ret_send_recv(c::recvmsg(
332+
ret_usize(c::recvmsg(
333333
borrowed_fd(sockfd),
334334
msghdr,
335335
bitflags_bits!(msg_flags),
@@ -364,7 +364,7 @@ pub(crate) fn sendmsg(
364364
msg_flags: SendFlags,
365365
) -> io::Result<usize> {
366366
with_noaddr_msghdr(iov, control, |msghdr| unsafe {
367-
ret_send_recv(c::sendmsg(
367+
ret_usize(c::sendmsg(
368368
borrowed_fd(sockfd),
369369
&msghdr,
370370
bitflags_bits!(msg_flags),
@@ -387,7 +387,7 @@ pub(crate) fn sendmsg_v4(
387387
msg_flags: SendFlags,
388388
) -> io::Result<usize> {
389389
with_v4_msghdr(addr, iov, control, |msghdr| unsafe {
390-
ret_send_recv(c::sendmsg(
390+
ret_usize(c::sendmsg(
391391
borrowed_fd(sockfd),
392392
&msghdr,
393393
bitflags_bits!(msg_flags),
@@ -410,7 +410,7 @@ pub(crate) fn sendmsg_v6(
410410
msg_flags: SendFlags,
411411
) -> io::Result<usize> {
412412
with_v6_msghdr(addr, iov, control, |msghdr| unsafe {
413-
ret_send_recv(c::sendmsg(
413+
ret_usize(c::sendmsg(
414414
borrowed_fd(sockfd),
415415
&msghdr,
416416
bitflags_bits!(msg_flags),
@@ -430,7 +430,7 @@ pub(crate) fn sendmsg_unix(
430430
msg_flags: SendFlags,
431431
) -> io::Result<usize> {
432432
super::msghdr::with_unix_msghdr(addr, iov, control, |msghdr| unsafe {
433-
ret_send_recv(c::sendmsg(
433+
ret_usize(c::sendmsg(
434434
borrowed_fd(sockfd),
435435
&msghdr,
436436
bitflags_bits!(msg_flags),
@@ -447,7 +447,7 @@ pub(crate) fn sendmsg_xdp(
447447
msg_flags: SendFlags,
448448
) -> io::Result<usize> {
449449
with_xdp_msghdr(addr, iov, control, |msghdr| unsafe {
450-
ret_send_recv(c::sendmsg(
450+
ret_usize(c::sendmsg(
451451
borrowed_fd(sockfd),
452452
&msghdr,
453453
bitflags_bits!(msg_flags),

0 commit comments

Comments
 (0)