From nobody Tue Apr 7 06:00:31 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1773657788; cv=none; d=zohomail.com; s=zohoarc; b=KV7wX1zsueNz0s94kFw+oSF9a8oJgncA969lpYjszpaRJO4LcgdTa/fF28h2HY5baLv0dkT+mwk3ElzxbXVsyZF+A7nn4e6AWHyjXgPcsGTAhW+a0d9TmpF9oaJ0hsmeQ228Qgb5ii0NwKtX1SDFgWAOlBxOf5tbppznaIQiPmA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773657788; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=Q+xitAlK1s/NviM9Oq68epH9BMAZRVhmQhy3D1hM4gI=; b=EUPEhVlWGaME/RmcRPnEu+Qpy3dsAl658ejrFEFO4XW2uTGCIqv9PrZMmsIkFqOzA3hGHeN0+A/cRffBD/dV8lrP/QyIW/EGv4tfF4p2YtXYd61HOyk3wZHMUFl02ixojaDemA6KjpMAvjDKfQ5EC3Qp6zWM/w9GJHom+9n05bQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773657788631258.7006288063509; Mon, 16 Mar 2026 03:43:08 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w25PR-0001rG-Ih; Mon, 16 Mar 2026 06:42:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w25PP-0001ie-SV for qemu-devel@nongnu.org; Mon, 16 Mar 2026 06:42:51 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w25PO-0003gi-3k for qemu-devel@nongnu.org; Mon, 16 Mar 2026 06:42:51 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-485445e80bdso38566435e9.0 for ; Mon, 16 Mar 2026 03:42:49 -0700 (PDT) Received: from lanath.. ([81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48557a74266sm85519135e9.17.2026.03.16.03.42.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 03:42:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773657768; x=1774262568; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=Q+xitAlK1s/NviM9Oq68epH9BMAZRVhmQhy3D1hM4gI=; b=llifjUQ8LEPd8i0rNZ6OcffcCVSnwQCMOfdr7kwsGc9e/6y0wTV8Wvul3N+1johGoo CCzsEPl/BbZF6lPYP+wn30FAVlR7/WSCLZntOC4uUk0ao5e7PQYQdkP+HkVmnSKleK2K 0zeX46Q+EAFFLPSc32FKxjyyeFWfZOlNItYJq8oDCvYN391qmvw4J69Of5s3+n7LR+d2 Cs7n2tRS0cCKOva2teJSN1MkCOIUoekWBeFL+1JPrkgvBg//p37brDfz94yY0u+QPwOe vYU8DykITpsfDld9sUVj9H+GU7f34vxJnFQMfOJcKGYhGp7I9YCcs5JHphiTJBJdY5ON itAw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773657768; x=1774262568; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=Q+xitAlK1s/NviM9Oq68epH9BMAZRVhmQhy3D1hM4gI=; b=bBnuso3HKDBPZl1FPQOj7GnzpPyCk9khtbKERUo5Z8l9Of6G+POjklairaWJhcHnqg egJGTXM2GSLnKQ4W2EoHp/4rLG+TDG5jA5rv6a8Dp0e8nMgHLXo36zeyENcPnXCvs6I4 TglDuYSNAMFECogXvbNw3xg8+oFHuiWG61VgRh2oA7VBoHxQBGn5LLLwIZj15FIF2lOm 0z70j+QCUDJnUqu0jNPCCeARzRBorUvMYJPRlzholbntlWd2CaYf+iQbTWAKdD6aO9HR S1h6UVIy0ZiJo/lmf9aWO6TSHyZz8TUzFFlrpNB/GU5I+dX5fvzCORa6cyCahZP7eVMC uUZQ== X-Gm-Message-State: AOJu0Yy7djJvB32nskPNB/5uKzL1m/O/3Hs+cmQxPl+zxC0r/+HDjJTx MTpa3ZgrxNROTOosiKgCdxoN3QomisCPkrk8b9loKc5ISdaTOuU/aRcX4Up9+hooX9Vju7ts/mV ooDWo X-Gm-Gg: ATEYQzzETdAd+JYj7acJYvbmzpw4FU6NSowccLdz60WX30gfDXH8qp5B4+u4DPok8B6 F6nTUtsJTYMPkv6Wp7Tsf9QrzkCocfMTPVNIHyPv/np5ASUGME69fYwZCqmUg24RWXKuc1cqEzS +6wMm/WG2TWJVQOqWL/Uau5FglQ6dgbiA14+S7gxCuYJIXqs0hVZ65lbKHsTqDVxZN8IfgN+Fj5 uO3ARjaieuiEGFHUn7jwMH0UnFiKuGMmq9s3/cxAt1bpqStwZCUNjvcUsut32bHUa84tvwyWkFn +408GOB0hIS1S5ud+XEEH78ag3C4/ksBMFWDYegwgckrH+Vu1B9xRmYlPbvmsMLSE/FjVDgVvzx mUWzYUqiQ4TEk24DKSeWloE3D4ul9CJac17diX3ugLuy82A6DmbJJt3DkJwH/mkLXXwPe/9weKS oPHRmMl8m3+GFzO3nl0MPGiMiT+SLbDkrvELGcGL4rcMYul83V18Axn7Oa7+OuzRDnvKwpm4in/ jfwSp715sA= X-Received: by 2002:a05:600c:1d0e:b0:47e:e076:c7a5 with SMTP id 5b1f17b1804b1-485566ea474mr226129845e9.11.1773657768176; Mon, 16 Mar 2026 03:42:48 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 14/17] tests/qtest/ast2700-sgpio-test: Use g_strdup_printf() instead of char arrays Date: Mon, 16 Mar 2026 10:42:27 +0000 Message-ID: <20260316104230.836962-15-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260316104230.836962-1-peter.maydell@linaro.org> References: <20260316104230.836962-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1773657790828154100 Older versions of gcc with -Wformat-overflow=3D2 don't like the usage of fixed size char arrays in this test; gcc 7.5.0 (SUSE Linux) says: ../tests/qtest/ast2700-sgpio-test.c: In function =E2=80=98test_output_pins= =E2=80=99: ../tests/qtest/ast2700-sgpio-test.c:27:33: error: =E2=80=98sprintf=E2=80=99= may write a terminating nul past the end of the destination [-Werror=3Dformat-overflow=3D] ../tests/qtest/ast2700-sgpio-test.c: In function =E2=80=98test_irq_level_hi= gh=E2=80=99: ../tests/qtest/ast2700-sgpio-test.c:85:33: error: =E2=80=98sprintf=E2=80=99= may write a terminating nul past the end of the destination [-Werror=3Dformat-overflow=3D] These can't actually happen because of the limited size of the values being substituted in. However rather than require readers to check whether the arrays really have been declared large enough, we prefer to use g_strdup_printf() for this kind of string work. Reported-by: Fabiano Rosas Signed-off-by: Peter Maydell Tested-by: Fabiano Rosas Reviewed-by: C=C3=A9dric Le Goater Message-id: 20260310151507.2973843-2-peter.maydell@linaro.org --- tests/qtest/ast2700-sgpio-test.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/qtest/ast2700-sgpio-test.c b/tests/qtest/ast2700-sgpio-t= est.c index 56c54cca9b..529408ca8f 100644 --- a/tests/qtest/ast2700-sgpio-test.c +++ b/tests/qtest/ast2700-sgpio-test.c @@ -18,14 +18,14 @@ static void test_output_pins(const char *machine, const uint32_t base, int= idx) { QTestState *s =3D qtest_init(machine); - char name[16]; - char qom_path[64]; uint32_t offset =3D 0; uint32_t value =3D 0; for (int i =3D 0; i < ASPEED_SGPIO_MAX_PIN_PAIR; i++) { /* Odd index is output port */ - sprintf(name, "sgpio%03d", i * 2 + 1); - sprintf(qom_path, "/machine/soc/sgpio[%d]", idx); + g_autofree const char *name =3D g_strdup_printf("sgpio%03d", i * 2= + 1); + g_autofree const char *qom_path + =3D g_strdup_printf("/machine/soc/sgpio[%d]", idx); + offset =3D base + (R_SGPIO_0_CONTROL + i) * 4; /* set serial output */ qtest_writel(s, offset, 0x00000001); @@ -45,14 +45,14 @@ static void test_output_pins(const char *machine, const= uint32_t base, int idx) static void test_input_pins(const char *machine, const uint32_t base, int = idx) { QTestState *s =3D qtest_init(machine); - char name[16]; - char qom_path[64]; uint32_t offset =3D 0; uint32_t value =3D 0; for (int i =3D 0; i < ASPEED_SGPIO_MAX_PIN_PAIR; i++) { /* Even index is input port */ - sprintf(name, "sgpio%03d", i * 2); - sprintf(qom_path, "/machine/soc/sgpio[%d]", idx); + g_autofree const char *name =3D g_strdup_printf("sgpio%03d", i * 2= ); + g_autofree const char *qom_path + =3D g_strdup_printf("/machine/soc/sgpio[%d]", idx); + offset =3D base + (R_SGPIO_0_CONTROL + i) * 4; /* set serial input */ qtest_qom_set_bool(s, qom_path, name, true); @@ -73,8 +73,6 @@ static void test_irq_level_high(const char *machine, const uint32_t base, int idx) { QTestState *s =3D qtest_init(machine); - char name[16]; - char qom_path[64]; uint32_t ctrl_offset =3D 0; uint32_t int_offset =3D 0; uint32_t int_reg_idx =3D 0; @@ -82,8 +80,10 @@ static void test_irq_level_high(const char *machine, uint32_t value =3D 0; for (int i =3D 0; i < ASPEED_SGPIO_MAX_PIN_PAIR; i++) { /* Even index is input port */ - sprintf(name, "sgpio%03d", i * 2); - sprintf(qom_path, "/machine/soc/sgpio[%d]", idx); + g_autofree const char *name =3D g_strdup_printf("sgpio%03d", i * 2= ); + g_autofree const char *qom_path =3D + g_strdup_printf("/machine/soc/sgpio[%d]", idx); + int_reg_idx =3D i / 32; int_bit_idx =3D i % 32; int_offset =3D base + (R_SGPIO_INT_STATUS_0 + int_reg_idx) * 4; --=20 2.43.0