qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH v9 1/3] iov: Factor out hexdumper


From: Peter Crosthwaite
Subject: Re: [Qemu-devel] [PATCH v9 1/3] iov: Factor out hexdumper
Date: Wed, 20 Feb 2013 12:19:07 +1000

On Tue, Feb 19, 2013 at 6:35 PM, Gerd Hoffmann <address@hidden> wrote:
>   Hi,
>
>> I ran git blame on it and its actually Gerds code. Gerd you want
>> co-authorship and the (c) of this hexdump.c?
>
> Yes.
>
> And don't break iov_hexdump() behavior please.  I suggest to just
> iov_to_buf() into a temporary buffer, then pass that to a single hexdump
> call.

Done, thanks for the correction. Do you have a lightweight test vector
that exercises this? The iovec stuff in my areas is all limited to
single iovec element.  Interdiff below.

Regards,
Peter

When calling hexdump for each iovec element the buffer offsets
> printed are wrong for all but the first iovec element.
>
> cheers,
>   Gerd
>
>

diff --git a/util/hexdump.c b/util/hexdump.c
index 0bf0f38..0d0efc8 100644
--- a/util/hexdump.c
+++ b/util/hexdump.c
@@ -1,12 +1,11 @@
 /*
  * Helper to hexdump a buffer
  *
+ * Copyright (c) 2013 Red Hat, Inc.
+ * Copyright (c) 2013 Gerd Hoffmann <address@hidden>
  * Copyright (c) 2013 Peter Crosthwaite <address@hidden>
  * Copyright (c) 2013 Xilinx, Inc
  *
- * Based on git commit 3a1dca94d6dba00fe0fd4c4a28449f57e01b9b6c
- * Author: Gerd Hoffmann <address@hidden>
- *
  * This work is licensed under the terms of the GNU GPL, version 2.  See
  * the COPYING file in the top-level directory.
  *
diff --git a/util/iov.c b/util/iov.c
index 91d79ae..99f0b50 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -202,11 +202,16 @@ void iov_hexdump(const struct iovec *iov, const
unsigned int iov_cnt,
                  FILE *fp, const char *prefix, size_t limit)
 {
     int v;
-    for (v = 0; v < iov_cnt && limit; v++) {
-        int size = limit < iov[v].iov_len ? limit : iov[v].iov_len;
-        hexdump(iov[v].iov_base, fp, prefix, size);
-        limit -= size;
+    size_t size = 0;
+    char *buf;
+
+    for (v = 0; v < iov_cnt; v++) {
+        size += iov[v].iov_len;
     }
+    size = size > limit ? limit : size;
+    buf = g_malloc(size);
+    iov_to_buf(iov, iov_cnt, 0, buf, size);
+    g_free(buf);
 }



reply via email to

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