All of lore.kernel.org
 help / color / mirror / Atom feed
From: Laurent Vivier <laurent@vivier.eu>
To: qemu-devel@nongnu.org
Cc: "Edgar E . Iglesias" <edgar.iglesias@xilinx.com>,
	"Peter Maydell" <peter.maydell@linaro.org>,
	qemu-trivial@nongnu.org, "Laurent Vivier" <laurent@vivier.eu>,
	"Philippe Mathieu-Daudé" <f4bug@amsat.org>,
	"Stefano Garzarella" <sgarzare@redhat.com>
Subject: [PULL 17/18] util/hexdump: Reorder qemu_hexdump() arguments
Date: Fri, 11 Sep 2020 21:33:29 +0200	[thread overview]
Message-ID: <20200911193330.1148942-18-laurent@vivier.eu> (raw)
In-Reply-To: <20200911193330.1148942-1-laurent@vivier.eu>

From: Philippe Mathieu-Daudé <f4bug@amsat.org>

qemu_hexdump()'s pointer to the buffer and length of the
buffer are closely related arguments but are widely separated
in the argument list order (also, the format of <stdio.h>
function prototypes is usually to have the FILE* argument
coming first).

Reorder the arguments as "fp, prefix, buf, size" which is
more logical.

Suggested-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Message-Id: <20200822180950.1343963-3-f4bug@amsat.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
---
 hw/dma/xlnx_dpdma.c      |  2 +-
 hw/net/fsl_etsec/etsec.c |  2 +-
 hw/net/fsl_etsec/rings.c |  2 +-
 hw/sd/sd.c               |  2 +-
 hw/usb/redirect.c        |  2 +-
 include/qemu-common.h    |  4 ++--
 net/colo-compare.c       | 24 ++++++++++++------------
 net/net.c                |  2 +-
 util/hexdump.c           |  4 ++--
 util/iov.c               |  2 +-
 10 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
index d75a8069426f..967548abd315 100644
--- a/hw/dma/xlnx_dpdma.c
+++ b/hw/dma/xlnx_dpdma.c
@@ -388,7 +388,7 @@ static void xlnx_dpdma_dump_descriptor(DPDMADescriptor *desc)
 {
     if (DEBUG_DPDMA) {
         qemu_log("DUMP DESCRIPTOR:\n");
-        qemu_hexdump(desc, stdout, "", sizeof(DPDMADescriptor));
+        qemu_hexdump(stdout, "", desc, sizeof(DPDMADescriptor));
     }
 }
 
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index 5c40303f93c1..93886bba60fc 100644
--- a/hw/net/fsl_etsec/etsec.c
+++ b/hw/net/fsl_etsec/etsec.c
@@ -357,7 +357,7 @@ static ssize_t etsec_receive(NetClientState *nc,
 
 #if defined(HEX_DUMP)
     fprintf(stderr, "%s receive size:%zd\n", nc->name, size);
-    qemu_hexdump(buf, stderr, "", size);
+    qemu_hexdump(stderr, "", buf, size);
 #endif
     /* Flush is unnecessary as are already in receiving path */
     etsec->need_flush = false;
diff --git a/hw/net/fsl_etsec/rings.c b/hw/net/fsl_etsec/rings.c
index 337a55fc957c..628648a9c37f 100644
--- a/hw/net/fsl_etsec/rings.c
+++ b/hw/net/fsl_etsec/rings.c
@@ -269,7 +269,7 @@ static void process_tx_bd(eTSEC         *etsec,
 
 #if defined(HEX_DUMP)
             qemu_log("eTSEC Send packet size:%d\n", etsec->tx_buffer_len);
-            qemu_hexdump(etsec->tx_buffer, stderr, "", etsec->tx_buffer_len);
+            qemu_hexdump(stderr, "", etsec->tx_buffer, etsec->tx_buffer_len);
 #endif  /* ETSEC_RING_DEBUG */
 
             if (etsec->first_bd.flags & BD_TX_TOEUN) {
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index 1c8f8529ea88..00128822224d 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1785,7 +1785,7 @@ send_response:
     }
 
 #ifdef DEBUG_SD
-    qemu_hexdump(response, stderr, "Response", rsplen);
+    qemu_hexdump(stderr, "Response", response, rsplen);
 #endif
 
     return rsplen;
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 09edb0d81c07..48f38d339124 100644
--- a/hw/usb/redirect.c
+++ b/hw/usb/redirect.c
@@ -240,7 +240,7 @@ static void usbredir_log_data(USBRedirDevice *dev, const char *desc,
     if (dev->debug < usbredirparser_debug_data) {
         return;
     }
-    qemu_hexdump(data, stderr, desc, len);
+    qemu_hexdump(stderr, desc, data, len);
 }
 
 /*
diff --git a/include/qemu-common.h b/include/qemu-common.h
index 6834883822f1..9cfd62669bf8 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -138,8 +138,8 @@ int os_parse_cmd_args(int index, const char *optarg);
  * Hexdump a buffer to a file. An optional string prefix is added to every line
  */
 
-void qemu_hexdump(const void *bufptr, FILE *fp,
-                  const char *prefix, size_t size);
+void qemu_hexdump(FILE *fp, const char *prefix,
+                  const void *bufptr, size_t size);
 
 /*
  * helper to parse debug environment variables
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 550272b3baa6..4a5ed642e9a5 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -494,10 +494,10 @@ sec:
         g_queue_push_head(&conn->secondary_list, spkt);
 
         if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
-            qemu_hexdump(ppkt->data, stderr,
-                        "colo-compare ppkt", ppkt->size);
-            qemu_hexdump(spkt->data, stderr,
-                        "colo-compare spkt", spkt->size);
+            qemu_hexdump(stderr, "colo-compare ppkt",
+                         ppkt->data, ppkt->size);
+            qemu_hexdump(stderr, "colo-compare spkt",
+                         spkt->data, spkt->size);
         }
 
         colo_compare_inconsistency_notify(s);
@@ -535,10 +535,10 @@ static int colo_packet_compare_udp(Packet *spkt, Packet *ppkt)
         trace_colo_compare_udp_miscompare("primary pkt size", ppkt->size);
         trace_colo_compare_udp_miscompare("Secondary pkt size", spkt->size);
         if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
-            qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
-                         ppkt->size);
-            qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
-                         spkt->size);
+            qemu_hexdump(stderr, "colo-compare pri pkt",
+                         ppkt->data, ppkt->size);
+            qemu_hexdump(stderr, "colo-compare sec pkt",
+                         spkt->data, spkt->size);
         }
         return -1;
     } else {
@@ -578,10 +578,10 @@ static int colo_packet_compare_icmp(Packet *spkt, Packet *ppkt)
         trace_colo_compare_icmp_miscompare("Secondary pkt size",
                                            spkt->size);
         if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
-            qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
-                         ppkt->size);
-            qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
-                         spkt->size);
+            qemu_hexdump(stderr, "colo-compare pri pkt",
+                         ppkt->data, ppkt->size);
+            qemu_hexdump(stderr, "colo-compare sec pkt",
+                         spkt->data, spkt->size);
         }
         return -1;
     } else {
diff --git a/net/net.c b/net/net.c
index f3e5d533fd74..7a2a0fb5ac67 100644
--- a/net/net.c
+++ b/net/net.c
@@ -636,7 +636,7 @@ static ssize_t qemu_send_packet_async_with_flags(NetClientState *sender,
 
 #ifdef DEBUG_NET
     printf("qemu_send_packet_async:\n");
-    qemu_hexdump(buf, stdout, "net", size);
+    qemu_hexdump(stdout, "net", buf, size);
 #endif
 
     if (sender->link_down || !sender->peer) {
diff --git a/util/hexdump.c b/util/hexdump.c
index 053f05d41603..0b4662e701d8 100644
--- a/util/hexdump.c
+++ b/util/hexdump.c
@@ -16,8 +16,8 @@
 #include "qemu/osdep.h"
 #include "qemu-common.h"
 
-void qemu_hexdump(const void *bufptr, FILE *fp,
-                  const char *prefix, size_t size)
+void qemu_hexdump(FILE *fp, const char *prefix,
+                  const void *bufptr, size_t size)
 {
     const char *buf = bufptr;
     unsigned int b, len, i, c;
diff --git a/util/iov.c b/util/iov.c
index 45ef3043eec6..ae61d696aae2 100644
--- a/util/iov.c
+++ b/util/iov.c
@@ -237,7 +237,7 @@ void iov_hexdump(const struct iovec *iov, const unsigned int iov_cnt,
     size = size > limit ? limit : size;
     buf = g_malloc(size);
     iov_to_buf(iov, iov_cnt, 0, buf, size);
-    qemu_hexdump(buf, fp, prefix, size);
+    qemu_hexdump(fp, prefix, buf, size);
     g_free(buf);
 }
 
-- 
2.26.2



  parent reply	other threads:[~2020-09-11 19:46 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-11 19:33 [PULL 00/18] Trivial branch for 5.2 patches Laurent Vivier
2020-09-11 19:33 ` [PULL 01/18] hw/mips/fuloong2e: Convert pointless error message to an assert() Laurent Vivier
2020-09-11 19:33 ` [PULL 02/18] hw/isa/isa-bus: Replace hw_error() by assert() Laurent Vivier
2020-09-11 19:33 ` [PULL 03/18] hw/acpi/tco: Remove unused definitions Laurent Vivier
2020-09-11 19:33 ` [PULL 04/18] hw/gpio/omap_gpio: Replace fprintf() by qemu_log_mask(GUEST_ERROR) Laurent Vivier
2020-09-11 19:33 ` [PULL 05/18] hw/gpio/max7310: Replace disabled printf() by qemu_log_mask(UNIMP) Laurent Vivier
2020-09-11 19:33 ` [PULL 06/18] Makefile: Drop extra phony cscope Laurent Vivier
2020-09-11 19:33 ` [PULL 07/18] Makefile: Skip the meson subdir in cscope/TAGS/ctags Laurent Vivier
2020-09-11 19:33 ` [PULL 08/18] hw/net/e1000e: Remove overwritten read handler for STATUS register Laurent Vivier
2020-09-11 19:33 ` [PULL 09/18] hw/net/e1000e: Remove duplicated write handler for FLSWDATA register Laurent Vivier
2020-09-11 19:33 ` [PULL 10/18] meson.build: tweak sdl-image error message Laurent Vivier
2020-09-11 19:33 ` [PULL 11/18] kconfig: fix comment referring to old Makefiles Laurent Vivier
2020-09-11 19:33 ` [PULL 12/18] hw: hyperv: vmbus: Fix 32bit compilation Laurent Vivier
2020-09-11 19:33 ` [PULL 13/18] test-vmstate: remove unnecessary code in match_interval_mapping_node Laurent Vivier
2020-09-11 19:33 ` [PULL 14/18] target/i386/kvm: Rename host_tsx_blacklisted() as host_tsx_broken() Laurent Vivier
2020-09-11 19:33 ` [PULL 15/18] hw/arm/pxa2xx: Add missing fallthrough comment Laurent Vivier
2020-09-11 19:33 ` [PULL 16/18] util/hexdump: Convert to take a void pointer argument Laurent Vivier
2020-09-11 19:33 ` Laurent Vivier [this message]
2020-09-11 19:33 ` [PULL 18/18] target/i386/kvm: Add missing fallthrough comment Laurent Vivier
2020-09-12 20:16 ` [PULL 00/18] Trivial branch for 5.2 patches Peter Maydell

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=20200911193330.1148942-18-laurent@vivier.eu \
    --to=laurent@vivier.eu \
    --cc=edgar.iglesias@xilinx.com \
    --cc=f4bug@amsat.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=sgarzare@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.