public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
* [newlib-cygwin] Cygwin: file I/O: make sure to treat write return value as ssize_t
@ 2020-04-24 14:23 Corinna Vinschen
  0 siblings, 0 replies; only message in thread
From: Corinna Vinschen @ 2020-04-24 14:23 UTC (permalink / raw)
  To: cygwin-cvs

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

commit 5a7e130c31dfdf78f2e1b30dd6ec39a842be1336
Author: Corinna Vinschen <corinna@vinschen.de>
Date:   Fri Apr 24 16:14:43 2020 +0200

    Cygwin: file I/O: make sure to treat write return value as ssize_t
    
    The return type of fhandler write methods is ssize_t.  Don't
    use an int to store the return value, use ssize_t.  Use ptrdiff_t
    for the buffer size.
    
    Signed-off-by: Corinna Vinschen <corinna@vinschen.de>

Diff:
---
 winsup/cygwin/fhandler.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index d754077b1..9d6271b3d 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -949,9 +949,9 @@ fhandler_base::write (const void *ptr, size_t len)
 	    }
 
 	  /* We've got a buffer-full, or we're out of data.  Write it out */
-	  int nbytes;
-	  int want = buf_ptr - buf;
-	  if ((nbytes = raw_write (buf, want)) == want)
+	  ssize_t nbytes;
+	  ptrdiff_t want = buf_ptr - buf;
+	  if ((nbytes = raw_write (buf, (size_t) want)) == want)
 	    {
 	      /* Keep track of how much written not counting additional \r's */
 	      res = data - (char *)ptr;


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-04-24 14:23 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-04-24 14:23 [newlib-cygwin] Cygwin: file I/O: make sure to treat write return value as ssize_t Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).