qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Liu Yuan <namei.unix@gmail.com>
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
Subject: [Qemu-devel] [PATCH 1/2] sheepdog: correct signedness of comparison
Date: Thu, 25 Jul 2013 13:25:34 +0800	[thread overview]
Message-ID: <1374729935-27667-2-git-send-email-namei.unix@gmail.com> (raw)
In-Reply-To: <1374729935-27667-1-git-send-email-namei.unix@gmail.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 <namei.unix@gmail.com>
---
 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

  reply	other threads:[~2013-07-25  5:25 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-07-24  7:56 [Qemu-devel] [PATCH v2 0/9] sheepdog: reconnect server after connection failure MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 1/9] ignore SIGPIPE in qemu-img and qemu-io MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 2/9] iov: handle EOF in iov_send_recv MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 3/9] sheepdog: check return values of qemu_co_recv/send correctly MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 4/9] sheepdog: handle vdi objects in resend_aio_req MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 5/9] sheepdog: reload inode outside of resend_aioreq MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 6/9] coroutine: add co_aio_sleep_ns() to allow sleep in block drivers MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 7/9] sheepdog: try to reconnect to sheepdog after network error MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 8/9] sheepdog: make add_aio_request and send_aioreq void functions MORITA Kazutaka
2013-07-24  7:56 ` [Qemu-devel] [PATCH v2 9/9] sheepdog: cancel aio requests if possible MORITA Kazutaka
2013-07-24  8:28 ` [Qemu-devel] [sheepdog] [PATCH v2 0/9] sheepdog: reconnect server after connection failure Liu Yuan
2013-07-24  9:07   ` MORITA Kazutaka
2013-07-24 15:42     ` Liu Yuan
2013-07-25  3:36       ` Liu Yuan
2013-07-25  5:25         ` [Qemu-devel] " Liu Yuan
2013-07-25  5:25           ` Liu Yuan [this message]
2013-07-25  5:25           ` [Qemu-devel] [PATCH 2/2] sheepdog: put aio request into failed list when failing to send request Liu Yuan
2013-07-25  5:53           ` [Qemu-devel] [sheepdog] [PATCH v2 0/9] sheepdog: reconnect server after connection failure MORITA Kazutaka
2013-07-25  6:02             ` Liu Yuan

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=1374729935-27667-2-git-send-email-namei.unix@gmail.com \
    --to=namei.unix@gmail.com \
    --cc=kwolf@redhat.com \
    --cc=morita.kazutaka@lab.ntt.co.jp \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=sheepdog@lists.wpkg.org \
    --cc=stefanha@redhat.com \
    /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 NNTP newsgroup(s).