Skip to content

Commit a6f2666

Browse files
committed
std/sys/fd: remove - 1 from READ_LIMIT on Darwin
Darwin's `read`/`write` syscalls emit `EINVAL` only when `nbyte > INT_MAX`. The case `nbyte == INT_MAX` is valid, so the subtraction can be removed.
1 parent b56aaec commit a6f2666

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/std/src/sys/fd/unix.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ pub struct FileDesc(OwnedFd);
3737
//
3838
// On Apple targets however, apparently the 64-bit libc is either buggy or
3939
// intentionally showing odd behavior by rejecting any read with a size
40-
// larger than or equal to INT_MAX. To handle both of these the read
41-
// size is capped on both platforms.
40+
// larger than INT_MAX. To handle both of these the read size is capped on
41+
// both platforms.
4242
const READ_LIMIT: usize = if cfg!(target_vendor = "apple") {
43-
libc::c_int::MAX as usize - 1
43+
libc::c_int::MAX as usize
4444
} else {
4545
libc::ssize_t::MAX as usize
4646
};

0 commit comments

Comments
 (0)