* [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump()
@ 2020-08-22 18:09 Philippe Mathieu-Daudé
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
` (4 more replies)
0 siblings, 5 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-08-22 18:09 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, Philippe Mathieu-Daudé,
Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann, Edgar E. Iglesias,
Philippe Mathieu-Daudé,
David Gibson
- Pass const void* buffer
- Reorder arguments
Supersedes: <20200822150457.1322519-1-f4bug@amsat.org>
Philippe Mathieu-Daudé (2):
util/hexdump: Convert to take a void pointer argument
util/hexdump: Reorder qemu_hexdump() arguments
include/qemu-common.h | 3 ++-
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 +-
net/colo-compare.c | 24 ++++++++++++------------
net/net.c | 2 +-
util/hexdump.c | 4 +++-
util/iov.c | 2 +-
10 files changed, 24 insertions(+), 21 deletions(-)
--
2.26.2
^ permalink raw reply [flat|nested] 13+ messages in thread
* [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument
2020-08-22 18:09 [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Philippe Mathieu-Daudé
@ 2020-08-22 18:09 ` Philippe Mathieu-Daudé
2020-08-25 18:25 ` Alistair Francis
` (3 more replies)
2020-08-22 18:09 ` [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments Philippe Mathieu-Daudé
` (3 subsequent siblings)
4 siblings, 4 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-08-22 18:09 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, Philippe Mathieu-Daudé,
Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann, Edgar E. Iglesias,
Philippe Mathieu-Daudé,
David Gibson
Most uses of qemu_hexdump() do not take an array of char
as input, forcing use of cast. Since we can use this
helper to dump any kind of buffer, use a pointer to void
argument instead.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
Since v1:
- renamed argument 'bufptr' (Peter Maydell)
---
include/qemu-common.h | 3 ++-
hw/dma/xlnx_dpdma.c | 2 +-
hw/net/fsl_etsec/etsec.c | 2 +-
hw/sd/sd.c | 2 +-
hw/usb/redirect.c | 2 +-
net/colo-compare.c | 12 ++++++------
net/net.c | 2 +-
util/hexdump.c | 4 +++-
8 files changed, 16 insertions(+), 13 deletions(-)
diff --git a/include/qemu-common.h b/include/qemu-common.h
index bb9496bd80f..6834883822f 100644
--- a/include/qemu-common.h
+++ b/include/qemu-common.h
@@ -138,7 +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 char *buf, FILE *fp, const char *prefix, size_t size);
+void qemu_hexdump(const void *bufptr, FILE *fp,
+ const char *prefix, size_t size);
/*
* helper to parse debug environment variables
diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
index b40c897de2c..d75a8069426 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((char *)desc, stdout, "", sizeof(DPDMADescriptor));
+ qemu_hexdump(desc, stdout, "", sizeof(DPDMADescriptor));
}
}
diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
index 7035cf4eb97..c817a28decd 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((void *)buf, stderr, "", size);
+ qemu_hexdump(buf, stderr, "", size);
#endif
/* Flush is unnecessary as are already in receiving path */
etsec->need_flush = false;
diff --git a/hw/sd/sd.c b/hw/sd/sd.c
index fad9cf1ee7a..190e4cf1232 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1781,7 +1781,7 @@ send_response:
}
#ifdef DEBUG_SD
- qemu_hexdump((const char *)response, stderr, "Response", rsplen);
+ qemu_hexdump(response, stderr, "Response", rsplen);
#endif
return rsplen;
diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
index 417a60a2e68..09edb0d81c0 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((char *)data, stderr, desc, len);
+ qemu_hexdump(data, stderr, desc, len);
}
/*
diff --git a/net/colo-compare.c b/net/colo-compare.c
index 2c20de1537d..550272b3baa 100644
--- a/net/colo-compare.c
+++ b/net/colo-compare.c
@@ -494,9 +494,9 @@ sec:
g_queue_push_head(&conn->secondary_list, spkt);
if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
- qemu_hexdump((char *)ppkt->data, stderr,
+ qemu_hexdump(ppkt->data, stderr,
"colo-compare ppkt", ppkt->size);
- qemu_hexdump((char *)spkt->data, stderr,
+ qemu_hexdump(spkt->data, stderr,
"colo-compare spkt", spkt->size);
}
@@ -535,9 +535,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
+ qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
ppkt->size);
- qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
+ qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
spkt->size);
}
return -1;
@@ -578,9 +578,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
+ qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
ppkt->size);
- qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
+ qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
spkt->size);
}
return -1;
diff --git a/net/net.c b/net/net.c
index bbaedb3c7a6..f3e5d533fd7 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((const char *)buf, stdout, "net", size);
+ qemu_hexdump(buf, stdout, "net", size);
#endif
if (sender->link_down || !sender->peer) {
diff --git a/util/hexdump.c b/util/hexdump.c
index f879ff0ad6b..053f05d4160 100644
--- a/util/hexdump.c
+++ b/util/hexdump.c
@@ -16,8 +16,10 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
-void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
+void qemu_hexdump(const void *bufptr, FILE *fp,
+ const char *prefix, size_t size)
{
+ const char *buf = bufptr;
unsigned int b, len, i, c;
for (b = 0; b < size; b += 16) {
--
2.26.2
^ permalink raw reply related [flat|nested] 13+ messages in thread
* [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments
2020-08-22 18:09 [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Philippe Mathieu-Daudé
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
@ 2020-08-22 18:09 ` Philippe Mathieu-Daudé
2020-08-28 9:13 ` Edgar E. Iglesias
2020-09-11 15:52 ` Laurent Vivier
2020-08-28 9:09 ` [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Stefano Garzarella
` (2 subsequent siblings)
4 siblings, 2 replies; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-08-22 18:09 UTC (permalink / raw)
To: qemu-devel
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, Philippe Mathieu-Daudé,
Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann, Edgar E. Iglesias,
Philippe Mathieu-Daudé,
David Gibson
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>
---
include/qemu-common.h | 4 ++--
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 +-
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/include/qemu-common.h b/include/qemu-common.h
index 6834883822f..9cfd62669bf 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/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
index d75a8069426..967548abd31 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 c817a28decd..c5edb25dc9f 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 337a55fc957..628648a9c37 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 190e4cf1232..6508939b1f4 100644
--- a/hw/sd/sd.c
+++ b/hw/sd/sd.c
@@ -1781,7 +1781,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 09edb0d81c0..48f38d33912 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/net/colo-compare.c b/net/colo-compare.c
index 550272b3baa..4a5ed642e9a 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 f3e5d533fd7..7a2a0fb5ac6 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 053f05d4160..0b4662e701d 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 45ef3043eec..ae61d696aae 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
^ permalink raw reply related [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
@ 2020-08-25 18:25 ` Alistair Francis
2020-08-28 9:12 ` Edgar E. Iglesias
` (2 subsequent siblings)
3 siblings, 0 replies; 13+ messages in thread
From: Alistair Francis @ 2020-08-25 18:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, Qemu-block, Li Zhijian, QEMU Trivial, Jason Wang,
Alistair Francis, qemu-devel@nongnu.org Developers, Zhang Chen,
qemu-arm, open list:New World, Gerd Hoffmann, Edgar E. Iglesias,
Philippe Mathieu-Daudé,
David Gibson
On Sat, Aug 22, 2020 at 11:10 AM Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Most uses of qemu_hexdump() do not take an array of char
> as input, forcing use of cast. Since we can use this
> helper to dump any kind of buffer, use a pointer to void
> argument instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> Since v1:
> - renamed argument 'bufptr' (Peter Maydell)
> ---
> include/qemu-common.h | 3 ++-
> hw/dma/xlnx_dpdma.c | 2 +-
> hw/net/fsl_etsec/etsec.c | 2 +-
> hw/sd/sd.c | 2 +-
> hw/usb/redirect.c | 2 +-
> net/colo-compare.c | 12 ++++++------
> net/net.c | 2 +-
> util/hexdump.c | 4 +++-
> 8 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index bb9496bd80f..6834883822f 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -138,7 +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 char *buf, FILE *fp, const char *prefix, size_t size);
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size);
>
> /*
> * helper to parse debug environment variables
> diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index b40c897de2c..d75a8069426 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((char *)desc, stdout, "", sizeof(DPDMADescriptor));
> + qemu_hexdump(desc, stdout, "", sizeof(DPDMADescriptor));
> }
> }
>
> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
> index 7035cf4eb97..c817a28decd 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((void *)buf, stderr, "", size);
> + qemu_hexdump(buf, stderr, "", size);
> #endif
> /* Flush is unnecessary as are already in receiving path */
> etsec->need_flush = false;
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index fad9cf1ee7a..190e4cf1232 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1781,7 +1781,7 @@ send_response:
> }
>
> #ifdef DEBUG_SD
> - qemu_hexdump((const char *)response, stderr, "Response", rsplen);
> + qemu_hexdump(response, stderr, "Response", rsplen);
> #endif
>
> return rsplen;
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index 417a60a2e68..09edb0d81c0 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((char *)data, stderr, desc, len);
> + qemu_hexdump(data, stderr, desc, len);
> }
>
> /*
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index 2c20de1537d..550272b3baa 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -494,9 +494,9 @@ sec:
> g_queue_push_head(&conn->secondary_list, spkt);
>
> if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
> - qemu_hexdump((char *)ppkt->data, stderr,
> + qemu_hexdump(ppkt->data, stderr,
> "colo-compare ppkt", ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr,
> + qemu_hexdump(spkt->data, stderr,
> "colo-compare spkt", spkt->size);
> }
>
> @@ -535,9 +535,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> @@ -578,9 +578,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> diff --git a/net/net.c b/net/net.c
> index bbaedb3c7a6..f3e5d533fd7 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((const char *)buf, stdout, "net", size);
> + qemu_hexdump(buf, stdout, "net", size);
> #endif
>
> if (sender->link_down || !sender->peer) {
> diff --git a/util/hexdump.c b/util/hexdump.c
> index f879ff0ad6b..053f05d4160 100644
> --- a/util/hexdump.c
> +++ b/util/hexdump.c
> @@ -16,8 +16,10 @@
> #include "qemu/osdep.h"
> #include "qemu-common.h"
>
> -void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size)
> {
> + const char *buf = bufptr;
> unsigned int b, len, i, c;
>
> for (b = 0; b < size; b += 16) {
> --
> 2.26.2
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump()
2020-08-22 18:09 [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Philippe Mathieu-Daudé
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
2020-08-22 18:09 ` [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments Philippe Mathieu-Daudé
@ 2020-08-28 9:09 ` Stefano Garzarella
2020-09-01 3:17 ` Jason Wang
2020-09-11 14:35 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 13+ messages in thread
From: Stefano Garzarella @ 2020-08-28 9:09 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, qemu-devel, Zhang Chen, qemu-arm, qemu-ppc,
Gerd Hoffmann, Edgar E. Iglesias, Philippe Mathieu-Daudé,
David Gibson
On Sat, Aug 22, 2020 at 08:09:48PM +0200, Philippe Mathieu-Daudé wrote:
> - Pass const void* buffer
> - Reorder arguments
>
> Supersedes: <20200822150457.1322519-1-f4bug@amsat.org>
>
> Philippe Mathieu-Daudé (2):
> util/hexdump: Convert to take a void pointer argument
> util/hexdump: Reorder qemu_hexdump() arguments
>
> include/qemu-common.h | 3 ++-
> 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 +-
> net/colo-compare.c | 24 ++++++++++++------------
> net/net.c | 2 +-
> util/hexdump.c | 4 +++-
> util/iov.c | 2 +-
> 10 files changed, 24 insertions(+), 21 deletions(-)
>
> --
> 2.26.2
>
>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
2020-08-25 18:25 ` Alistair Francis
@ 2020-08-28 9:12 ` Edgar E. Iglesias
2020-08-28 9:56 ` Li Qiang
2020-09-11 15:51 ` Laurent Vivier
3 siblings, 0 replies; 13+ messages in thread
From: Edgar E. Iglesias @ 2020-08-28 9:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, qemu-devel, Zhang Chen, qemu-arm, qemu-ppc,
Gerd Hoffmann, Philippe Mathieu-Daudé,
David Gibson
On Sat, Aug 22, 2020 at 08:09:49PM +0200, Philippe Mathieu-Daudé wrote:
> Most uses of qemu_hexdump() do not take an array of char
> as input, forcing use of cast. Since we can use this
> helper to dump any kind of buffer, use a pointer to void
> argument instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Edgar E. Iglesias <edgar.iglesias@xilinx.com>
> ---
> Since v1:
> - renamed argument 'bufptr' (Peter Maydell)
> ---
> include/qemu-common.h | 3 ++-
> hw/dma/xlnx_dpdma.c | 2 +-
> hw/net/fsl_etsec/etsec.c | 2 +-
> hw/sd/sd.c | 2 +-
> hw/usb/redirect.c | 2 +-
> net/colo-compare.c | 12 ++++++------
> net/net.c | 2 +-
> util/hexdump.c | 4 +++-
> 8 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index bb9496bd80f..6834883822f 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -138,7 +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 char *buf, FILE *fp, const char *prefix, size_t size);
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size);
>
> /*
> * helper to parse debug environment variables
> diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index b40c897de2c..d75a8069426 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((char *)desc, stdout, "", sizeof(DPDMADescriptor));
> + qemu_hexdump(desc, stdout, "", sizeof(DPDMADescriptor));
> }
> }
>
> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
> index 7035cf4eb97..c817a28decd 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((void *)buf, stderr, "", size);
> + qemu_hexdump(buf, stderr, "", size);
> #endif
> /* Flush is unnecessary as are already in receiving path */
> etsec->need_flush = false;
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index fad9cf1ee7a..190e4cf1232 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1781,7 +1781,7 @@ send_response:
> }
>
> #ifdef DEBUG_SD
> - qemu_hexdump((const char *)response, stderr, "Response", rsplen);
> + qemu_hexdump(response, stderr, "Response", rsplen);
> #endif
>
> return rsplen;
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index 417a60a2e68..09edb0d81c0 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((char *)data, stderr, desc, len);
> + qemu_hexdump(data, stderr, desc, len);
> }
>
> /*
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index 2c20de1537d..550272b3baa 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -494,9 +494,9 @@ sec:
> g_queue_push_head(&conn->secondary_list, spkt);
>
> if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
> - qemu_hexdump((char *)ppkt->data, stderr,
> + qemu_hexdump(ppkt->data, stderr,
> "colo-compare ppkt", ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr,
> + qemu_hexdump(spkt->data, stderr,
> "colo-compare spkt", spkt->size);
> }
>
> @@ -535,9 +535,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> @@ -578,9 +578,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> diff --git a/net/net.c b/net/net.c
> index bbaedb3c7a6..f3e5d533fd7 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((const char *)buf, stdout, "net", size);
> + qemu_hexdump(buf, stdout, "net", size);
> #endif
>
> if (sender->link_down || !sender->peer) {
> diff --git a/util/hexdump.c b/util/hexdump.c
> index f879ff0ad6b..053f05d4160 100644
> --- a/util/hexdump.c
> +++ b/util/hexdump.c
> @@ -16,8 +16,10 @@
> #include "qemu/osdep.h"
> #include "qemu-common.h"
>
> -void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size)
> {
> + const char *buf = bufptr;
> unsigned int b, len, i, c;
>
> for (b = 0; b < size; b += 16) {
> --
> 2.26.2
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments
2020-08-22 18:09 ` [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments Philippe Mathieu-Daudé
@ 2020-08-28 9:13 ` Edgar E. Iglesias
2020-09-11 15:52 ` Laurent Vivier
1 sibling, 0 replies; 13+ messages in thread
From: Edgar E. Iglesias @ 2020-08-28 9:13 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, qemu-devel, Zhang Chen, qemu-arm, qemu-ppc,
Gerd Hoffmann, Philippe Mathieu-Daudé,
David Gibson
On Sat, Aug 22, 2020 at 08:09:50PM +0200, Philippe Mathieu-Daudé wrote:
> 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>
> ---
> include/qemu-common.h | 4 ++--
> 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 +-
> 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/include/qemu-common.h b/include/qemu-common.h
> index 6834883822f..9cfd62669bf 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/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index d75a8069426..967548abd31 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 c817a28decd..c5edb25dc9f 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 337a55fc957..628648a9c37 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 190e4cf1232..6508939b1f4 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1781,7 +1781,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 09edb0d81c0..48f38d33912 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/net/colo-compare.c b/net/colo-compare.c
> index 550272b3baa..4a5ed642e9a 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 f3e5d533fd7..7a2a0fb5ac6 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 053f05d4160..0b4662e701d 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 45ef3043eec..ae61d696aae 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
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
2020-08-25 18:25 ` Alistair Francis
2020-08-28 9:12 ` Edgar E. Iglesias
@ 2020-08-28 9:56 ` Li Qiang
2020-09-11 15:51 ` Laurent Vivier
3 siblings, 0 replies; 13+ messages in thread
From: Li Qiang @ 2020-08-28 9:56 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, Qemu Developers, Zhang Chen, qemu-arm,
qemu-ppc, Gerd Hoffmann, Edgar E. Iglesias,
Philippe Mathieu-Daudé,
David Gibson
Philippe Mathieu-Daudé <f4bug@amsat.org> 于2020年8月23日周日 上午2:11写道:
>
> Most uses of qemu_hexdump() do not take an array of char
> as input, forcing use of cast. Since we can use this
> helper to dump any kind of buffer, use a pointer to void
> argument instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
> ---
> Since v1:
> - renamed argument 'bufptr' (Peter Maydell)
> ---
> include/qemu-common.h | 3 ++-
> hw/dma/xlnx_dpdma.c | 2 +-
> hw/net/fsl_etsec/etsec.c | 2 +-
> hw/sd/sd.c | 2 +-
> hw/usb/redirect.c | 2 +-
> net/colo-compare.c | 12 ++++++------
> net/net.c | 2 +-
> util/hexdump.c | 4 +++-
> 8 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index bb9496bd80f..6834883822f 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -138,7 +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 char *buf, FILE *fp, const char *prefix, size_t size);
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size);
>
> /*
> * helper to parse debug environment variables
> diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index b40c897de2c..d75a8069426 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((char *)desc, stdout, "", sizeof(DPDMADescriptor));
> + qemu_hexdump(desc, stdout, "", sizeof(DPDMADescriptor));
> }
> }
>
> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
> index 7035cf4eb97..c817a28decd 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((void *)buf, stderr, "", size);
> + qemu_hexdump(buf, stderr, "", size);
> #endif
> /* Flush is unnecessary as are already in receiving path */
> etsec->need_flush = false;
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index fad9cf1ee7a..190e4cf1232 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1781,7 +1781,7 @@ send_response:
> }
>
> #ifdef DEBUG_SD
> - qemu_hexdump((const char *)response, stderr, "Response", rsplen);
> + qemu_hexdump(response, stderr, "Response", rsplen);
> #endif
>
> return rsplen;
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index 417a60a2e68..09edb0d81c0 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((char *)data, stderr, desc, len);
> + qemu_hexdump(data, stderr, desc, len);
> }
>
> /*
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index 2c20de1537d..550272b3baa 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -494,9 +494,9 @@ sec:
> g_queue_push_head(&conn->secondary_list, spkt);
>
> if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
> - qemu_hexdump((char *)ppkt->data, stderr,
> + qemu_hexdump(ppkt->data, stderr,
> "colo-compare ppkt", ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr,
> + qemu_hexdump(spkt->data, stderr,
> "colo-compare spkt", spkt->size);
> }
>
> @@ -535,9 +535,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> @@ -578,9 +578,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> diff --git a/net/net.c b/net/net.c
> index bbaedb3c7a6..f3e5d533fd7 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((const char *)buf, stdout, "net", size);
> + qemu_hexdump(buf, stdout, "net", size);
> #endif
>
> if (sender->link_down || !sender->peer) {
> diff --git a/util/hexdump.c b/util/hexdump.c
> index f879ff0ad6b..053f05d4160 100644
> --- a/util/hexdump.c
> +++ b/util/hexdump.c
> @@ -16,8 +16,10 @@
> #include "qemu/osdep.h"
> #include "qemu-common.h"
>
> -void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size)
> {
> + const char *buf = bufptr;
> unsigned int b, len, i, c;
>
> for (b = 0; b < size; b += 16) {
> --
> 2.26.2
>
>
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump()
2020-08-22 18:09 [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-08-28 9:09 ` [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Stefano Garzarella
@ 2020-09-01 3:17 ` Jason Wang
2020-09-11 14:35 ` Philippe Mathieu-Daudé
4 siblings, 0 replies; 13+ messages in thread
From: Jason Wang @ 2020-09-01 3:17 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial,
Alistair Francis, Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann,
Edgar E. Iglesias, Philippe Mathieu-Daudé,
David Gibson
On 2020/8/23 上午2:09, Philippe Mathieu-Daudé wrote:
> - Pass const void* buffer
> - Reorder arguments
>
> Supersedes: <20200822150457.1322519-1-f4bug@amsat.org>
>
> Philippe Mathieu-Daudé (2):
> util/hexdump: Convert to take a void pointer argument
> util/hexdump: Reorder qemu_hexdump() arguments
>
> include/qemu-common.h | 3 ++-
> 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 +-
> net/colo-compare.c | 24 ++++++++++++------------
> net/net.c | 2 +-
> util/hexdump.c | 4 +++-
> util/iov.c | 2 +-
> 10 files changed, 24 insertions(+), 21 deletions(-)
>
Applied.
Thanks
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump()
2020-08-22 18:09 [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2020-09-01 3:17 ` Jason Wang
@ 2020-09-11 14:35 ` Philippe Mathieu-Daudé
2020-09-11 15:52 ` Laurent Vivier
4 siblings, 1 reply; 13+ messages in thread
From: Philippe Mathieu-Daudé @ 2020-09-11 14:35 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial
Cc: Peter Maydell, qemu-block, Li Zhijian, Jason Wang,
Alistair Francis, Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann,
Edgar E. Iglesias, David Gibson
Hi Laurent,
On 8/22/20 8:09 PM, Philippe Mathieu-Daudé wrote:
> - Pass const void* buffer
> - Reorder arguments
>
> Supersedes: <20200822150457.1322519-1-f4bug@amsat.org>
>
> Philippe Mathieu-Daudé (2):
> util/hexdump: Convert to take a void pointer argument
> util/hexdump: Reorder qemu_hexdump() arguments
This series is fully reviewed, can it go via
your qemu-trivial tree?
Thanks,
Phil.
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2020-08-28 9:56 ` Li Qiang
@ 2020-09-11 15:51 ` Laurent Vivier
3 siblings, 0 replies; 13+ messages in thread
From: Laurent Vivier @ 2020-09-11 15:51 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann,
Edgar E. Iglesias, Philippe Mathieu-Daudé,
David Gibson
Le 22/08/2020 à 20:09, Philippe Mathieu-Daudé a écrit :
> Most uses of qemu_hexdump() do not take an array of char
> as input, forcing use of cast. Since we can use this
> helper to dump any kind of buffer, use a pointer to void
> argument instead.
>
> Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
> ---
> Since v1:
> - renamed argument 'bufptr' (Peter Maydell)
> ---
> include/qemu-common.h | 3 ++-
> hw/dma/xlnx_dpdma.c | 2 +-
> hw/net/fsl_etsec/etsec.c | 2 +-
> hw/sd/sd.c | 2 +-
> hw/usb/redirect.c | 2 +-
> net/colo-compare.c | 12 ++++++------
> net/net.c | 2 +-
> util/hexdump.c | 4 +++-
> 8 files changed, 16 insertions(+), 13 deletions(-)
>
> diff --git a/include/qemu-common.h b/include/qemu-common.h
> index bb9496bd80f..6834883822f 100644
> --- a/include/qemu-common.h
> +++ b/include/qemu-common.h
> @@ -138,7 +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 char *buf, FILE *fp, const char *prefix, size_t size);
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size);
>
> /*
> * helper to parse debug environment variables
> diff --git a/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index b40c897de2c..d75a8069426 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((char *)desc, stdout, "", sizeof(DPDMADescriptor));
> + qemu_hexdump(desc, stdout, "", sizeof(DPDMADescriptor));
> }
> }
>
> diff --git a/hw/net/fsl_etsec/etsec.c b/hw/net/fsl_etsec/etsec.c
> index 7035cf4eb97..c817a28decd 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((void *)buf, stderr, "", size);
> + qemu_hexdump(buf, stderr, "", size);
> #endif
> /* Flush is unnecessary as are already in receiving path */
> etsec->need_flush = false;
> diff --git a/hw/sd/sd.c b/hw/sd/sd.c
> index fad9cf1ee7a..190e4cf1232 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1781,7 +1781,7 @@ send_response:
> }
>
> #ifdef DEBUG_SD
> - qemu_hexdump((const char *)response, stderr, "Response", rsplen);
> + qemu_hexdump(response, stderr, "Response", rsplen);
> #endif
>
> return rsplen;
> diff --git a/hw/usb/redirect.c b/hw/usb/redirect.c
> index 417a60a2e68..09edb0d81c0 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((char *)data, stderr, desc, len);
> + qemu_hexdump(data, stderr, desc, len);
> }
>
> /*
> diff --git a/net/colo-compare.c b/net/colo-compare.c
> index 2c20de1537d..550272b3baa 100644
> --- a/net/colo-compare.c
> +++ b/net/colo-compare.c
> @@ -494,9 +494,9 @@ sec:
> g_queue_push_head(&conn->secondary_list, spkt);
>
> if (trace_event_get_state_backends(TRACE_COLO_COMPARE_MISCOMPARE)) {
> - qemu_hexdump((char *)ppkt->data, stderr,
> + qemu_hexdump(ppkt->data, stderr,
> "colo-compare ppkt", ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr,
> + qemu_hexdump(spkt->data, stderr,
> "colo-compare spkt", spkt->size);
> }
>
> @@ -535,9 +535,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> @@ -578,9 +578,9 @@ 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((char *)ppkt->data, stderr, "colo-compare pri pkt",
> + qemu_hexdump(ppkt->data, stderr, "colo-compare pri pkt",
> ppkt->size);
> - qemu_hexdump((char *)spkt->data, stderr, "colo-compare sec pkt",
> + qemu_hexdump(spkt->data, stderr, "colo-compare sec pkt",
> spkt->size);
> }
> return -1;
> diff --git a/net/net.c b/net/net.c
> index bbaedb3c7a6..f3e5d533fd7 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((const char *)buf, stdout, "net", size);
> + qemu_hexdump(buf, stdout, "net", size);
> #endif
>
> if (sender->link_down || !sender->peer) {
> diff --git a/util/hexdump.c b/util/hexdump.c
> index f879ff0ad6b..053f05d4160 100644
> --- a/util/hexdump.c
> +++ b/util/hexdump.c
> @@ -16,8 +16,10 @@
> #include "qemu/osdep.h"
> #include "qemu-common.h"
>
> -void qemu_hexdump(const char *buf, FILE *fp, const char *prefix, size_t size)
> +void qemu_hexdump(const void *bufptr, FILE *fp,
> + const char *prefix, size_t size)
> {
> + const char *buf = bufptr;
> unsigned int b, len, i, c;
>
> for (b = 0; b < size; b += 16) {
>
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments
2020-08-22 18:09 ` [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments Philippe Mathieu-Daudé
2020-08-28 9:13 ` Edgar E. Iglesias
@ 2020-09-11 15:52 ` Laurent Vivier
1 sibling, 0 replies; 13+ messages in thread
From: Laurent Vivier @ 2020-09-11 15:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: Peter Maydell, qemu-block, Li Zhijian, qemu-trivial, Jason Wang,
Alistair Francis, Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann,
Edgar E. Iglesias, Philippe Mathieu-Daudé,
David Gibson
Le 22/08/2020 à 20:09, Philippe Mathieu-Daudé a écrit :
> 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>
> ---
> include/qemu-common.h | 4 ++--
> 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 +-
> 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/include/qemu-common.h b/include/qemu-common.h
> index 6834883822f..9cfd62669bf 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/hw/dma/xlnx_dpdma.c b/hw/dma/xlnx_dpdma.c
> index d75a8069426..967548abd31 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 c817a28decd..c5edb25dc9f 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 337a55fc957..628648a9c37 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 190e4cf1232..6508939b1f4 100644
> --- a/hw/sd/sd.c
> +++ b/hw/sd/sd.c
> @@ -1781,7 +1781,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 09edb0d81c0..48f38d33912 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/net/colo-compare.c b/net/colo-compare.c
> index 550272b3baa..4a5ed642e9a 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 f3e5d533fd7..7a2a0fb5ac6 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 053f05d4160..0b4662e701d 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 45ef3043eec..ae61d696aae 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);
> }
>
>
Applied to my trivial-patches branch.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 13+ messages in thread
* Re: [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump()
2020-09-11 14:35 ` Philippe Mathieu-Daudé
@ 2020-09-11 15:52 ` Laurent Vivier
0 siblings, 0 replies; 13+ messages in thread
From: Laurent Vivier @ 2020-09-11 15:52 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel, qemu-trivial
Cc: Peter Maydell, qemu-block, Li Zhijian, Jason Wang,
Alistair Francis, Zhang Chen, qemu-arm, qemu-ppc, Gerd Hoffmann,
Edgar E. Iglesias, David Gibson
Le 11/09/2020 à 16:35, Philippe Mathieu-Daudé a écrit :
> Hi Laurent,
>
> On 8/22/20 8:09 PM, Philippe Mathieu-Daudé wrote:
>> - Pass const void* buffer
>> - Reorder arguments
>>
>> Supersedes: <20200822150457.1322519-1-f4bug@amsat.org>
>>
>> Philippe Mathieu-Daudé (2):
>> util/hexdump: Convert to take a void pointer argument
>> util/hexdump: Reorder qemu_hexdump() arguments
>
> This series is fully reviewed, can it go via
> your qemu-trivial tree?
Done.
Thanks,
Laurent
^ permalink raw reply [flat|nested] 13+ messages in thread
end of thread, other threads:[~2020-09-11 15:57 UTC | newest]
Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-08-22 18:09 [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Philippe Mathieu-Daudé
2020-08-22 18:09 ` [PATCH v2 1/2] util/hexdump: Convert to take a void pointer argument Philippe Mathieu-Daudé
2020-08-25 18:25 ` Alistair Francis
2020-08-28 9:12 ` Edgar E. Iglesias
2020-08-28 9:56 ` Li Qiang
2020-09-11 15:51 ` Laurent Vivier
2020-08-22 18:09 ` [PATCH v2 2/2] util/hexdump: Reorder qemu_hexdump() arguments Philippe Mathieu-Daudé
2020-08-28 9:13 ` Edgar E. Iglesias
2020-09-11 15:52 ` Laurent Vivier
2020-08-28 9:09 ` [PATCH v2 0/2] util/hexdump: Cleanup qemu_hexdump() Stefano Garzarella
2020-09-01 3:17 ` Jason Wang
2020-09-11 14:35 ` Philippe Mathieu-Daudé
2020-09-11 15:52 ` Laurent Vivier
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.