[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 7/9] hw/riscv/virt: Replace sprintf() by snprintf()
From: |
Philippe Mathieu-Daudé |
Subject: |
[PATCH 7/9] hw/riscv/virt: Replace sprintf() by snprintf() |
Date: |
Thu, 11 Apr 2024 12:43:38 +0200 |
sprintf() is deprecated on Darwin since macOS 13.0 / XCode 14.1,
resulting in painful developper experience. Use snprintf() instead.
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
hw/riscv/virt.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/hw/riscv/virt.c b/hw/riscv/virt.c
index d171e74f7b..b3fede1207 100644
--- a/hw/riscv/virt.c
+++ b/hw/riscv/virt.c
@@ -1619,7 +1619,7 @@ static char *virt_get_aia_guests(Object *obj, Error
**errp)
RISCVVirtState *s = RISCV_VIRT_MACHINE(obj);
char val[32];
- sprintf(val, "%d", s->aia_guests);
+ snprintf(val, sizeof(val), "%d", s->aia_guests);
return g_strdup(val);
}
@@ -1785,7 +1785,8 @@ static void virt_machine_class_init(ObjectClass *oc, void
*data)
object_class_property_add_str(oc, "aia-guests",
virt_get_aia_guests,
virt_set_aia_guests);
- sprintf(str, "Set number of guest MMIO pages for AIA IMSIC. Valid value "
+ snprintf(str, sizeof(str),
+ "Set number of guest MMIO pages for AIA IMSIC. Valid value "
"should be between 0 and %d.", VIRT_IRQCHIP_MAX_GUESTS);
object_class_property_set_description(oc, "aia-guests", str);
object_class_property_add(oc, "acpi", "OnOffAuto",
--
2.41.0
- [PATCH 3/9] disas/riscv: Replace sprintf() by snprintf(), (continued)
- [PATCH 3/9] disas/riscv: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 4/9] linux-user/flatload: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 5/9] hw/misc/imx: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 6/9] hw/net/rocker: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 7/9] hw/riscv/virt: Replace sprintf() by snprintf(),
Philippe Mathieu-Daudé <=
- [PATCH 8/9] target/arm: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11
- [PATCH 9/9] target/i386: Replace sprintf() by snprintf(), Philippe Mathieu-Daudé, 2024/04/11