All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>
To: qemu-devel@nongnu.org
Cc: qemu-riscv@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org,
	"Philippe Mathieu-Daudé" <philmd@oss.qualcomm.com>,
	"Tyrone Ting" <kfting@nuvoton.com>,
	"Hao Wu" <wuhaotsh@google.com>, "Fabiano Rosas" <farosas@suse.de>,
	"Laurent Vivier" <lvivier@redhat.com>,
	"Paolo Bonzini" <pbonzini@redhat.com>
Subject: [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf()
Date: Thu,  5 Nov 2026 13:51:47 +0100	[thread overview]
Message-ID: <20261105125203.40320-3-philmd@oss.qualcomm.com> (raw)
In-Reply-To: <20261105125203.40320-1-philmd@oss.qualcomm.com>

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



  parent reply	other threads:[~2026-11-05 12:53 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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-06 16:02   ` Peter Maydell
2026-11-05 12:51 ` Philippe Mathieu-Daudé [this message]
2026-11-05 16:02   ` [PATCH v2 02/17] tests/qtest/npcm7xx: Replace deprecated sprintf() with g_strdup_printf() Alex Bennée
2026-11-06 18:52     ` Hao Wu
2026-11-05 12:51 ` [PATCH v2 03/17] tests/unit/qobject: " 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é
2026-11-05 12:51 ` [PATCH v2 05/17] hw/ppc/vof: " Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 06/17] hw/usb/hcd-ohci: " 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é
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é
2026-11-05 13:25   ` Cédric Le Goater
2026-11-05 12:51 ` [PATCH v2 09/17] hw/ppc/spapr: " 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é
2026-11-05 16:12   ` Alex Bennée
2026-11-05 12:51 ` [PATCH v2 11/17] hw/net/rocker: " Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 12/17] hw/scsi: " Philippe Mathieu-Daudé
2026-11-05 12:51 ` [PATCH v2 13/17] target/xtensa: " Philippe Mathieu-Daudé
2026-11-06  2:25   ` Max Filippov
2026-11-05 12:51 ` [PATCH v2 14/17] target/m68k: " Philippe Mathieu-Daudé
2026-11-05 12:52 ` [PATCH v2 15/17] target/rx: " 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é
2026-11-05 15:29   ` Kostiantyn Kostiuk
2026-11-05 19:59     ` Philippe Mathieu-Daudé

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261105125203.40320-3-philmd@oss.qualcomm.com \
    --to=philmd@oss.qualcomm.com \
    --cc=farosas@suse.de \
    --cc=kfting@nuvoton.com \
    --cc=lvivier@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-ppc@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=wuhaotsh@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.