From patchwork Tue Jul 23 08:30:15 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: MORITA Kazutaka X-Patchwork-Id: 260983 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id DBD912C00BD for ; Tue, 23 Jul 2013 18:35:00 +1000 (EST) Received: from localhost ([::1]:58189 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Y3e-0002Io-DP for incoming@patchwork.ozlabs.org; Tue, 23 Jul 2013 04:34:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53942) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Y0L-0005Di-VW for qemu-devel@nongnu.org; Tue, 23 Jul 2013 04:31:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V1Y0K-0001kF-PU for qemu-devel@nongnu.org; Tue, 23 Jul 2013 04:31:33 -0400 Received: from sh.osrg.net ([192.16.179.4]:37874) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V1Y0K-0001eZ-8c for qemu-devel@nongnu.org; Tue, 23 Jul 2013 04:31:32 -0400 Received: from fs.osrg.net (localns.osrg.net [10.0.0.11]) by sh.osrg.net (8.14.4/8.14.4/OSRG-NET) with ESMTP id r6N8V8mx010586; Tue, 23 Jul 2013 17:31:08 +0900 Received: from localhost (unknown [10.32.32.72]) by fs.osrg.net (Postfix) with ESMTP id 5EF4DF94C; Tue, 23 Jul 2013 17:31:07 +0900 (JST) From: MORITA Kazutaka To: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org Date: Tue, 23 Jul 2013 17:30:15 +0900 Message-Id: <1374568221-23147-6-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Mailer: git-send-email 1.8.1.3.566.gaa39828 In-Reply-To: <1374568221-23147-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> References: <1374568221-23147-1-git-send-email-morita.kazutaka@lab.ntt.co.jp> X-Dispatcher: imput version 20100215(IM150) Lines: 50 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.3.9 (sh.osrg.net [192.16.179.4]); Tue, 23 Jul 2013 17:31:08 +0900 (JST) X-Virus-Scanned: clamav-milter 0.97.8 at sh X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 192.16.179.4 Cc: sheepdog@lists.wpkg.org Subject: [Qemu-devel] [PATCH 05/11] sheepdog: check return values of qemu_co_recv/send correctly X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org qemu_co_recv/send return shorter length on error. Signed-off-by: MORITA Kazutaka --- block/sheepdog.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 6f5ede4..567f52e 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -727,7 +727,7 @@ static void coroutine_fn aio_read_response(void *opaque) /* read a header */ ret = qemu_co_recv(fd, &rsp, sizeof(rsp)); - if (ret < 0) { + if (ret < sizeof(rsp)) { error_report("failed to get the header, %s", strerror(errno)); goto out; } @@ -778,7 +778,7 @@ static void coroutine_fn aio_read_response(void *opaque) case AIOCB_READ_UDATA: ret = qemu_co_recvv(fd, acb->qiov->iov, acb->qiov->niov, aio_req->iov_offset, rsp.data_length); - if (ret < 0) { + if (ret < rsp.data_length) { error_report("failed to get the data, %s", strerror(errno)); goto out; } @@ -1131,7 +1131,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, /* send a header */ ret = qemu_co_send(s->fd, &hdr, sizeof(hdr)); - if (ret < 0) { + if (ret < sizeof(hdr)) { qemu_co_mutex_unlock(&s->lock); error_report("failed to send a req, %s", strerror(errno)); return -errno; @@ -1139,7 +1139,7 @@ static int coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, if (wlen) { ret = qemu_co_sendv(s->fd, iov, niov, aio_req->iov_offset, wlen); - if (ret < 0) { + if (ret < wlen) { qemu_co_mutex_unlock(&s->lock); error_report("failed to send a data, %s", strerror(errno)); return -errno;