[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 12/13] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf(
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH v2 12/13] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf() |
Date: |
Thu, 11 Apr 2024 12:15:48 +0200 |
sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
resulting in painful developper experience.
Use qemu_hexdump_line() to avoid sprintf() calls, silencing:
[5/8] Compiling C object libcommon.fa.p/hw_dma_pl330.c.o
hw/dma/pl330.c:333:13: warning: 'sprintf' is deprecated:
This function is provided for compatibility reasons only.
Due to security concerns inherent in the design of sprintf(3),
it is highly recommended that you use snprintf(3) instead.
[-Wdeprecated-declarations]
sprintf(tmpbuf + strlen(tmpbuf), " %02x", buf[b + i]);
^
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/dma/pl330.c | 12 +++---------
1 file changed, 3 insertions(+), 9 deletions(-)
diff --git a/hw/dma/pl330.c b/hw/dma/pl330.c
index 70a502d245..0435378b7e 100644
--- a/hw/dma/pl330.c
+++ b/hw/dma/pl330.c
@@ -15,6 +15,7 @@
*/
#include "qemu/osdep.h"
+#include "qemu/cutils.h"
#include "hw/irq.h"
#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
@@ -317,21 +318,14 @@ typedef struct PL330InsnDesc {
static void pl330_hexdump(uint8_t *buf, size_t size)
{
- unsigned int b, i, len;
- char tmpbuf[80];
+ unsigned int b, len;
for (b = 0; b < size; b += 16) {
len = size - b;
if (len > 16) {
len = 16;
}
- tmpbuf[0] = '\0';
- for (i = 0; i < len; i++) {
- if ((i % 4) == 0) {
- strcat(tmpbuf, " ");
- }
- sprintf(tmpbuf + strlen(tmpbuf), " %02x", buf[b + i]);
- }
+ g_autofree char *tmpbuf = qemu_hexdump_line(buf, b, len, false);
trace_pl330_hexdump(b, tmpbuf);
}
}
--
2.41.0
- Re: [PATCH v2 09/13] util/hexdump: Replace sprintf() by g_string_append_printf(), (continued)
- [PATCH v2 03/13] hw/ppc/spapr: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH v2 13/13] backends/tpm: Use qemu_hexdump_line() to avoid sprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH v2 11/13] hw/ide/atapi: Use qemu_hexdump_line() to avoid sprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH v2 08/13] util/hexdump: Have qemu_hexdump_line() return heap allocated buffer, Philippe Mathieu-Daudé, 2024/04/11
- [PATCH v2 10/13] hw/scsi/scsi-disk: Use qemu_hexdump_line() to avoid sprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH v2 12/13] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf(),
Philippe Mathieu-Daudé <=