[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 11/12] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 11/12] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf() |
Date: |
Wed, 10 Apr 2024 18:06:12 +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 05/12] system/qtest: Replace sprintf() by g_string_append_printf(), (continued)
- [PATCH 03/12] hw/ppc/spapr: Replace sprintf() by g_strdup_printf(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 04/12] hw/mips/malta: Replace sprintf() by g_string_append_printf(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 06/12] util/hexdump: Rename @offset argument in qemu_hexdump_line(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 07/12] util/hexdump: Have qemu_hexdump_line() return heap allocated buffer, Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 08/12] util/hexdump: Replace sprintf() by g_string_append_printf(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 12/12] backends/tpm: Use qemu_hexdump_line() to avoid sprintf(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 10/12] hw/ide/atapi: Use qemu_hexdump_line() to avoid sprintf(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 09/12] hw/scsi/scsi-disk: Use qemu_hexdump_line() to avoid sprintf(), Philippe Mathieu-Daudé, 2024/04/10
- [PATCH 11/12] hw/dma/pl330: Use qemu_hexdump_line() to avoid sprintf(),
Philippe Mathieu-Daudé <=
- Re: [PATCH 00/12] misc: Remove sprintf() due to macOS deprecation, Richard Henderson, 2024/04/10