public inbox for cygwin-cvs@sourceware.org
help / color / mirror / Atom feed
From: Corinna Vinschen <corinna@sourceware.org>
To: cygwin-cvs@sourceware.org
Subject: [newlib-cygwin] Cygwin: file I/O: make sure to treat write return value as ssize_t
Date: Fri, 24 Apr 2020 14:23:30 +0000 (GMT)	[thread overview]
Message-ID: <20200424142330.7209E38930F7@sourceware.org> (raw)

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;


                 reply	other threads:[~2020-04-24 14:23 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200424142330.7209E38930F7@sourceware.org \
    --to=corinna@sourceware.org \
    --cc=cygwin-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).