From nobody Tue Apr 7 05:59:11 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=1773657897; cv=none; d=zohomail.com; s=zohoarc; b=XOA2CXdH8aofQdXt5/7dxt7QNjWjOBqK8sRtVqfI/pqewToqXLCkxz1n+fcckbjcHoJdkV6mQfnfXf6YLGsSwn4LJN8YIwuJrgKZnjdZIDz6mn05pZS7hOKbAG9gPRvEvYRQ0Tz+oLPzpcYoyrDLiIpdXcb6E5hWwaV9k+3ydqs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773657897; 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=6aV4AyLVehW0PthetTdb9Q6TzUbWpqWLCzbdXYshMzc=; b=DcTXypTbo5oybckf5In6JDRV/4xZNfvMlTJtHZ8Zl/463tl/bqB9cAGd07cDyi40yxzDJZ85PzNBNWAZuv1NInn6vxFBuvCBzk9lyf4RSa5z+riDJEP2AX8w3/hlc3igX73VezaMImWAai3irOiJP9IQdH8/WqJmBDtW7bjOHp0= 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 1773657897208773.335810154018; Mon, 16 Mar 2026 03:44:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w25PS-0001ts-4O; Mon, 16 Mar 2026 06:42:54 -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 1w25PQ-0001mo-Ht for qemu-devel@nongnu.org; Mon, 16 Mar 2026 06:42:52 -0400 Received: from mail-wm1-x333.google.com ([2a00:1450:4864:20::333]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w25PO-0003gq-OL for qemu-devel@nongnu.org; Mon, 16 Mar 2026 06:42:52 -0400 Received: by mail-wm1-x333.google.com with SMTP id 5b1f17b1804b1-48532925a4bso22532225e9.1 for ; Mon, 16 Mar 2026 03:42:50 -0700 (PDT) Received: from lanath.. ([81.2.115.145]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48557a74266sm85519135e9.17.2026.03.16.03.42.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 Mar 2026 03:42:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1773657769; x=1774262569; 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=6aV4AyLVehW0PthetTdb9Q6TzUbWpqWLCzbdXYshMzc=; b=IQ0BJ/ua+y7qIWkk27GT/qZY0Q9lgJbxTaKHwK0ABAM1uMjdZ17pnI4+Ulkp4No9ey Qml0GQ91QSneJQ/HfGhKUbYQB6953MpGlLrDeokJ05OUnxEgknyrOsqGxh6kxd94xhqy eAkV2VE6BHVRKuT08ae1qWJdplByBC+uW7P821nJJAeRp3npw0N2r3e1lqE2DIHugfhA JuaOZvMpJdnzKgM6xmmIIDXMlkpoaHW+O+UIy+WDIs0IeVp08eKkdA69owLcEH9a+CkN HvfrnosHZSY3EuIH4oeAjZ75DnX4KSUhHpsuF8Gy0RyH2D2ijfwdnx2y77EEEg7OqXxp 4aWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773657769; x=1774262569; 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=6aV4AyLVehW0PthetTdb9Q6TzUbWpqWLCzbdXYshMzc=; b=cboqdckvcbFzvjMaJp0RuV1YF7ZIDxVAxpGNI+bRI7R6HkX0eNjCYF2bSkw0Lw8ssu 1mOvXJGzyCbAMcN3mNGRfJFYaszXQ/bW2WRxaCX37AAAlofoTjaZ62J6bdOFM6+sSrN+ 9p9uGO194FUF07DvddbQjRb7Z0a6cJLx3ZJr/VV3PpK6Ck851uHWanrp5T5nKE7IN6+T 2H7MBoq4f0SLpvvzi7/+FY3y5zWTrDufG/gGIa0D8qmHIlS4RL1BtJngojXAvER9b/3C P97ZpRuek0JuOeVePWtUjVPPrv2e2OuUV7lvkCPRA3WqYFtAGo9N18SKPxzQka9paRvY NQfg== X-Gm-Message-State: AOJu0Yy287lAgZTe6n2f7bQ8MRS3/1S/EyipJS5dHdibOI00eYcELo6J rhehVmFLjscz4QwnbCsS+tMUWPH4YQgtIkORvZsR64cnMvAgFqjXF3nm4NmArCbfZf7M9UTlcCu B6iY9 X-Gm-Gg: ATEYQzxyLDcyKne5CHfOE9OmYAie7pzoSaDhFzM9hY78ylhNIvlvFDTT78movI3DPa1 eUT9mvUhjvWURJIytWyD0ny35OEMplLggEFPS2QxVXbvERJ1D1DloU5sKc/WPXJnSFOhkBqe8A4 FPOxcMyog9syMtgToi219cmXKckGttudkywTIUMxcyDD81bNPvkt0StWaHTWIwYgR5eQyaOUbXE a+agD2fo7OY9A4FWurzlvhO/VBISnasFNYO8KdCyrpM0tS0eWXrp5N/C3Bft6hp/Grj/MIAyh8+ SSbWCr+E2Iuv3s/+UbXtkoP3gf0+FqZO49zEa5ssPXD8ob9x4JlM0shRMsSInunURlNESxb4Gwc BDioQH204ZeP3V6vajfEosh3eXGEWU2LzViFGlzSr+OAJNuuju0+PKj1kwh5/X2WuFL7IGjjX8u k/NyfyRbZhby4et8zaYBxSDjXSmdfuLWPWNmpLikqSnnS6IqwXFEYwxbOtyxh38CpAabzotFYyn cae+sb4e1g= X-Received: by 2002:a05:600c:1388:b0:483:badb:618f with SMTP id 5b1f17b1804b1-485567050dcmr204222605e9.25.1773657769143; Mon, 16 Mar 2026 03:42:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 15/17] tests/qtest/arm-cpu-features: Use g_strdup_printf() instead of char arrays Date: Mon, 16 Mar 2026 10:42:28 +0000 Message-ID: <20260316104230.836962-16-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::333; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x333.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: 1773657898402154100 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/arm-cpu-features.c: In function =E2=80=98test_query_cpu_mode= l_expansion_kvm=E2=80=99: ../tests/qtest/arm-cpu-features.c:578:35: error: =E2=80=98%u=E2=80=99 direc= tive writing between 1 and 10 bytes into a region of size 5 [-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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 Message-id: 20260310151507.2973843-3-peter.maydell@linaro.org --- tests/qtest/arm-cpu-features.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/tests/qtest/arm-cpu-features.c b/tests/qtest/arm-cpu-features.c index eb8ddebffb..5444e4d40b 100644 --- a/tests/qtest/arm-cpu-features.c +++ b/tests/qtest/arm-cpu-features.c @@ -519,7 +519,6 @@ static void test_query_cpu_model_expansion_kvm(const vo= id *data) bool kvm_supports_pmu; bool kvm_supports_steal_time; bool kvm_supports_sve; - char max_name[8], name[8]; uint32_t max_vq, vq; uint64_t vls; QDict *resp; @@ -573,9 +572,12 @@ static void test_query_cpu_model_expansion_kvm(const v= oid *data) } =20 if (kvm_supports_sve) { + g_autofree const char *max_name =3D NULL; + g_autofree const char *name =3D NULL; + g_assert(vls !=3D 0); max_vq =3D 64 - __builtin_clzll(vls); - sprintf(max_name, "sve%u", max_vq * 128); + max_name =3D g_strdup_printf("sve%u", max_vq * 128); =20 /* Enabling a supported length is of course fine. */ assert_sve_vls(qts, "host", vls, "{ %s: true }", max_name); @@ -583,6 +585,9 @@ static void test_query_cpu_model_expansion_kvm(const vo= id *data) /* Get the next supported length smaller than max-vq. */ vq =3D 64 - __builtin_clzll(vls & ~BIT_ULL(max_vq - 1)); if (vq) { + g_autofree const char *name2 =3D + g_strdup_printf("sve%u", vq * 128); + /* * We have at least one length smaller than max-vq, * so we can disable max-vq. @@ -595,11 +600,10 @@ static void test_query_cpu_model_expansion_kvm(const = void *data) * unless all larger, supported vector lengths are also * disabled. */ - sprintf(name, "sve%u", vq * 128); - error =3D g_strdup_printf("cannot disable %s", name); + error =3D g_strdup_printf("cannot disable %s", name2); assert_error(qts, "host", error, "{ %s: true, %s: false }", - max_name, name); + max_name, name2); g_free(error); } =20 @@ -608,7 +612,7 @@ static void test_query_cpu_model_expansion_kvm(const vo= id *data) * we need at least one vector length enabled. */ vq =3D __builtin_ffsll(vls); - sprintf(name, "sve%u", vq * 128); + name =3D g_strdup_printf(name, "sve%u", vq * 128); error =3D g_strdup_printf("cannot disable %s", name); assert_error(qts, "host", error, "{ %s: false }", name); g_free(error); @@ -620,9 +624,11 @@ static void test_query_cpu_model_expansion_kvm(const v= oid *data) } } if (vq <=3D SVE_MAX_VQ) { - sprintf(name, "sve%u", vq * 128); - error =3D g_strdup_printf("cannot enable %s", name); - assert_error(qts, "host", error, "{ %s: true }", name); + g_autofree const char *name2 =3D + g_strdup_printf("sve%u", vq * 128); + + error =3D g_strdup_printf("cannot enable %s", name2); + assert_error(qts, "host", error, "{ %s: true }", name2); g_free(error); } } else { --=20 2.43.0