Patchwork [v3] win32-aio: use iov utility functions instead of open-coding them

login
register
mail settings
Submitter Michael Tokarev
Date Jan. 17, 2013, 2:47 p.m.
Message ID <1358434072-9637-1-git-send-email-mjt@msgid.tls.msk.ru>
Download mbox | patch
Permalink /patch/213286/
State New
Headers show

Comments

Michael Tokarev - Jan. 17, 2013, 2:47 p.m.
We have iov_from_buf() and iov_to_buf(), use them instead of
open-coding these in block/win32-aio.c
---
v3: added the forgotten #include (compile-tested on mingw32)
v2: rebase on top of the fix from bonzini@

 block/win32-aio.c |   17 +++--------------
 1 file changed, 3 insertions(+), 14 deletions(-)
Stefan Hajnoczi - Jan. 18, 2013, 9 a.m.
On Thu, Jan 17, 2013 at 06:47:52PM +0400, Michael Tokarev wrote:
> We have iov_from_buf() and iov_to_buf(), use them instead of
> open-coding these in block/win32-aio.c
> ---
> v3: added the forgotten #include (compile-tested on mingw32)
> v2: rebase on top of the fix from bonzini@
> 
>  block/win32-aio.c |   17 +++--------------
>  1 file changed, 3 insertions(+), 14 deletions(-)

Thanks, applied to my block tree:
https://github.com/stefanha/qemu/commits/block

Stefan

Patch

diff --git a/block/win32-aio.c b/block/win32-aio.c
index b9236ea..5d0fbbf 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -29,6 +29,7 @@ 
 #include "block/aio.h"
 #include "raw-aio.h"
 #include "qemu/event_notifier.h"
+#include "qemu/iov.h"
 #include <windows.h>
 #include <winioctl.h>
 
@@ -80,13 +81,7 @@  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(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
-                p += qiov->iov[i].iov_len;
-            }
+            iov_from_buf(qiov->iov, qiov->niov, 0, waiocb->buf, qiov->size);
         }
         qemu_vfree(waiocb->buf);
     }
@@ -153,13 +148,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 {