From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60331) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2E3p-0001i2-78 for qemu-devel@nongnu.org; Thu, 25 Jul 2013 01:25:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1V2E3o-0002nO-8R for qemu-devel@nongnu.org; Thu, 25 Jul 2013 01:25:57 -0400 Received: from mail-pb0-x22f.google.com ([2607:f8b0:400e:c01::22f]:65144) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1V2E3o-0002nK-1U for qemu-devel@nongnu.org; Thu, 25 Jul 2013 01:25:56 -0400 Received: by mail-pb0-f47.google.com with SMTP id rr13so297088pbb.34 for ; Wed, 24 Jul 2013 22:25:55 -0700 (PDT) From: Liu Yuan Date: Thu, 25 Jul 2013 13:25:34 +0800 Message-Id: <1374729935-27667-2-git-send-email-namei.unix@gmail.com> In-Reply-To: <1374729935-27667-1-git-send-email-namei.unix@gmail.com> References: <20130725033651.GB24069@ubuntu-precise> <1374729935-27667-1-git-send-email-namei.unix@gmail.com> Subject: [Qemu-devel] [PATCH 1/2] sheepdog: correct signedness of comparison List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: sheepdog@lists.wpkg.org, morita.kazutaka@lab.ntt.co.jp Cc: kwolf@redhat.com, pbonzini@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com When signed int compared to unsigned int, signed int will be converted to unsigned int. For example, (-1 < sizeof(structure)) always true because -1 in the left is converted into unsigned int, thus this restule in unexpected true. Signed-off-by: Liu Yuan --- block/sheepdog.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index 58e03c8..8c6c8f1 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -616,7 +616,7 @@ static coroutine_fn void do_co_req(void *opaque) if (*rlen) { ret = qemu_co_recv(sockfd, data, *rlen); - if (ret < *rlen) { + if (ret < (int)*rlen) { error_report("failed to get the data, %s", strerror(errno)); ret = -errno; goto out; @@ -755,7 +755,7 @@ static void coroutine_fn aio_read_response(void *opaque) /* read a header */ ret = qemu_co_recv(fd, &rsp, sizeof(rsp)); - if (ret < sizeof(rsp)) { + if (ret < (int)sizeof(rsp)) { error_report("failed to get the header, %s", strerror(errno)); goto err; } @@ -806,7 +806,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 < rsp.data_length) { + if (ret < (int)rsp.data_length) { error_report("failed to get the data, %s", strerror(errno)); goto err; } @@ -1116,7 +1116,7 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, { int nr_copies = s->inode.nr_copies; SheepdogObjReq hdr; - unsigned int wlen = 0; + int wlen = 0; int ret; uint64_t oid = aio_req->oid; unsigned int datalen = aio_req->data_len; @@ -1173,7 +1173,7 @@ static void coroutine_fn add_aio_request(BDRVSheepdogState *s, AIOReq *aio_req, /* send a header */ ret = qemu_co_send(s->fd, &hdr, sizeof(hdr)); - if (ret < sizeof(hdr)) { + if (ret < (int)sizeof(hdr)) { error_report("failed to send a req, %s", strerror(errno)); goto out; } -- 1.7.9.5