about summary refs log tree commit diff
diff options
context:
space:
mode:
authormorinmorin <mimomorin@gmail.com>2025-07-25 23:22:36 +0900
committermorinmorin <mimomorin@gmail.com>2025-07-25 23:22:36 +0900
commita6f266612a42737ee46b69645244975e75406b60 (patch)
tree6abd5356fb43f54fd0e2898d0810e4f07e8e7bd7
parentb56aaec52bc0fa35591a872fb4aac81f606e265c (diff)
downloadrust-a6f266612a42737ee46b69645244975e75406b60.tar.gz
rust-a6f266612a42737ee46b69645244975e75406b60.zip
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.
-rw-r--r--library/std/src/sys/fd/unix.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/library/std/src/sys/fd/unix.rs b/library/std/src/sys/fd/unix.rs
index cdca73cdca1..a12f692e754 100644
--- a/library/std/src/sys/fd/unix.rs
+++ b/library/std/src/sys/fd/unix.rs
@@ -37,10 +37,10 @@ pub struct FileDesc(OwnedFd);
 //
 // On Apple targets however, apparently the 64-bit libc is either buggy or
 // intentionally showing odd behavior by rejecting any read with a size
-// larger than or equal to INT_MAX. To handle both of these the read
-// size is capped on both platforms.
+// larger than INT_MAX. To handle both of these the read size is capped on
+// both platforms.
 const READ_LIMIT: usize = if cfg!(target_vendor = "apple") {
-    libc::c_int::MAX as usize - 1
+    libc::c_int::MAX as usize
 } else {
     libc::ssize_t::MAX as usize
 };