* [PATCH v2 01/17] tests/qtest: Use qemu_hexdump_to_buffer() in qtest_memwrite()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-06 16:02 ` Peter Maydell
2026-11-05 12:51 ` [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf() Philippe Mathieu-Daudé
` (15 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Fabiano Rosas, Laurent Vivier, Paolo Bonzini
Replace sprintf("%02x) by equivalent qemu_hexdump_to_buffer()
helper and silent when using Apple clang 17.0.0:
../tests/qtest/libqtest.c:1522:9: 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]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
tests/qtest/libqtest.c | 6 +-----
1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c
index 7f66c1bbb3b6..b6b9f8fe161d 100644
--- a/tests/qtest/libqtest.c
+++ b/tests/qtest/libqtest.c
@@ -1509,7 +1509,6 @@ void qtest_bufread(QTestState *s, uint64_t addr, void *data, size_t size)
void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
{
const uint8_t *ptr = data;
- size_t i;
char *enc;
if (!size) {
@@ -1517,10 +1516,7 @@ void qtest_memwrite(QTestState *s, uint64_t addr, const void *data, size_t size)
}
enc = g_malloc(2 * size + 1);
-
- for (i = 0; i < size; i++) {
- sprintf(&enc[i * 2], "%02x", ptr[i]);
- }
+ qemu_hexdump_to_buffer(enc, 2 * size + 1, ptr, size);
qtest_sendf(s, "write 0x%" PRIx64 " 0x%zx 0x%s\n", addr, size, enc);
qtest_rsp(s);
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 01/17] tests/qtest: Use qemu_hexdump_to_buffer() in qtest_memwrite()
2026-11-05 12:51 ` [PATCH v2 01/17] tests/qtest: Use qemu_hexdump_to_buffer() in qtest_memwrite() Philippe Mathieu-Daudé
@ 2026-11-06 16:02 ` Peter Maydell
0 siblings, 0 replies; 31+ messages in thread
From: Peter Maydell @ 2026-11-06 16:02 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Fabiano Rosas,
Laurent Vivier, Paolo Bonzini
On Thu, 5 Nov 2026 at 12:53, Philippe Mathieu-Daudé
<philmd@oss.qualcomm.com> wrote:
>
> Replace sprintf("%02x) by equivalent qemu_hexdump_to_buffer()
> helper and silent when using Apple clang 17.0.0:
>
> ../tests/qtest/libqtest.c:1522:9: 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]
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 01/17] tests/qtest: Use qemu_hexdump_to_buffer() in qtest_memwrite() Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 16:02 ` Alex Bennée
2026-11-05 12:51 ` [PATCH v2 03/17] tests/unit/qobject: " Philippe Mathieu-Daudé
` (14 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Tyrone Ting, Hao Wu, Fabiano Rosas, Laurent Vivier, Paolo Bonzini
Replace sprintf() by safer g_strdup_printf() to fill the QOM path
and property names. This silences when using Apple clang 17.0.0:
../tests/qtest/npcm7xx_adc-test.c:140:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/qtest/npcm7xx_adc-test.c:322:9: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/qtest/npcm7xx_pwm-test.c:244:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/qtest/npcm7xx_pwm-test.c:245:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/qtest/npcm7xx_pwm-test.c:255:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/qtest/npcm7xx_pwm-test.c:256:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
tests/qtest/npcm7xx_adc-test.c | 8 ++++----
tests/qtest/npcm7xx_pwm-test.c | 14 ++++----------
2 files changed, 8 insertions(+), 14 deletions(-)
diff --git a/tests/qtest/npcm7xx_adc-test.c b/tests/qtest/npcm7xx_adc-test.c
index 8bc89b8a8b9a..85915d6f1243 100644
--- a/tests/qtest/npcm7xx_adc-test.c
+++ b/tests/qtest/npcm7xx_adc-test.c
@@ -135,9 +135,8 @@ static void adc_qom_set(QTestState *qts, const ADC *adc,
static void adc_write_input(QTestState *qts, const ADC *adc,
uint32_t index, uint32_t value)
{
- char name[100];
+ g_autofree char *name = g_strdup_printf("adci[%u]", index);
- sprintf(name, "adci[%u]", index);
adc_qom_set(qts, adc, name, value);
}
@@ -316,10 +315,11 @@ static void test_calibrate(gconstpointer adc_p)
adc_calculate_output(R0_INPUT, iref),
adc_calculate_output(R1_INPUT, iref),
};
- char buf[100];
+ g_autofree char *buf = g_strdup_printf("-machine quanta-gsj"
+ " -global npcm7xx-adc.iref=%u",
+ iref);
QTestState *qts;
- sprintf(buf, "-machine quanta-gsj -global npcm7xx-adc.iref=%u", iref);
qts = qtest_init(buf);
/* Check the converted value is correct using the calibration value. */
diff --git a/tests/qtest/npcm7xx_pwm-test.c b/tests/qtest/npcm7xx_pwm-test.c
index 052ea876621a..400d44f424e1 100644
--- a/tests/qtest/npcm7xx_pwm-test.c
+++ b/tests/qtest/npcm7xx_pwm-test.c
@@ -238,22 +238,16 @@ static uint64_t pwm_qom_get(QTestState *qts, const char *path, const char *name)
static uint64_t pwm_get_freq(QTestState *qts, int module_index, int pwm_index)
{
- char path[100];
- char name[100];
-
- sprintf(path, "/machine/soc/pwm[%d]", module_index);
- sprintf(name, "freq[%d]", pwm_index);
+ g_autofree char *path = g_strdup_printf("/machine/soc/pwm[%d]", module_index);
+ g_autofree char *name = g_strdup_printf("freq[%d]", pwm_index);
return pwm_qom_get(qts, path, name);
}
static uint64_t pwm_get_duty(QTestState *qts, int module_index, int pwm_index)
{
- char path[100];
- char name[100];
-
- sprintf(path, "/machine/soc/pwm[%d]", module_index);
- sprintf(name, "duty[%d]", pwm_index);
+ g_autofree char *path = g_strdup_printf("/machine/soc/pwm[%d]", module_index);
+ g_autofree char *name = g_strdup_printf("duty[%d]", pwm_index);
return pwm_qom_get(qts, path, name);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 ` [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf() Philippe Mathieu-Daudé
@ 2026-11-05 16:02 ` Alex Bennée
2026-11-06 18:52 ` Hao Wu
0 siblings, 1 reply; 31+ messages in thread
From: Alex Bennée @ 2026-11-05 16:02 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Tyrone Ting, Hao Wu,
Fabiano Rosas, Laurent Vivier, Paolo Bonzini
Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:
> Replace sprintf() by safer g_strdup_printf() to fill the QOM path
> and property names. This silences when using Apple clang 17.0.0:
>
> ../tests/qtest/npcm7xx_adc-test.c:140:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
> ../tests/qtest/npcm7xx_adc-test.c:322:9: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
> ../tests/qtest/npcm7xx_pwm-test.c:244:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
> ../tests/qtest/npcm7xx_pwm-test.c:245:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
> ../tests/qtest/npcm7xx_pwm-test.c:255:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
> ../tests/qtest/npcm7xx_pwm-test.c:256:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 16:02 ` Alex Bennée
@ 2026-11-06 18:52 ` Hao Wu
0 siblings, 0 replies; 31+ messages in thread
From: Hao Wu @ 2026-11-06 18:52 UTC (permalink / raw)
To: Alex Bennée
Cc: Philippe Mathieu-Daudé, qemu-devel, qemu-riscv, qemu-arm,
qemu-ppc, Tyrone Ting, Fabiano Rosas, Laurent Vivier,
Paolo Bonzini
[-- Attachment #1: Type: text/plain, Size: 1208 bytes --]
On Thu, Nov 5, 2026 at 8:02 AM Alex Bennée <alex.bennee@linaro.org> wrote:
> Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:
>
> > Replace sprintf() by safer g_strdup_printf() to fill the QOM path
> > and property names. This silences when using Apple clang 17.0.0:
> >
> > ../tests/qtest/npcm7xx_adc-test.c:140:5: warning: 'sprintf' is
> deprecated [-Wdeprecated-declarations]
> > ../tests/qtest/npcm7xx_adc-test.c:322:9: warning: 'sprintf' is
> deprecated [-Wdeprecated-declarations]
> > ../tests/qtest/npcm7xx_pwm-test.c:244:5: warning: 'sprintf' is
> deprecated [-Wdeprecated-declarations]
> > ../tests/qtest/npcm7xx_pwm-test.c:245:5: warning: 'sprintf' is
> deprecated [-Wdeprecated-declarations]
> > ../tests/qtest/npcm7xx_pwm-test.c:255:5: warning: 'sprintf' is
> deprecated [-Wdeprecated-declarations]
> > ../tests/qtest/npcm7xx_pwm-test.c:256:5: warning: 'sprintf' is
> deprecated [-Wdeprecated-declarations]
> >
> > Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
>
> Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
>
Reviewed-by: Hao Wu <wuhaotsh@google.com>
>
> --
> Alex Bennée
> Virtualisation Tech Lead @ Linaro
>
[-- Attachment #2: Type: text/html, Size: 2038 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 03/17] tests/unit/qobject: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 01/17] tests/qtest: Use qemu_hexdump_to_buffer() in qtest_memwrite() Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf() Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 16:03 ` Alex Bennée
2026-11-05 12:51 ` [PATCH v2 04/17] tests/unit/visitor: Replace deprecated sprintf() with snprintf() Philippe Mathieu-Daudé
` (13 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Markus Armbruster, Michael Roth
Replace sprintf() by safer g_strdup_printf() to avoid
when using Apple clang 17.0.0 on macOS ARM64:
../tests/unit/test-qobject-output-visitor.c:598:9: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/unit/test-qobject-input-visitor.c:600:9: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
tests/unit/test-qobject-input-visitor.c | 4 +---
tests/unit/test-qobject-output-visitor.c | 3 +--
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/tests/unit/test-qobject-input-visitor.c b/tests/unit/test-qobject-input-visitor.c
index beee11db4e47..d4d2f7f1ee0a 100644
--- a/tests/unit/test-qobject-input-visitor.c
+++ b/tests/unit/test-qobject-input-visitor.c
@@ -595,9 +595,7 @@ static void test_visitor_in_list_struct(TestInputVisitorData *data,
i = 0;
for (str_list = arrs->string; str_list; str_list = str_list->next) {
- char expected[32];
-
- sprintf(expected, "%d", i);
+ g_autofree char *expected = g_strdup_printf("%d", i);
g_assert_cmpstr(str_list->value, ==, expected);
i++;
}
diff --git a/tests/unit/test-qobject-output-visitor.c b/tests/unit/test-qobject-output-visitor.c
index 3c47b28f6638..b240cb326c4e 100644
--- a/tests/unit/test-qobject-output-visitor.c
+++ b/tests/unit/test-qobject-output-visitor.c
@@ -592,10 +592,9 @@ static void test_visitor_out_list_struct(TestOutputVisitorData *data,
i = 0;
QLIST_FOREACH_ENTRY(qlist, e) {
QString *qvalue = qobject_to(QString, qlist_entry_obj(e));
- char expected[32];
+ g_autofree char *expected = g_strdup_printf("%d", i);
g_assert(qvalue);
- sprintf(expected, "%d", i);
g_assert_cmpstr(qstring_get_str(qvalue), ==, expected);
i++;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 03/17] tests/unit/qobject: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 ` [PATCH v2 03/17] tests/unit/qobject: " Philippe Mathieu-Daudé
@ 2026-11-05 16:03 ` Alex Bennée
0 siblings, 0 replies; 31+ messages in thread
From: Alex Bennée @ 2026-11-05 16:03 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Markus Armbruster,
Michael Roth
Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:
> Replace sprintf() by safer g_strdup_printf() to avoid
> when using Apple clang 17.0.0 on macOS ARM64:
>
> ../tests/unit/test-qobject-output-visitor.c:598:9: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
> ../tests/unit/test-qobject-input-visitor.c:600:9: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 04/17] tests/unit/visitor: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (2 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 03/17] tests/unit/qobject: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 05/17] hw/ppc/vof: " Philippe Mathieu-Daudé
` (12 subsequent siblings)
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Markus Armbruster, Michael Roth
Replace sprintf() by safer snprintf() to avoid when using
Apple clang 17.0.0 on macOS ARM64:
../tests/unit/test-visitor-serialization.c:1031:5: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
../tests/unit/test-visitor-serialization.c:1035:13: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
...
Use pstrcpy() when no formatting is needed.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
tests/unit/test-visitor-serialization.c | 21 +++++++++++++--------
1 file changed, 13 insertions(+), 8 deletions(-)
diff --git a/tests/unit/test-visitor-serialization.c b/tests/unit/test-visitor-serialization.c
index 2d365999fc82..254c24d5cda4 100644
--- a/tests/unit/test-visitor-serialization.c
+++ b/tests/unit/test-visitor-serialization.c
@@ -14,6 +14,7 @@
#include "qemu/osdep.h"
#include <float.h>
+#include "qemu/cutils.h"
#include "test-qapi-visit.h"
#include "qapi/error.h"
#include "qobject/qjson.h"
@@ -1028,12 +1029,13 @@ static void add_visitor_type(const SerializeOps *ops)
TestArgs *args;
int i = 0;
- sprintf(testname_prefix, "/visitor/serialization/%s", ops->type);
+ snprintf(testname_prefix, sizeof(testname_prefix),
+ "/visitor/serialization/%s", ops->type);
if (ops->caps & VCAP_PRIMITIVES) {
while (pt_values[i].type != PTYPE_EOL) {
- sprintf(testname, "%s/primitives/%s", testname_prefix,
- pt_values[i].description);
+ snprintf(testname, sizeof(testname), "%s/primitives/%s",
+ testname_prefix, pt_values[i].description);
args = g_malloc0(sizeof(*args));
args->ops = ops;
args->test_data = &pt_values[i];
@@ -1043,13 +1045,15 @@ static void add_visitor_type(const SerializeOps *ops)
}
if (ops->caps & VCAP_STRUCTURES) {
- sprintf(testname, "%s/struct", testname_prefix);
+ pstrcpy(testname, sizeof(testname), testname_prefix);
+ pstrcat(testname, sizeof(testname), "/struct");
args = g_malloc0(sizeof(*args));
args->ops = ops;
args->test_data = NULL;
g_test_add_data_func(testname, args, test_struct);
- sprintf(testname, "%s/nested_struct", testname_prefix);
+ pstrcpy(testname, sizeof(testname), testname_prefix);
+ pstrcat(testname, sizeof(testname), "/nested_struct");
args = g_malloc0(sizeof(*args));
args->ops = ops;
args->test_data = NULL;
@@ -1057,7 +1061,8 @@ static void add_visitor_type(const SerializeOps *ops)
}
if (ops->caps & VCAP_LISTS) {
- sprintf(testname, "%s/nested_struct_list", testname_prefix);
+ pstrcpy(testname, sizeof(testname), testname_prefix);
+ pstrcat(testname, sizeof(testname), "/nested_struct_list");
args = g_malloc0(sizeof(*args));
args->ops = ops;
args->test_data = NULL;
@@ -1067,8 +1072,8 @@ static void add_visitor_type(const SerializeOps *ops)
if (ops->caps & VCAP_PRIMITIVE_LISTS) {
i = 0;
while (pt_values[i].type != PTYPE_EOL) {
- sprintf(testname, "%s/primitive_list/%s", testname_prefix,
- pt_values[i].description);
+ snprintf(testname, sizeof(testname), "%s/primitive_list/%s",
+ testname_prefix, pt_values[i].description);
args = g_malloc0(sizeof(*args));
args->ops = ops;
args->test_data = &pt_values[i];
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 05/17] hw/ppc/vof: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (3 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 04/17] tests/unit/visitor: Replace deprecated sprintf() with snprintf() Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 06/17] hw/usb/hcd-ohci: " Philippe Mathieu-Daudé
` (11 subsequent siblings)
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Alexey Kardashevskiy
Replace sprintf() by safer snprintf() to avoid when using
Apple clang 17.0.0 on macOS ARM64:
../hw/ppc/vof.c:104:14: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/ppc/vof.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/vof.c b/hw/ppc/vof.c
index 873e967f1e4d..ef89b71f7336 100644
--- a/hw/ppc/vof.c
+++ b/hw/ppc/vof.c
@@ -101,7 +101,7 @@ static void prop_format(char *tval, int tlen, const void *prop, int len)
strcat(t, " ");
++t;
}
- t += sprintf(t, "%02X", *c & 0xFF);
+ t += snprintf(t, tval + tlen - t, "%02X", *c & 0xFF);
}
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 06/17] hw/usb/hcd-ohci: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (4 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 05/17] hw/ppc/vof: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf Philippe Mathieu-Daudé
` (10 subsequent siblings)
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé
Replace sprintf() by safer snprintf() to avoid when using
Apple clang 17.0.0 on macOS ARM64:
../hw/usb/hcd-ohci.c:875:14: warning: 'sprintf' is deprecated [-Wdeprecated-declarations]
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/usb/hcd-ohci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/usb/hcd-ohci.c b/hw/usb/hcd-ohci.c
index 4d38150a8458..d9fcee6c0b4b 100644
--- a/hw/usb/hcd-ohci.c
+++ b/hw/usb/hcd-ohci.c
@@ -872,7 +872,7 @@ static void ohci_td_pkt(const char *msg, const uint8_t *buf, size_t len)
break;
}
- p += sprintf(p, " %.2x", buf[i]);
+ p += snprintf(p, tmp + sizeof(tmp) - p, " %.2x", buf[i]);
}
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (5 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 06/17] hw/usb/hcd-ohci: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 16:05 ` Alex Bennée
2026-11-05 23:17 ` Alistair Francis
2026-11-05 12:51 ` [PATCH v2 08/17] hw/vfio/pci: Replace deprecated sprintf() with g_strdup_printf() Philippe Mathieu-Daudé
` (9 subsequent siblings)
16 siblings, 2 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Palmer Dabbelt, Alistair Francis, Weiwei Li,
Daniel Henrique Barboza, Liu Zhiwei, Chao Liu
Replace sprintf() by safer g_strdup_printf() to format the AIA
guest count / description, silencing -Wdeprecated-declarations
produced by Apple clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/riscv/server_platform_ref.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hw/riscv/server_platform_ref.c b/hw/riscv/server_platform_ref.c
index 5f485b1c79cb..d75bd1465a43 100644
--- a/hw/riscv/server_platform_ref.c
+++ b/hw/riscv/server_platform_ref.c
@@ -668,10 +668,8 @@ static void rvserver_ref_machine_instance_finalize(Object *obj)
static char *rvserver_ref_get_aia_guests(Object *obj, Error **errp)
{
RISCVServerRefMachineState *s = RISCV_SERVER_REF_MACHINE(obj);
- char val[32];
- sprintf(val, "%d", s->aia_guests);
- return g_strdup(val);
+ return g_strdup_printf("%d", s->aia_guests);
}
static void rvserver_ref_set_aia_guests(Object *obj, const char *val,
@@ -716,7 +714,10 @@ static void rvserver_machine_device_plug_cb(const HotplugHandler *hotplug_dev,
static void rvserver_ref_machine_class_init(ObjectClass *oc, const void *data)
{
- char str[128];
+ g_autofree char *str = g_strdup_printf("Set number of guest MMIO pages"
+ " for AIA IMSIC. Valid value should"
+ " be between 0 and %d.",
+ RVSERVER_IRQCHIP_MAX_GUESTS);
MachineClass *mc = MACHINE_CLASS(oc);
HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
static const char * const valid_cpu_types[] = {
@@ -743,8 +744,6 @@ static void rvserver_ref_machine_class_init(ObjectClass *oc, const void *data)
object_class_property_add_str(oc, "aia-guests",
rvserver_ref_get_aia_guests,
rvserver_ref_set_aia_guests);
- sprintf(str, "Set number of guest MMIO pages for AIA IMSIC. Valid value "
- "should be between 0 and %d.", RVSERVER_IRQCHIP_MAX_GUESTS);
object_class_property_set_description(oc, "aia-guests", str);
assert(!mc->get_hotplug_handler);
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf
2026-11-05 12:51 ` [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf Philippe Mathieu-Daudé
@ 2026-11-05 16:05 ` Alex Bennée
2026-11-05 23:17 ` Alistair Francis
1 sibling, 0 replies; 31+ messages in thread
From: Alex Bennée @ 2026-11-05 16:05 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Palmer Dabbelt,
Alistair Francis, Weiwei Li, Daniel Henrique Barboza, Liu Zhiwei,
Chao Liu
Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:
> Replace sprintf() by safer g_strdup_printf() to format the AIA
> guest count / description, silencing -Wdeprecated-declarations
> produced by Apple clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
<snip>
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 31+ messages in thread
* Re: [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf
2026-11-05 12:51 ` [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf Philippe Mathieu-Daudé
2026-11-05 16:05 ` Alex Bennée
@ 2026-11-05 23:17 ` Alistair Francis
1 sibling, 0 replies; 31+ messages in thread
From: Alistair Francis @ 2026-11-05 23:17 UTC (permalink / raw)
To: philmd@oss.qualcomm.com, qemu-devel@nongnu.org
Cc: daniel.barboza@oss.qualcomm.com, qemu-arm@nongnu.org,
qemu-riscv@nongnu.org, chao.liu@processmission.com,
zhiwei_liu@linux.alibaba.com, qemu-ppc@nongnu.org,
palmer@dabbelt.com, liwei1518@gmail.com
On Thu, 2026-11-05 at 13:51 +0100, Philippe Mathieu-Daudé wrote:
> Replace sprintf() by safer g_strdup_printf() to format the AIA
> guest count / description, silencing -Wdeprecated-declarations
> produced by Apple clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Alistair
> ---
> hw/riscv/server_platform_ref.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/hw/riscv/server_platform_ref.c
> b/hw/riscv/server_platform_ref.c
> index 5f485b1c79cb..d75bd1465a43 100644
> --- a/hw/riscv/server_platform_ref.c
> +++ b/hw/riscv/server_platform_ref.c
> @@ -668,10 +668,8 @@ static void
> rvserver_ref_machine_instance_finalize(Object *obj)
> static char *rvserver_ref_get_aia_guests(Object *obj, Error **errp)
> {
> RISCVServerRefMachineState *s = RISCV_SERVER_REF_MACHINE(obj);
> - char val[32];
>
> - sprintf(val, "%d", s->aia_guests);
> - return g_strdup(val);
> + return g_strdup_printf("%d", s->aia_guests);
> }
>
> static void rvserver_ref_set_aia_guests(Object *obj, const char
> *val,
> @@ -716,7 +714,10 @@ static void
> rvserver_machine_device_plug_cb(const HotplugHandler *hotplug_dev,
>
> static void rvserver_ref_machine_class_init(ObjectClass *oc, const
> void *data)
> {
> - char str[128];
> + g_autofree char *str = g_strdup_printf("Set number of guest MMIO
> pages"
> + " for AIA IMSIC. Valid
> value should"
> + " be between 0 and %d.",
> +
> RVSERVER_IRQCHIP_MAX_GUESTS);
> MachineClass *mc = MACHINE_CLASS(oc);
> HotplugHandlerClass *hc = HOTPLUG_HANDLER_CLASS(oc);
> static const char * const valid_cpu_types[] = {
> @@ -743,8 +744,6 @@ static void
> rvserver_ref_machine_class_init(ObjectClass *oc, const void *data)
> object_class_property_add_str(oc, "aia-guests",
> rvserver_ref_get_aia_guests,
> rvserver_ref_set_aia_guests);
> - sprintf(str, "Set number of guest MMIO pages for AIA IMSIC.
> Valid value "
> - "should be between 0 and %d.",
> RVSERVER_IRQCHIP_MAX_GUESTS);
> object_class_property_set_description(oc, "aia-guests", str);
>
> assert(!mc->get_hotplug_handler);
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 08/17] hw/vfio/pci: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (6 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 07/17] hw/riscv/platform-ref: Replace deprecated sprintf with g_strdup_printf Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 13:25 ` Cédric Le Goater
2026-11-05 12:51 ` [PATCH v2 09/17] hw/ppc/spapr: " Philippe Mathieu-Daudé
` (8 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Alex Williamson, Cédric Le Goater
Replace sprintf() by safer g_strdup_printf() to format the
host address, silencing -Wdeprecated-declarations produced
by Apple clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/vfio/pci.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 0da2e143b88a..eea96240b7c9 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2857,10 +2857,9 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev)
bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
{
- char tmp[36];
-
- sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain,
- addr->bus, addr->slot, addr->function);
+ g_autofree char *tmp = g_strdup_printf("%04x:%02x:%02x.%1x",
+ addr->domain, addr->bus, addr->slot,
+ addr->function);
return (strcmp(tmp, name) == 0);
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 08/17] hw/vfio/pci: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 ` [PATCH v2 08/17] hw/vfio/pci: Replace deprecated sprintf() with g_strdup_printf() Philippe Mathieu-Daudé
@ 2026-11-05 13:25 ` Cédric Le Goater
0 siblings, 0 replies; 31+ messages in thread
From: Cédric Le Goater @ 2026-11-05 13:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé, qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Alex Williamson
On 11/5/26 13:51, Philippe Mathieu-Daudé wrote:
> Replace sprintf() by safer g_strdup_printf() to format the
> host address, silencing -Wdeprecated-declarations produced
> by Apple clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
> hw/vfio/pci.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 0da2e143b88a..eea96240b7c9 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2857,10 +2857,9 @@ void vfio_pci_post_reset(VFIOPCIDevice *vdev)
>
> bool vfio_pci_host_match(PCIHostDeviceAddress *addr, const char *name)
> {
> - char tmp[36];
> -
> - sprintf(tmp, "%04x:%02x:%02x.%1x", addr->domain,
> - addr->bus, addr->slot, addr->function);
> + g_autofree char *tmp = g_strdup_printf("%04x:%02x:%02x.%1x",
> + addr->domain, addr->bus, addr->slot,
> + addr->function);
>
> return (strcmp(tmp, name) == 0);
> }
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Thanks,
C.
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 09/17] hw/ppc/spapr: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (7 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 08/17] hw/vfio/pci: Replace deprecated sprintf() with g_strdup_printf() Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 16:08 ` Alex Bennée
2026-11-05 12:51 ` [PATCH v2 10/17] hw/net/eepro100: Replace deprecated sprintf() with snprintf() Philippe Mathieu-Daudé
` (7 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Nicholas Piggin, Harsh Prateek Bora, Amit Machhiwal
Replace sprintf() by safer g_strdup_printf() to format the
node name, silencing -Wdeprecated-declarations produced
by Apple clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/ppc/spapr.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
index 54e3cc3cbe42..6f1a046a425d 100644
--- a/hw/ppc/spapr.c
+++ b/hw/ppc/spapr.c
@@ -352,14 +352,13 @@ static void add_str(GString *s, const gchar *s1)
static int spapr_dt_memory_node(SpaprMachineState *spapr, void *fdt, int nodeid,
hwaddr start, hwaddr size)
{
- char mem_name[32];
+ g_autofree char *mem_name = g_strdup_printf("memory@%" HWADDR_PRIx, start);
uint64_t mem_reg_property[2];
int off;
mem_reg_property[0] = cpu_to_be64(start);
mem_reg_property[1] = cpu_to_be64(size);
- sprintf(mem_name, "memory@%" HWADDR_PRIx, start);
off = fdt_add_subnode(fdt, 0, mem_name);
_FDT(off);
_FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 09/17] hw/ppc/spapr: Replace deprecated sprintf() with g_strdup_printf()
2026-11-05 12:51 ` [PATCH v2 09/17] hw/ppc/spapr: " Philippe Mathieu-Daudé
@ 2026-11-05 16:08 ` Alex Bennée
0 siblings, 0 replies; 31+ messages in thread
From: Alex Bennée @ 2026-11-05 16:08 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Nicholas Piggin,
Harsh Prateek Bora, Amit Machhiwal
Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:
> Replace sprintf() by safer g_strdup_printf() to format the
> node name, silencing -Wdeprecated-declarations produced
> by Apple clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
> hw/ppc/spapr.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c
> index 54e3cc3cbe42..6f1a046a425d 100644
> --- a/hw/ppc/spapr.c
> +++ b/hw/ppc/spapr.c
> @@ -352,14 +352,13 @@ static void add_str(GString *s, const gchar *s1)
> static int spapr_dt_memory_node(SpaprMachineState *spapr, void *fdt, int nodeid,
> hwaddr start, hwaddr size)
> {
> - char mem_name[32];
> + g_autofree char *mem_name = g_strdup_printf("memory@%" HWADDR_PRIx, start);
> uint64_t mem_reg_property[2];
> int off;
>
> mem_reg_property[0] = cpu_to_be64(start);
> mem_reg_property[1] = cpu_to_be64(size);
>
> - sprintf(mem_name, "memory@%" HWADDR_PRIx, start);
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> off = fdt_add_subnode(fdt, 0, mem_name);
fun fact, ppc seems to be one of the arches that mixes fdt_add_subnode
with qemu_fdt_add_subnode.
> _FDT(off);
> _FDT((fdt_setprop_string(fdt, off, "device_type", "memory")));
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 10/17] hw/net/eepro100: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (8 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 09/17] hw/ppc/spapr: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 16:12 ` Alex Bennée
2026-11-05 12:51 ` [PATCH v2 11/17] hw/net/rocker: " Philippe Mathieu-Daudé
` (6 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Stefan Weil, Jason Wang
Replace sprintf() by safer snprintf() to format debug dump
silencing -Wdeprecated-declarations produced by Apple clang
17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/net/eepro100.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
index aaa3eb60f8ab..44eff5fd3ad8 100644
--- a/hw/net/eepro100.c
+++ b/hw/net/eepro100.c
@@ -369,7 +369,7 @@ static const char *nic_dump(const uint8_t * buf, unsigned size)
size = 16;
}
while (size-- > 0) {
- p += sprintf(p, " %02x", *buf++);
+ p += snprintf(p, sizeof(dump) - (p - dump), " %02x", *buf++);
}
return dump;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 10/17] hw/net/eepro100: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 ` [PATCH v2 10/17] hw/net/eepro100: Replace deprecated sprintf() with snprintf() Philippe Mathieu-Daudé
@ 2026-11-05 16:12 ` Alex Bennée
0 siblings, 0 replies; 31+ messages in thread
From: Alex Bennée @ 2026-11-05 16:12 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Stefan Weil,
Jason Wang
Philippe Mathieu-Daudé <philmd@oss.qualcomm.com> writes:
> Replace sprintf() by safer snprintf() to format debug dump
> silencing -Wdeprecated-declarations produced by Apple clang
> 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
> hw/net/eepro100.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c
> index aaa3eb60f8ab..44eff5fd3ad8 100644
> --- a/hw/net/eepro100.c
> +++ b/hw/net/eepro100.c
> @@ -369,7 +369,7 @@ static const char *nic_dump(const uint8_t * buf, unsigned size)
> size = 16;
> }
> while (size-- > 0) {
> - p += sprintf(p, " %02x", *buf++);
> + p += snprintf(p, sizeof(dump) - (p - dump), " %02x", *buf++);
I was going to say the whole function could be re-done to avoid the
static buffer in nic_dump but that took me to TRACE and then missing() and
I realised you probably didn't sign up to modernise the eepro100
emulation ;-)
Reviewed-by: Alex Bennée <alex.bennee@linaro.org>
> }
> return dump;
> }
--
Alex Bennée
Virtualisation Tech Lead @ Linaro
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 11/17] hw/net/rocker: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (9 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 10/17] hw/net/eepro100: Replace deprecated sprintf() with snprintf() Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 12/17] hw/scsi: " Philippe Mathieu-Daudé
` (5 subsequent siblings)
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Jiri Pirko, Jason Wang
Replace sprintf() by safer snprintf() to format debug
register, silencing -Wdeprecated-declarations produced
by Apple clang 17.0.0.
Use pstrcpy() when no formatting is needed.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/net/rocker/rocker.c | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
index 910dce901b67..aaf447641c86 100644
--- a/hw/net/rocker/rocker.c
+++ b/hw/net/rocker/rocker.c
@@ -910,40 +910,40 @@ static const char *rocker_reg_name(void *opaque, hwaddr addr)
switch (index) {
case 0:
- sprintf(ring_name, "cmd");
+ pstrcpy(ring_name, sizeof(ring_name), "cmd");
break;
case 1:
- sprintf(ring_name, "event");
+ pstrcpy(ring_name, sizeof(ring_name), "event");
break;
default:
- sprintf(ring_name, "%s-%d", index % 2 ? "rx" : "tx",
- (index - 2) / 2);
+ snprintf(ring_name, sizeof(ring_name), "%s-%d",
+ index % 2 ? "rx" : "tx", (index - 2) / 2);
}
switch (offset) {
case ROCKER_DMA_DESC_ADDR_OFFSET:
- sprintf(buf, "Ring[%s] ADDR", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] ADDR", ring_name);
return buf;
case ROCKER_DMA_DESC_ADDR_OFFSET+4:
- sprintf(buf, "Ring[%s] ADDR+4", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] ADDR+4", ring_name);
return buf;
case ROCKER_DMA_DESC_SIZE_OFFSET:
- sprintf(buf, "Ring[%s] SIZE", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] SIZE", ring_name);
return buf;
case ROCKER_DMA_DESC_HEAD_OFFSET:
- sprintf(buf, "Ring[%s] HEAD", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] HEAD", ring_name);
return buf;
case ROCKER_DMA_DESC_TAIL_OFFSET:
- sprintf(buf, "Ring[%s] TAIL", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] TAIL", ring_name);
return buf;
case ROCKER_DMA_DESC_CTRL_OFFSET:
- sprintf(buf, "Ring[%s] CTRL", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] CTRL", ring_name);
return buf;
case ROCKER_DMA_DESC_CREDITS_OFFSET:
- sprintf(buf, "Ring[%s] CREDITS", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] CREDITS", ring_name);
return buf;
default:
- sprintf(buf, "Ring[%s] ???", ring_name);
+ snprintf(buf, sizeof(buf), "Ring[%s] ???", ring_name);
return buf;
}
} else {
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 12/17] hw/scsi: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (10 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 11/17] hw/net/rocker: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 13/17] target/xtensa: " Philippe Mathieu-Daudé
` (4 subsequent siblings)
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Paolo Bonzini, Fam Zheng
Replace sprintf() by safer snprintf() to format command
trace, silencing -Wdeprecated-declarations produced by
Apple clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
hw/scsi/scsi-generic.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/scsi/scsi-generic.c b/hw/scsi/scsi-generic.c
index e48fcb926f1d..61d9de30dfa0 100644
--- a/hw/scsi/scsi-generic.c
+++ b/hw/scsi/scsi-generic.c
@@ -863,7 +863,7 @@ static void scsi_generic_command_dump(uint8_t *cmd, int len)
line_buffer = g_malloc(len * 5 + 1);
for (i = 0, p = line_buffer; i < len; i++) {
- p += sprintf(p, " 0x%02x", cmd[i]);
+ p += snprintf(p, (len - i) * 5 + 1, " 0x%02x", cmd[i]);
}
trace_scsi_generic_send_command(line_buffer);
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 13/17] target/xtensa: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (11 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 12/17] hw/scsi: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-06 2:25 ` Max Filippov
2026-11-05 12:51 ` [PATCH v2 14/17] target/m68k: " Philippe Mathieu-Daudé
` (3 subsequent siblings)
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Max Filippov
Replace sprintf() by safer snprintf() to format ISA error
message, silencing -Wdeprecated-declarations produced by
Apple clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
target/xtensa/xtensa-isa.c | 50 +++++++++++++++++++++++---------------
1 file changed, 31 insertions(+), 19 deletions(-)
diff --git a/target/xtensa/xtensa-isa.c b/target/xtensa/xtensa-isa.c
index c564af340fa9..f589a7cffe01 100644
--- a/target/xtensa/xtensa-isa.c
+++ b/target/xtensa/xtensa-isa.c
@@ -519,7 +519,8 @@ xtensa_format xtensa_format_lookup(xtensa_isa isa, const char *fmtname)
}
xtisa_errno = xtensa_isa_bad_format;
- sprintf(xtisa_error_msg, "format \"%s\" not recognized", fmtname);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "format \"%s\" not recognized", fmtname);
return XTENSA_UNDEFINED;
}
@@ -646,7 +647,8 @@ xtensa_opcode xtensa_opcode_lookup(xtensa_isa isa, const char *opname)
if (!result) {
xtisa_errno = xtensa_isa_bad_opcode;
- sprintf(xtisa_error_msg, "opcode \"%s\" not recognized", opname);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "opcode \"%s\" not recognized", opname);
return XTENSA_UNDEFINED;
}
@@ -692,7 +694,7 @@ int xtensa_opcode_encode(xtensa_isa isa, xtensa_format fmt, int slot,
encode_fn = intisa->opcodes[opc].encode_fns[slot_id];
if (!encode_fn) {
xtisa_errno = xtensa_isa_wrong_slot;
- sprintf(xtisa_error_msg,
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
"opcode \"%s\" is not allowed in slot %d of format \"%s\"",
intisa->opcodes[opc].name, slot, intisa->formats[fmt].name);
return -1;
@@ -809,7 +811,8 @@ xtensa_funcUnit_use *xtensa_opcode_funcUnit_use(xtensa_isa isa,
CHECK_OPCODE(intisa, opc, NULL);
if (u < 0 || u >= intisa->opcodes[opc].num_funcUnit_uses) {
xtisa_errno = xtensa_isa_bad_funcUnit;
- sprintf(xtisa_error_msg, "invalid functional unit use number (%d); "
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "invalid functional unit use number (%d); "
"opcode \"%s\" has %d", u, intisa->opcodes[opc].name,
intisa->opcodes[opc].num_funcUnit_uses);
return NULL;
@@ -825,7 +828,8 @@ xtensa_funcUnit_use *xtensa_opcode_funcUnit_use(xtensa_isa isa,
do { \
if ((OPND) < 0 || (OPND) >= (ICLASS)->num_operands) { \
xtisa_errno = xtensa_isa_bad_operand; \
- sprintf(xtisa_error_msg, "invalid operand number (%d); " \
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg), \
+ "invalid operand number (%d); " \
"opcode \"%s\" has %d operands", (OPND), \
(INTISA)->opcodes[(OPC)].name, (ICLASS)->num_operands); \
return ERRVAL; \
@@ -938,7 +942,7 @@ int xtensa_operand_get_field(xtensa_isa isa, xtensa_opcode opc, int opnd,
get_fn = intisa->slots[slot_id].get_field_fns[intop->field_id];
if (!get_fn) {
xtisa_errno = xtensa_isa_wrong_slot;
- sprintf(xtisa_error_msg,
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
"operand \"%s\" does not exist in slot %d of format \"%s\"",
intop->name, slot, intisa->formats[fmt].name);
return -1;
@@ -974,7 +978,7 @@ int xtensa_operand_set_field(xtensa_isa isa, xtensa_opcode opc, int opnd,
set_fn = intisa->slots[slot_id].set_field_fns[intop->field_id];
if (!set_fn) {
xtisa_errno = xtensa_isa_wrong_slot;
- sprintf(xtisa_error_msg,
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
"operand \"%s\" does not exist in slot %d of format \"%s\"",
intop->name, slot, intisa->formats[fmt].name);
return -1;
@@ -1050,7 +1054,8 @@ int xtensa_operand_encode(xtensa_isa isa, xtensa_opcode opc, int opnd,
(test_val = *valp, (*intop->decode)(&test_val)) ||
test_val != orig_val) {
xtisa_errno = xtensa_isa_bad_value;
- sprintf(xtisa_error_msg, "cannot encode operand value 0x%08x", *valp);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "cannot encode operand value 0x%08x", *valp);
return -1;
}
@@ -1076,7 +1081,8 @@ int xtensa_operand_decode(xtensa_isa isa, xtensa_opcode opc, int opnd,
if ((*intop->decode)(valp)) {
xtisa_errno = xtensa_isa_bad_value;
- sprintf(xtisa_error_msg, "cannot decode operand value 0x%08x", *valp);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "cannot decode operand value 0x%08x", *valp);
return -1;
}
return 0;
@@ -1186,7 +1192,7 @@ int xtensa_operand_do_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd,
if ((*intop->do_reloc)(valp, pc)) {
xtisa_errno = xtensa_isa_bad_value;
- sprintf(xtisa_error_msg,
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
"do_reloc failed for value 0x%08x at PC 0x%08x", *valp, pc);
return -1;
}
@@ -1218,7 +1224,7 @@ int xtensa_operand_undo_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd,
if ((*intop->undo_reloc)(valp, pc)) {
xtisa_errno = xtensa_isa_bad_value;
- sprintf(xtisa_error_msg,
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
"undo_reloc failed for value 0x%08x at PC 0x%08x", *valp, pc);
return -1;
}
@@ -1234,7 +1240,8 @@ int xtensa_operand_undo_reloc(xtensa_isa isa, xtensa_opcode opc, int opnd,
do { \
if ((STOP) < 0 || (STOP) >= (ICLASS)->num_stateOperands) { \
xtisa_errno = xtensa_isa_bad_operand; \
- sprintf(xtisa_error_msg, "invalid state operand number (%d); " \
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg), \
+ "invalid state operand number (%d); " \
"opcode \"%s\" has %d state operands", (STOP), \
(INTISA)->opcodes[(OPC)].name, \
(ICLASS)->num_stateOperands); \
@@ -1279,7 +1286,7 @@ char xtensa_stateOperand_inout(xtensa_isa isa, xtensa_opcode opc, int stOp)
do { \
if ((IFOP) < 0 || (IFOP) >= (ICLASS)->num_interfaceOperands) { \
xtisa_errno = xtensa_isa_bad_operand; \
- sprintf(xtisa_error_msg, \
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg), \
"invalid interface operand number (%d); " \
"opcode \"%s\" has %d interface operands", (IFOP), \
(INTISA)->opcodes[(OPC)].name, \
@@ -1337,7 +1344,8 @@ xtensa_regfile xtensa_regfile_lookup(xtensa_isa isa, const char *name)
}
xtisa_errno = xtensa_isa_bad_regfile;
- sprintf(xtisa_error_msg, "regfile \"%s\" not recognized", name);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "regfile \"%s\" not recognized", name);
return XTENSA_UNDEFINED;
}
@@ -1369,7 +1377,8 @@ xtensa_regfile xtensa_regfile_lookup_shortname(xtensa_isa isa,
}
xtisa_errno = xtensa_isa_bad_regfile;
- sprintf(xtisa_error_msg, "regfile shortname \"%s\" not recognized",
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "regfile shortname \"%s\" not recognized",
shortname);
return XTENSA_UNDEFINED;
}
@@ -1453,7 +1462,8 @@ xtensa_state xtensa_state_lookup(xtensa_isa isa, const char *name)
if (!result) {
xtisa_errno = xtensa_isa_bad_state;
- sprintf(xtisa_error_msg, "state \"%s\" not recognized", name);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "state \"%s\" not recognized", name);
return XTENSA_UNDEFINED;
}
@@ -1555,7 +1565,8 @@ xtensa_sysreg xtensa_sysreg_lookup_name(xtensa_isa isa, const char *name)
if (!result) {
xtisa_errno = xtensa_isa_bad_sysreg;
- sprintf(xtisa_error_msg, "sysreg \"%s\" not recognized", name);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "sysreg \"%s\" not recognized", name);
return XTENSA_UNDEFINED;
}
@@ -1626,7 +1637,8 @@ xtensa_interface xtensa_interface_lookup(xtensa_isa isa, const char *ifname)
if (!result) {
xtisa_errno = xtensa_isa_bad_interface;
- sprintf(xtisa_error_msg, "interface \"%s\" not recognized", ifname);
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
+ "interface \"%s\" not recognized", ifname);
return XTENSA_UNDEFINED;
}
@@ -1716,7 +1728,7 @@ xtensa_funcUnit xtensa_funcUnit_lookup(xtensa_isa isa, const char *fname)
if (!result) {
xtisa_errno = xtensa_isa_bad_funcUnit;
- sprintf(xtisa_error_msg,
+ snprintf(xtisa_error_msg, sizeof(xtisa_error_msg),
"functional unit \"%s\" not recognized", fname);
return XTENSA_UNDEFINED;
}
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 13/17] target/xtensa: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 ` [PATCH v2 13/17] target/xtensa: " Philippe Mathieu-Daudé
@ 2026-11-06 2:25 ` Max Filippov
0 siblings, 0 replies; 31+ messages in thread
From: Max Filippov @ 2026-11-06 2:25 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc
On Thu, Nov 5, 2026 at 4:54 AM Philippe Mathieu-Daudé
<philmd@oss.qualcomm.com> wrote:
>
> Replace sprintf() by safer snprintf() to format ISA error
> message, silencing -Wdeprecated-declarations produced by
> Apple clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
> target/xtensa/xtensa-isa.c | 50 +++++++++++++++++++++++---------------
> 1 file changed, 31 insertions(+), 19 deletions(-)
Reviewed-by: Max Filippov <jcmvbkbc@gmail.com>
--
Thanks.
-- Max
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 14/17] target/m68k: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (12 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 13/17] target/xtensa: " Philippe Mathieu-Daudé
@ 2026-11-05 12:51 ` Philippe Mathieu-Daudé
2026-11-05 12:52 ` [PATCH v2 15/17] target/rx: " Philippe Mathieu-Daudé
` (2 subsequent siblings)
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:51 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Laurent Vivier
Replace sprintf() by safer snprintf() to format register
name, silencing -Wdeprecated-declarations produced by Apple
clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
target/m68k/translate.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/target/m68k/translate.c b/target/m68k/translate.c
index 138c89d3e531..f955aae649d3 100644
--- a/target/m68k/translate.c
+++ b/target/m68k/translate.c
@@ -77,17 +77,17 @@ void m68k_tcg_init(void)
p = cpu_reg_names;
for (i = 0; i < 8; i++) {
- sprintf(p, "D%d", i);
+ snprintf(p, 3, "D%d", i);
cpu_dregs[i] = tcg_global_mem_new(tcg_env,
offsetof(CPUM68KState, dregs[i]), p);
p += 3;
- sprintf(p, "A%d", i);
+ snprintf(p, 3, "A%d", i);
cpu_aregs[i] = tcg_global_mem_new(tcg_env,
offsetof(CPUM68KState, aregs[i]), p);
p += 3;
}
for (i = 0; i < 4; i++) {
- sprintf(p, "ACC%d", i);
+ snprintf(p, 5, "ACC%d", i);
cpu_macc[i] = tcg_global_mem_new_i64(tcg_env,
offsetof(CPUM68KState, macc[i]), p);
p += 5;
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 15/17] target/rx: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (13 preceding siblings ...)
2026-11-05 12:51 ` [PATCH v2 14/17] target/m68k: " Philippe Mathieu-Daudé
@ 2026-11-05 12:52 ` Philippe Mathieu-Daudé
2026-11-06 8:37 ` yoshinori.sato
2026-11-05 12:52 ` [PATCH v2 16/17] libdecnumber: " Philippe Mathieu-Daudé
2026-11-05 12:52 ` [PATCH v2 17/17] qga/vss-win32: Replace deprecated sprintf() by StrCatBuffA() Philippe Mathieu-Daudé
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:52 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Yoshinori Sato
Replace sprintf() by safer snprintf() to format dissassembly
index, silencing -Wdeprecated-declarations produced by Apple
clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
target/rx/disas.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/target/rx/disas.c b/target/rx/disas.c
index 0eb2ee6f4507..2a67ecfd2fa3 100644
--- a/target/rx/disas.c
+++ b/target/rx/disas.c
@@ -167,7 +167,7 @@ static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)
g_assert_not_reached();
}
- sprintf(out, "%u", dsp << (mi < 3 ? mi : 4 - mi));
+ snprintf(out, 8, "%u", dsp << (mi < 3 ? mi : 4 - mi));
}
static void prt_ldmi(DisasContext *ctx, const char *insn,
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 15/17] target/rx: Replace deprecated sprintf() with snprintf()
2026-11-05 12:52 ` [PATCH v2 15/17] target/rx: " Philippe Mathieu-Daudé
@ 2026-11-06 8:37 ` yoshinori.sato
0 siblings, 0 replies; 31+ messages in thread
From: yoshinori.sato @ 2026-11-06 8:37 UTC (permalink / raw)
To: Philippe Mathieu-Daudé; +Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc
On Thu, 05 Nov 2026 21:52:00 +0900,
Philippe Mathieu-Daudé wrote:
>
> Replace sprintf() by safer snprintf() to format dissassembly
> index, silencing -Wdeprecated-declarations produced by Apple
> clang 17.0.0.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
> target/rx/disas.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/target/rx/disas.c b/target/rx/disas.c
> index 0eb2ee6f4507..2a67ecfd2fa3 100644
> --- a/target/rx/disas.c
> +++ b/target/rx/disas.c
> @@ -167,7 +167,7 @@ static void rx_index_addr(DisasContext *ctx, char out[8], int ld, int mi)
> g_assert_not_reached();
> }
>
> - sprintf(out, "%u", dsp << (mi < 3 ? mi : 4 - mi));
> + snprintf(out, 8, "%u", dsp << (mi < 3 ? mi : 4 - mi));
> }
>
> static void prt_ldmi(DisasContext *ctx, const char *insn,
> --
> 2.55.0
>
Reviewed-by: Yoshinori Sato <yoshinori.sato@nifty.com>
--
Yosinori Sato
^ permalink raw reply [flat|nested] 31+ messages in thread
* [PATCH v2 16/17] libdecnumber: Replace deprecated sprintf() with snprintf()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (14 preceding siblings ...)
2026-11-05 12:52 ` [PATCH v2 15/17] target/rx: " Philippe Mathieu-Daudé
@ 2026-11-05 12:52 ` Philippe Mathieu-Daudé
2026-11-05 12:52 ` [PATCH v2 17/17] qga/vss-win32: Replace deprecated sprintf() by StrCatBuffA() Philippe Mathieu-Daudé
16 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:52 UTC (permalink / raw)
To: qemu-devel; +Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé
Replace sprintf() by safer snprintf() to format hexadecimal
debug, silencing -Wdeprecated-declarations produced by Apple
clang 17.0.0.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
libdecnumber/dpd/decimal128.c | 4 ++--
libdecnumber/dpd/decimal32.c | 4 ++--
libdecnumber/dpd/decimal64.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/libdecnumber/dpd/decimal128.c b/libdecnumber/dpd/decimal128.c
index 1064fb25e01d..e4ff39c90bd2 100644
--- a/libdecnumber/dpd/decimal128.c
+++ b/libdecnumber/dpd/decimal128.c
@@ -543,7 +543,7 @@ void decimal128Show(const decimal128 *d128) {
if (DECLITEND) {
for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
- sprintf(&buf[j], "%02x", d128->bytes[15-i]);
+ snprintf(&buf[j], sizeof(buf) - j, "%02x", d128->bytes[15-i]);
}
printf(" D128> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
d128->bytes[15]>>7, (d128->bytes[15]>>2)&0x1f,
@@ -552,7 +552,7 @@ void decimal128Show(const decimal128 *d128) {
}
else {
for (i=0; i<DECIMAL128_Bytes; i++, j+=2) {
- sprintf(&buf[j], "%02x", d128->bytes[i]);
+ snprintf(&buf[j], sizeof(buf) - j, "%02x", d128->bytes[i]);
}
printf(" D128> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
decimal128Sign(d128), decimal128Comb(d128),
diff --git a/libdecnumber/dpd/decimal32.c b/libdecnumber/dpd/decimal32.c
index 34ff0fe95991..bc16361c82de 100644
--- a/libdecnumber/dpd/decimal32.c
+++ b/libdecnumber/dpd/decimal32.c
@@ -470,7 +470,7 @@ void decimal32Show(const decimal32 *d32) {
if (DECLITEND) {
for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
- sprintf(&buf[j], "%02x", d32->bytes[3-i]);
+ snprintf(&buf[j], sizeof(buf) - j, "%02x", d32->bytes[3-i]);
}
printf(" D32> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
d32->bytes[3]>>7, (d32->bytes[3]>>2)&0x1f,
@@ -478,7 +478,7 @@ void decimal32Show(const decimal32 *d32) {
}
else {
for (i=0; i<DECIMAL32_Bytes; i++, j+=2) {
- sprintf(&buf[j], "%02x", d32->bytes[i]);
+ snprintf(&buf[j], sizeof(buf) - j, "%02x", d32->bytes[i]);
}
printf(" D32> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
decimal32Sign(d32), decimal32Comb(d32), decimal32ExpCon(d32));
diff --git a/libdecnumber/dpd/decimal64.c b/libdecnumber/dpd/decimal64.c
index 11e0674fa7c8..18438c1de1c3 100644
--- a/libdecnumber/dpd/decimal64.c
+++ b/libdecnumber/dpd/decimal64.c
@@ -530,7 +530,7 @@ void decimal64Show(const decimal64 *d64) {
if (DECLITEND) {
for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
- sprintf(&buf[j], "%02x", d64->bytes[7-i]);
+ snprintf(&buf[j], sizeof(buf) - j, "%02x", d64->bytes[7-i]);
}
printf(" D64> %s [S:%d Cb:%02x Ec:%02x] LittleEndian\n", buf,
d64->bytes[7]>>7, (d64->bytes[7]>>2)&0x1f,
@@ -538,7 +538,7 @@ void decimal64Show(const decimal64 *d64) {
}
else { /* big-endian */
for (i=0; i<DECIMAL64_Bytes; i++, j+=2) {
- sprintf(&buf[j], "%02x", d64->bytes[i]);
+ snprintf(&buf[j], sizeof(buf) - j, "%02x", d64->bytes[i]);
}
printf(" D64> %s [S:%d Cb:%02x Ec:%02x] BigEndian\n", buf,
decimal64Sign(d64), decimal64Comb(d64), decimal64ExpCon(d64));
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* [PATCH v2 17/17] qga/vss-win32: Replace deprecated sprintf() by StrCatBuffA()
2026-11-05 12:51 [PATCH v2 00/17] buildsys: Replace some deprecated sprintf() Philippe Mathieu-Daudé
` (15 preceding siblings ...)
2026-11-05 12:52 ` [PATCH v2 16/17] libdecnumber: " Philippe Mathieu-Daudé
@ 2026-11-05 12:52 ` Philippe Mathieu-Daudé
2026-11-05 15:29 ` Kostiantyn Kostiuk
16 siblings, 1 reply; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 12:52 UTC (permalink / raw)
To: qemu-devel
Cc: qemu-riscv, qemu-arm, qemu-ppc, Philippe Mathieu-Daudé,
Kostiantyn Kostiuk, Michael Roth
Formatting is not necessary, replace the deprecated
sprintf() by StrCpyNA() and StrCatBuffA() calls.
Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
qga/vss-win32/install.cpp | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
index df00588c923a..1a3d5cbf75d5 100644
--- a/qga/vss-win32/install.cpp
+++ b/qga/vss-win32/install.cpp
@@ -562,7 +562,8 @@ STDAPI DllRegisterServer(void)
/* Add this module to registry */
- sprintf(key, "CLSID\\%s", g_szClsid);
+ StrCpyNA(key, "CLSID\\", sizeof(key));
+ StrCatBuffA(key, g_szClsid, sizeof(key));
if (!CreateRegistryKey(key, NULL, g_szClsid)) {
goto out;
}
@@ -572,7 +573,9 @@ STDAPI DllRegisterServer(void)
goto out;
}
- sprintf(key, "CLSID\\%s\\InprocServer32", g_szClsid);
+ StrCpyNA(key, "CLSID\\", sizeof(key));
+ StrCatBuffA(key, g_szClsid, sizeof(key));
+ StrCatBuffA(key, "\\InprocServer32", sizeof(key));
if (!CreateRegistryKey(key, NULL, dllPath)) {
goto out;
}
@@ -581,7 +584,9 @@ STDAPI DllRegisterServer(void)
goto out;
}
- sprintf(key, "CLSID\\%s\\ProgID", g_szClsid);
+ StrCpyNA(key, "CLSID\\", sizeof(key));
+ StrCatBuffA(key, g_szClsid, sizeof(key));
+ StrCatBuffA(key, "\\ProgID", sizeof(key));
if (!CreateRegistryKey(key, NULL, g_szProgid)) {
goto out;
}
@@ -590,7 +595,8 @@ STDAPI DllRegisterServer(void)
goto out;
}
- sprintf(key, "%s\\CLSID", g_szProgid);
+ StrCpyNA(key, g_szProgid, sizeof(key));
+ StrCatBuffA(key, "\\CLSID", sizeof(key));
if (!CreateRegistryKey(key, NULL, g_szClsid)) {
goto out;
}
@@ -651,7 +657,8 @@ STDAPI DllUnregisterServer(void)
errmsg(hr, "CoCreateInstance(VSSCoordinator) failed");
}
- sprintf(key, "CLSID\\%s", g_szClsid);
+ StrCpyNA(key, "CLSID\\", sizeof(key));
+ StrCatBuffA(key, g_szClsid, sizeof(key));
SHDeleteKey(HKEY_CLASSES_ROOT, key);
SHDeleteKey(HKEY_CLASSES_ROOT, g_szProgid);
--
2.55.0
^ permalink raw reply related [flat|nested] 31+ messages in thread* Re: [PATCH v2 17/17] qga/vss-win32: Replace deprecated sprintf() by StrCatBuffA()
2026-11-05 12:52 ` [PATCH v2 17/17] qga/vss-win32: Replace deprecated sprintf() by StrCatBuffA() Philippe Mathieu-Daudé
@ 2026-11-05 15:29 ` Kostiantyn Kostiuk
2026-11-05 19:59 ` Philippe Mathieu-Daudé
0 siblings, 1 reply; 31+ messages in thread
From: Kostiantyn Kostiuk @ 2026-11-05 15:29 UTC (permalink / raw)
To: Philippe Mathieu-Daudé
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Michael Roth
[-- Attachment #1: Type: text/plain, Size: 2551 bytes --]
On Thu, Nov 5, 2026 at 2:54 PM Philippe Mathieu-Daudé <
philmd@oss.qualcomm.com> wrote:
> Formatting is not necessary, replace the deprecated
> sprintf() by StrCpyNA() and StrCatBuffA() calls.
>
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
> qga/vss-win32/install.cpp | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
> index df00588c923a..1a3d5cbf75d5 100644
> --- a/qga/vss-win32/install.cpp
> +++ b/qga/vss-win32/install.cpp
> @@ -562,7 +562,8 @@ STDAPI DllRegisterServer(void)
>
> /* Add this module to registry */
>
> - sprintf(key, "CLSID\\%s", g_szClsid);
> + StrCpyNA(key, "CLSID\\", sizeof(key));
> + StrCatBuffA(key, g_szClsid, sizeof(key));
>
MSFT does not recommend to use StrCatBuffA due to security warning.
What about using StringCchCatA instead of snprintf, even in this case?
> if (!CreateRegistryKey(key, NULL, g_szClsid)) {
> goto out;
> }
> @@ -572,7 +573,9 @@ STDAPI DllRegisterServer(void)
> goto out;
> }
>
> - sprintf(key, "CLSID\\%s\\InprocServer32", g_szClsid);
> + StrCpyNA(key, "CLSID\\", sizeof(key));
> + StrCatBuffA(key, g_szClsid, sizeof(key));
> + StrCatBuffA(key, "\\InprocServer32", sizeof(key));
> if (!CreateRegistryKey(key, NULL, dllPath)) {
> goto out;
> }
> @@ -581,7 +584,9 @@ STDAPI DllRegisterServer(void)
> goto out;
> }
>
> - sprintf(key, "CLSID\\%s\\ProgID", g_szClsid);
> + StrCpyNA(key, "CLSID\\", sizeof(key));
> + StrCatBuffA(key, g_szClsid, sizeof(key));
> + StrCatBuffA(key, "\\ProgID", sizeof(key));
> if (!CreateRegistryKey(key, NULL, g_szProgid)) {
> goto out;
> }
> @@ -590,7 +595,8 @@ STDAPI DllRegisterServer(void)
> goto out;
> }
>
> - sprintf(key, "%s\\CLSID", g_szProgid);
> + StrCpyNA(key, g_szProgid, sizeof(key));
> + StrCatBuffA(key, "\\CLSID", sizeof(key));
> if (!CreateRegistryKey(key, NULL, g_szClsid)) {
> goto out;
> }
> @@ -651,7 +657,8 @@ STDAPI DllUnregisterServer(void)
> errmsg(hr, "CoCreateInstance(VSSCoordinator) failed");
> }
>
> - sprintf(key, "CLSID\\%s", g_szClsid);
> + StrCpyNA(key, "CLSID\\", sizeof(key));
> + StrCatBuffA(key, g_szClsid, sizeof(key));
> SHDeleteKey(HKEY_CLASSES_ROOT, key);
> SHDeleteKey(HKEY_CLASSES_ROOT, g_szProgid);
>
> --
> 2.55.0
>
>
[-- Attachment #2: Type: text/html, Size: 3513 bytes --]
^ permalink raw reply [flat|nested] 31+ messages in thread* Re: [PATCH v2 17/17] qga/vss-win32: Replace deprecated sprintf() by StrCatBuffA()
2026-11-05 15:29 ` Kostiantyn Kostiuk
@ 2026-11-05 19:59 ` Philippe Mathieu-Daudé
0 siblings, 0 replies; 31+ messages in thread
From: Philippe Mathieu-Daudé @ 2026-11-05 19:59 UTC (permalink / raw)
To: Kostiantyn Kostiuk
Cc: qemu-devel, qemu-riscv, qemu-arm, qemu-ppc, Michael Roth
On 5/11/26 16:29, Kostiantyn Kostiuk wrote:
> On Thu, Nov 5, 2026 at 2:54 PM Philippe Mathieu-Daudé <
> philmd@oss.qualcomm.com> wrote:
>
>> Formatting is not necessary, replace the deprecated
>> sprintf() by StrCpyNA() and StrCatBuffA() calls.
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
>> ---
>> qga/vss-win32/install.cpp | 17 ++++++++++++-----
>> 1 file changed, 12 insertions(+), 5 deletions(-)
>>
>> diff --git a/qga/vss-win32/install.cpp b/qga/vss-win32/install.cpp
>> index df00588c923a..1a3d5cbf75d5 100644
>> --- a/qga/vss-win32/install.cpp
>> +++ b/qga/vss-win32/install.cpp
>> @@ -562,7 +562,8 @@ STDAPI DllRegisterServer(void)
>>
>> /* Add this module to registry */
>>
>> - sprintf(key, "CLSID\\%s", g_szClsid);
>> + StrCpyNA(key, "CLSID\\", sizeof(key));
>> + StrCatBuffA(key, g_szClsid, sizeof(key));
>>
>
> MSFT does not recommend to use StrCatBuffA due to security warning.
> What about using StringCchCatA instead of snprintf, even in this case?
Good point. I went back with StringCchPrintfA() for less code churn.
^ permalink raw reply [flat|nested] 31+ messages in thread