All of lore.kernel.org
 help / color / mirror / Atom feed
From: Peter Xu <peterx@redhat.com>
To: Juan Quintela <quintela@redhat.com>
Cc: qemu-devel@nongnu.org, dgilbert@redhat.com, lvivier@redhat.com,
	pbonzini@redhat.com
Subject: Re: [Qemu-devel] [PATCH 1/2] tests: Use real size for iov tests
Date: Wed, 23 Aug 2017 19:18:32 +0800	[thread overview]
Message-ID: <20170823111832.GC19071@pxdev.xzpeter.org> (raw)
In-Reply-To: <20170823083901.852-2-quintela@redhat.com>

On Wed, Aug 23, 2017 at 10:39:00AM +0200, Juan Quintela wrote:
> We were using -1 instead of the real size because the functions check
> what is bigger, size in bytes or the size of the iov.  Recent gcc's
> barf at this.
> 
> Signed-off-by: Juan Quintela <quintela@redhat.com>
> ---
>  tests/test-iov.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/test-iov.c b/tests/test-iov.c
> index a22d71fd2c..819c410a51 100644
> --- a/tests/test-iov.c
> +++ b/tests/test-iov.c
> @@ -81,17 +81,17 @@ static void test_to_from_buf_1(void)
>            * skip whole vector and process exactly 0 bytes */
>  
>           /* first set bytes [i..sz) to some "random" value */
> -         n = iov_memset(iov, niov, 0, 0xff, -1);
> +         n = iov_memset(iov, niov, 0, 0xff, sz);

This one is not needed?

>           g_assert(n == sz);
>  
>           /* next copy bytes [i..sz) from ibuf to iovec */
> -         n = iov_from_buf(iov, niov, i, ibuf + i, -1);
> +         n = iov_from_buf(iov, niov, i, ibuf + i, sz - i);
>           g_assert(n == sz - i);
>  
>           /* clear part of obuf */
>           memset(obuf + i, 0, sz - i);
>           /* and set this part of obuf to values from iovec */
> -         n = iov_to_buf(iov, niov, i, obuf + i, -1);
> +         n = iov_to_buf(iov, niov, i, obuf + i, sz - i);
>           g_assert(n == sz - i);
>  
>           /* now compare resulting buffers */
> @@ -109,7 +109,7 @@ static void test_to_from_buf_1(void)
>                * with j in [i..sz]. */
>  
>               /* clear iovec */
> -             n = iov_memset(iov, niov, 0, 0xff, -1);
> +             n = iov_memset(iov, niov, 0, 0xff, sz);

This one as well?

Actually I think we can keep the two places above, but there seems to
be a 3rd one below which is untouched.  If we do change the two, maybe
we'd better change the 3rd one as well.

Besides:

Reviewed-by: Peter Xu <peterx@redhat.com>

>               g_assert(n == sz);
>  
>               /* copy bytes [i..j) from ibuf to iovec */
> -- 
> 2.13.5
> 

-- 
Peter Xu

  reply	other threads:[~2017-08-23 11:18 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-23  8:38 [Qemu-devel] [PATCH 0/2] Fix tests on recent gcc Juan Quintela
2017-08-23  8:39 ` [Qemu-devel] [PATCH 1/2] tests: Use real size for iov tests Juan Quintela
2017-08-23 11:18   ` Peter Xu [this message]
2017-08-23 11:35     ` Juan Quintela
2017-08-28 16:10   ` Thomas Huth
2017-08-30  9:45     ` Juan Quintela
2017-08-30 11:34     ` Juan Quintela
2017-08-23  8:39 ` [Qemu-devel] [PATCH 2/2] tests: Make acpid test compile Juan Quintela
2017-08-23 11:53   ` Dr. David Alan Gilbert
2017-08-28 14:41     ` Cédric Le Goater
2017-08-29 20:17       ` Eric Blake
2017-08-30 10:45         ` Daniel P. Berrange
2017-08-30 11:37           ` Juan Quintela
2017-08-30 10:51       ` Juan Quintela
2017-08-30 11:07         ` Daniel P. Berrange

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=20170823111832.GC19071@pxdev.xzpeter.org \
    --to=peterx@redhat.com \
    --cc=dgilbert@redhat.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=quintela@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.