qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH 1/2] tests: Use real size for iov tests


From: Juan Quintela
Subject: Re: [Qemu-devel] [PATCH 1/2] tests: Use real size for iov tests
Date: Wed, 23 Aug 2017 13:35:53 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/25.2 (gnu/linux)

Peter Xu <address@hidden> wrote:
> 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 <address@hidden>
>> ---
>>  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?

Not, but it is for consistence.  iov_memset() has that property, that it
memset whatever is smaller, bytes parameter or iov size.


>>                * 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?

I decided to change all of them for consistence.

Using -1 is a trick that just happens to work for current
implementation, but it is a hack.  and we have just after that an assert
with the real size that we want to copy.  Just use them everywhere.

>
> 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.

Opps, didn't saw that other.  With this changes it fixed all for me.



> Besides:
>
> Reviewed-by: Peter Xu <address@hidden>

Thanks, Juan.


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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]