From: Juan Quintela <quintela@redhat.com>
To: Thomas Huth <thuth@redhat.com>
Cc: qemu-devel@nongnu.org, lvivier@redhat.com, pbonzini@redhat.com,
dgilbert@redhat.com, peterx@redhat.com,
"Christian Borntraeger" <borntraeger@de.ibm.com>,
"Cédric Le Goater" <clg@kaod.org>
Subject: Re: [Qemu-devel] [PATCH 1/2] tests: Use real size for iov tests
Date: Wed, 30 Aug 2017 13:34:30 +0200 [thread overview]
Message-ID: <87ziah5lx5.fsf@secure.mitica> (raw)
In-Reply-To: <6f537126-f1a6-2159-d8f7-35d34b803dfa@redhat.com> (Thomas Huth's message of "Mon, 28 Aug 2017 18:10:09 +0200")
Thomas Huth <thuth@redhat.com> wrote:
> On 23.08.2017 10:39, 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(-)
>
> While you're at it, could you maybe also adjust the comments in
> include/qemu/iov.h ? It currently says:
>
> * It is okay to use very large value for `bytes' since we're
> * limited by the size of the iovec anyway, provided that the
> * buffer pointed to by buf has enough space. One possible
> * such "large" value is -1 (sinice size_t is unsigned),
> * so specifying `-1' as `bytes' means 'up to the end of iovec'.
This is for the _full() versions, and still work. the same for
iov_memset().
> ... and apparently -1 is not working anymore as expected. Maybe SIZE_MAX
> from stdint.h is a better choice?
static inline size_t
iov_from_buf(const struct iovec *iov, unsigned int iov_cnt,
size_t offset, const void *buf, size_t bytes)
{
if (__builtin_constant_p(bytes) && iov_cnt &&
offset <= iov[0].iov_len && bytes <= iov[0].iov_len - offset) {
memcpy(iov[0].iov_base + offset, buf, bytes);
return bytes;
} else {
return iov_from_buf_full(iov, iov_cnt, offset, buf, bytes);
}
}
This optimization don't work very well if we used bytes = -1,
furthermore, we return the wrong value.
And no, I don't understand how the (bytes <= iov[0].iov_len - offset)
test pass when bytes == -1.
Later, Juan.
next prev parent reply other threads:[~2017-08-30 11:34 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
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 [this message]
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=87ziah5lx5.fsf@secure.mitica \
--to=quintela@redhat.com \
--cc=borntraeger@de.ibm.com \
--cc=clg@kaod.org \
--cc=dgilbert@redhat.com \
--cc=lvivier@redhat.com \
--cc=pbonzini@redhat.com \
--cc=peterx@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=thuth@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).