aboutsummaryrefslogtreecommitdiff
path: root/hw/virtio
diff options
context:
space:
mode:
authorRichard Henderson <richard.henderson@linaro.org>2024-04-12 00:33:22 -0700
committerRichard Henderson <richard.henderson@linaro.org>2024-06-05 12:13:42 -0700
commit53ee5f551e5743516c90a662425276cae4cf0aeb (patch)
tree4544265752101f0a14190e9bab455fae03b2a63b /hw/virtio
parentf1572ab94738bd5787b7badcd4bd93a3657f0680 (diff)
util/hexdump: Use a GString for qemu_hexdump_line
Allocate a new, or append to an existing GString instead of using a fixed sized buffer. Require the caller to determine the length of the line -- do not bound len here. Signed-off-by: Richard Henderson <richard.henderson@linaro.org> Message-Id: <20240412073346.458116-4-richard.henderson@linaro.org>
Diffstat (limited to 'hw/virtio')
-rw-r--r--hw/virtio/vhost-vdpa.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/hw/virtio/vhost-vdpa.c b/hw/virtio/vhost-vdpa.c
index 7368b71902..419463c154 100644
--- a/hw/virtio/vhost-vdpa.c
+++ b/hw/virtio/vhost-vdpa.c
@@ -944,13 +944,15 @@ static int vhost_vdpa_set_config_call(struct vhost_dev *dev,
static void vhost_vdpa_dump_config(struct vhost_dev *dev, const uint8_t *config,
uint32_t config_len)
{
- int b, len;
- char line[QEMU_HEXDUMP_LINE_LEN];
+ g_autoptr(GString) str = g_string_sized_new(4 * 16);
+ size_t b, len;
- for (b = 0; b < config_len; b += 16) {
- len = config_len - b;
- qemu_hexdump_line(line, config + b, len);
- trace_vhost_vdpa_dump_config(dev, b, line);
+ for (b = 0; b < config_len; b += len) {
+ len = MIN(config_len - b, 16);
+
+ g_string_truncate(str, 0);
+ qemu_hexdump_line(str, config + b, len);
+ trace_vhost_vdpa_dump_config(dev, b, str->str);
}
}