From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 46970 invoked by alias); 7 Aug 2018 07:49:42 -0000 Mailing-List: contact cygwin-cvs-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Post: List-Help: , Sender: cygwin-cvs-owner@cygwin.com Received: (qmail 46887 invoked by uid 9078); 7 Aug 2018 07:49:40 -0000 Date: Tue, 07 Aug 2018 07:49:00 -0000 Message-ID: <20180807074940.46884.qmail@sourceware.org> Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Corinna Vinschen To: cygwin-cvs@sourceware.org Subject: [newlib-cygwin] Fix return value on aio_read/write success X-Act-Checkin: newlib-cygwin X-Git-Author: Mark Geisert X-Git-Refname: refs/heads/master X-Git-Oldrev: f16b198c3b033ae60af9efcb045ebf68361950ad X-Git-Newrev: b1952c03a8d6970f0fb4bcfffb9cfb5b525884d6 X-SW-Source: 2018-q3/txt/msg00020.txt.bz2 https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;h=b1952c03a8d6970f0fb4bcfffb9cfb5b525884d6 commit b1952c03a8d6970f0fb4bcfffb9cfb5b525884d6 Author: Mark Geisert Date: Mon Aug 6 22:54:06 2018 -0700 Fix return value on aio_read/write success Internally track resultant byte counts as ssize_t, but return 0 as int for success indication, per POSIX. Diff: --- winsup/cygwin/aio.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/winsup/cygwin/aio.cc b/winsup/cygwin/aio.cc index fe63dec..7d5d982 100644 --- a/winsup/cygwin/aio.cc +++ b/winsup/cygwin/aio.cc @@ -265,7 +265,7 @@ aiowaiter (void *unused) } } -static int +static ssize_t asyncread (struct aiocb *aio) { /* Try to initiate an asynchronous read, either from app or worker thread */ ssize_t res = 0; @@ -296,7 +296,7 @@ asyncread (struct aiocb *aio) return res; } -static int +static ssize_t asyncwrite (struct aiocb *aio) { /* Try to initiate an asynchronous write, either from app or worker thread */ ssize_t res = 0; @@ -712,7 +712,7 @@ aio_read (struct aiocb *aio) ; /* I think this is not possible */ } - return res; + return res < 0 ? (int) res : 0; /* return 0 on success */ } ssize_t @@ -902,7 +902,7 @@ aio_write (struct aiocb *aio) ; /* I think this is not possible */ } - return res; + return res < 0 ? (int) res : 0; /* return 0 on success */ } int