From cdea75656912bc8001e488fe53f3aaef3a55f143 Mon Sep 17 00:00:00 2001 From: Anhad Singh Date: Thu, 25 Jun 2026 23:55:00 +1000 Subject: [PATCH] fix(tcp/write_buf): incorrect return value On success, the number of bytes written should be returned. Previously `buf.len()` was always returned. The function `send_slice` > ... returns the amount of octets actually enqueued, which is limited > by the amount of free space in the transmit buffer; down to zero. "down to zero" is okay as that is checked by `can_send`. Signed-off-by: Anhad Singh --- netstack/src/scheme/tcp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/netstack/src/scheme/tcp.rs b/netstack/src/scheme/tcp.rs index 435553829d..3536c1bbea 100644 --- a/netstack/src/scheme/tcp.rs +++ b/netstack/src/scheme/tcp.rs @@ -162,8 +162,7 @@ impl<'a> SchemeSocket for TcpSocket<'a> { } else if !self.is_active() { Err(SyscallError::new(syscall::ENOTCONN)) } else if self.can_send() { - self.send_slice(buf).expect("Can't send slice"); - Ok(buf.len()) + Ok(self.send_slice(buf).expect("Can't send slice")) } else if file.flags & syscall::O_NONBLOCK == syscall::O_NONBLOCK { Err(SyscallError::new(syscall::EAGAIN)) } else {