qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] win32-aio: use iov utility functions instead of open-coding them
@ 2013-01-17  8:48 Michael Tokarev
  2013-01-17  8:57 ` Kevin Wolf
  0 siblings, 1 reply; 3+ messages in thread
From: Michael Tokarev @ 2013-01-17  8:48 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: pbonzini, Michael Tokarev, qemu-devel, stefanha

We have iov_from_buf() and iov_to_buf(), use them instead of
open-coding these in block/win32-aio.c

Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru>
---
 block/win32-aio.c |   18 +++---------------
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/block/win32-aio.c b/block/win32-aio.c
index 0383370..773d3f4 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -79,14 +79,8 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
 
     if (!waiocb->is_linear) {
         if (ret == 0 && waiocb->is_read) {
-            QEMUIOVector *qiov = waiocb->qiov;
-            char *p = waiocb->buf;
-            int i;
-
-            for (i = 0; i < qiov->niov; ++i) {
-                memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
-                p += qiov->iov[i].iov_len;
-            }
+            iov_from_buf(waiocb->qiov.iov, waiocb->qiov.niov,
+                         0, waiocb->buf, waiocb->qiov.size);
             qemu_vfree(waiocb->buf);
         }
     }
@@ -153,13 +147,7 @@ BlockDriverAIOCB *win32_aio_submit(BlockDriverState *bs,
     if (qiov->niov > 1) {
         waiocb->buf = qemu_blockalign(bs, qiov->size);
         if (type & QEMU_AIO_WRITE) {
-            char *p = waiocb->buf;
-            int i;
-
-            for (i = 0; i < qiov->niov; ++i) {
-                memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);
-                p += qiov->iov[i].iov_len;
-            }
+            iov_to_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
         }
         waiocb->is_linear = false;
     } else {
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] win32-aio: use iov utility functions instead of open-coding them
  2013-01-17  8:48 [Qemu-devel] [PATCH] win32-aio: use iov utility functions instead of open-coding them Michael Tokarev
@ 2013-01-17  8:57 ` Kevin Wolf
  2013-01-17  8:59   ` Michael Tokarev
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Wolf @ 2013-01-17  8:57 UTC (permalink / raw)
  To: Michael Tokarev; +Cc: pbonzini, qemu-devel, stefanha

Am 17.01.2013 09:48, schrieb Michael Tokarev:
> We have iov_from_buf() and iov_to_buf(), use them instead of
> open-coding these in block/win32-aio.c
> 
> Signed-Off-By: Michael Tokarev <mjt@tls.msk.ru>
> ---
>  block/win32-aio.c |   18 +++---------------
>  1 file changed, 3 insertions(+), 15 deletions(-)
> 
> diff --git a/block/win32-aio.c b/block/win32-aio.c
> index 0383370..773d3f4 100644
> --- a/block/win32-aio.c
> +++ b/block/win32-aio.c
> @@ -79,14 +79,8 @@ static void win32_aio_process_completion(QEMUWin32AIOState *s,
>  
>      if (!waiocb->is_linear) {
>          if (ret == 0 && waiocb->is_read) {
> -            QEMUIOVector *qiov = waiocb->qiov;
> -            char *p = waiocb->buf;
> -            int i;
> -
> -            for (i = 0; i < qiov->niov; ++i) {
> -                memcpy(p, qiov->iov[i].iov_base, qiov->iov[i].iov_len);

I said on top of my patch for a reason: Now this looks like an innocent
refactoring patch, while in fact it is a hidden bug fix. Even the commit
message doesn't mention this.

Though I guess Stefan can apply my patch first and resolve the conflict
with this patch, then the result should be right.

Kevin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [Qemu-devel] [PATCH] win32-aio: use iov utility functions instead of open-coding them
  2013-01-17  8:57 ` Kevin Wolf
@ 2013-01-17  8:59   ` Michael Tokarev
  0 siblings, 0 replies; 3+ messages in thread
From: Michael Tokarev @ 2013-01-17  8:59 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: pbonzini, qemu-devel, stefanha

17.01.2013 12:57, Kevin Wolf wrote:

> I said on top of my patch for a reason: Now this looks like an innocent

Kevin, that wasn't intentional.  I'm sorry.  Somehow I thought your
bugfix is already applied to master, and these reverse memcpy args
are difficult to spot (gah, that's why the bug is here to start with).
I resend it based on your patch.

/mjt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-17  9:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-17  8:48 [Qemu-devel] [PATCH] win32-aio: use iov utility functions instead of open-coding them Michael Tokarev
2013-01-17  8:57 ` Kevin Wolf
2013-01-17  8:59   ` Michael Tokarev

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