From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRARE-00018B-9y for qemu-devel@nongnu.org; Thu, 26 Feb 2015 21:14:01 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YRAR9-0007gn-92 for qemu-devel@nongnu.org; Thu, 26 Feb 2015 21:14:00 -0500 Received: from mail-ie0-x22c.google.com ([2607:f8b0:4001:c03::22c]:36782) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YRAR9-0007gg-3Q for qemu-devel@nongnu.org; Thu, 26 Feb 2015 21:13:55 -0500 Received: by ierx19 with SMTP id x19so24530674ier.3 for ; Thu, 26 Feb 2015 18:13:54 -0800 (PST) Date: Fri, 27 Feb 2015 10:13:51 +0800 From: Liu Yuan Message-ID: <20150227021350.GE5811@ubuntu-trusty> References: <1424231875-7131-1-git-send-email-namei.unix@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1424231875-7131-1-git-send-email-namei.unix@gmail.com> Subject: Re: [Qemu-devel] [PATCH v2] sheepdog: fix confused return values List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: sheepdog@lists.wpkg.org Cc: Kevin Wolf , qemu-devel@nongnu.org, Stefan Hajnoczi , Markus Armbruster On Wed, Feb 18, 2015 at 11:57:55AM +0800, Liu Yuan wrote: > From: Liu Yuan > > These functions mix up -1 and -errno in return values and would might cause > trouble error handling in the call chain. > > This patch let them return -errno and add some comments. > > Cc: qemu-devel@nongnu.org > Cc: Markus Armbruster > Cc: Kevin Wolf > Cc: Stefan Hajnoczi > Reported-by: Markus Armbruster > Signed-off-by: Liu Yuan > --- > v2: > - use socket_error() instead of errno > > block/sheepdog.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/block/sheepdog.c b/block/sheepdog.c > index be3176f..e4b30ba 100644 > --- a/block/sheepdog.c > +++ b/block/sheepdog.c > @@ -527,6 +527,7 @@ static SheepdogAIOCB *sd_aio_setup(BlockDriverState *bs, QEMUIOVector *qiov, > return acb; > } > > +/* Return -EIO in case of error, file descriptor on success */ > static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > { > int fd; > @@ -546,11 +547,14 @@ static int connect_to_sdog(BDRVSheepdogState *s, Error **errp) > > if (fd >= 0) { > qemu_set_nonblock(fd); > + } else { > + fd = -EIO; > } > > return fd; > } > > +/* Return 0 on success and -errno in case of error */ > static coroutine_fn int send_co_req(int sockfd, SheepdogReq *hdr, void *data, > unsigned int *wlen) > { > @@ -559,11 +563,13 @@ static coroutine_fn int send_co_req(int sockfd, SheepdogReq *hdr, void *data, > ret = qemu_co_send(sockfd, hdr, sizeof(*hdr)); > if (ret != sizeof(*hdr)) { > error_report("failed to send a req, %s", strerror(errno)); > + ret = -socket_error(); > return ret; > } > > ret = qemu_co_send(sockfd, data, *wlen); > if (ret != *wlen) { > + ret = -socket_error(); > error_report("failed to send a req, %s", strerror(errno)); > } > > @@ -638,6 +644,11 @@ out: > srco->finished = true; > } > > +/* > + * Send the request to the sheep in a synchronous manner. > + * > + * Return 0 on success, -errno in case of error. > + */ > static int do_req(int sockfd, AioContext *aio_context, SheepdogReq *hdr, > void *data, unsigned int *wlen, unsigned int *rlen) > { > -- > 1.9.1 > Ping...