[newlib-cygwin/cygwin-3_5-branch] Cygwin: pipe: fix comparison

Corinna Vinschen corinna@sourceware.org
Thu Aug 22 20:38:30 GMT 2024


https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=61dc66d2f203517786151d4bcee685f1298068c4

commit 61dc66d2f203517786151d4bcee685f1298068c4
Author:     Corinna Vinschen <corinna@vinschen.de>
AuthorDate: Mon Aug 19 11:44:42 2024 +0200
Commit:     Corinna Vinschen <corinna@vinschen.de>
CommitDate: Thu Aug 22 19:58:49 2024 +0200

    Cygwin: pipe: fix comparison
    
    There's no reason to overwrite len1 with align if they are the same value.
    
    Fixes: 170e6badb621 ("Cygwin: pipe: improve writing when pipe buffer is almost full")
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler/pipe.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/winsup/cygwin/fhandler/pipe.cc b/winsup/cygwin/fhandler/pipe.cc
index e0de157ef0d1..3f8d5479c5f1 100644
--- a/winsup/cygwin/fhandler/pipe.cc
+++ b/winsup/cygwin/fhandler/pipe.cc
@@ -551,7 +551,7 @@ fhandler_pipe_fifo::raw_write (const void *ptr, size_t len)
 					       PDA_WRITE);
 	  if (avail < 1)	/* error or pipe closed */
 	    break;
-	  if (avail >= len1)	/* somebody read from the pipe */
+	  if (avail > len1)	/* somebody read from the pipe */
 	    avail = len1;
 	  if (avail == 1)	/* 1 byte left or non-Cygwin pipe */
 	    len1 >>= 1;


More information about the Cygwin-cvs mailing list