https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=4899407e0e6129060cd1767744b4db82f164da36
commit 4899407e0e6129060cd1767744b4db82f164da36 Author: Takashi Yano <takashi.y...@nifty.ne.jp> Date: Wed Jun 25 20:31:10 2025 +0900 Cygwin: pipe: Simplify raw_write() a bit (Drop using chunk) There are tree variables for similar purpose in raw_write(), avail, chunk, and len1. avail is the amount of writable space in the pipe. len1 is the data length to attempt to NtWriteFile(). And chunk is intermediate value to calculate len1 from avail which holds min(avail, len). Here, chunk has no clear role among them. In fact, it appears to obscure the intent of the code for the reader. This patch removes the use of chunk and obtains len1 directly from avail. Reviewed-by: Johannes Schindelin <johannes.schinde...@gmx.de> Signed-off-by: Takashi Yano <takashi.y...@nifty.ne.jp> Diff: --- winsup/cygwin/fhandler/pipe.cc | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc index 3a0f8bfe9..1a8c39c5b 100644 --- a/winsup/cygwin/fhandler/pipe.cc +++ b/winsup/cygwin/fhandler/pipe.cc @@ -442,7 +442,6 @@ ssize_t fhandler_pipe_fifo::raw_write (const void *ptr, size_t len) { size_t nbytes = 0; - ULONG chunk; NTSTATUS status = STATUS_SUCCESS; IO_STATUS_BLOCK io; HANDLE evt; @@ -543,11 +542,6 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len) } } - if (len <= (size_t) avail) - chunk = len; - else - chunk = avail; - if (!(evt = CreateEvent (NULL, false, false, NULL))) { __seterrno (); @@ -564,8 +558,8 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len) ULONG len1; DWORD waitret = WAIT_OBJECT_0; - if (left > chunk && !is_nonblocking ()) - len1 = chunk; + if (left > (size_t) avail && !is_nonblocking ()) + len1 = (ULONG) avail; else len1 = (ULONG) left;