From nobody Tue Apr 7 00:44:32 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=suse.de ARC-Seal: i=1; a=rsa-sha256; t=1773771897; cv=none; d=zohomail.com; s=zohoarc; b=fF9Jx4l9WGNIqohJphh45Q5XlDqe22d4LRWiKOt0IYCq+9aJ1nvbUrgMwIyeRYVWtMI7M1tOfWwsCRGyfv1OUUZDNTQIOOzQFAKcFDFUck0dPnTFKl77CMcYO0+gK8QhGLY9d3UeQEupMAUv2UbYIDmQwXir4Bjb/jf+KjcbwG4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773771897; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=XQWEuBKAi2YbC0czpsuizw7lRBNrGsjzEhd6lT/BdAI=; b=KY8UH+wTYfXRCPz9s+0KRXUUZdLiHCLBDekQ4grGigfho3qj30E7fk3nDoPuAYJOqV6UkWU72Zhc9bRYCpEemdqsIaS8tQyFGiHTLIi2ocr2bGlPY0S68stdjxXxJSGsSV07YgsF4+LR/zbphLmoV+MQzem/WUkrstLXMQCvX+Q= 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 1773771897802611.5231825885422; Tue, 17 Mar 2026 11:24:57 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w2Z64-0005Ja-8C; Tue, 17 Mar 2026 14:24:52 -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 1w2Z5p-0004wZ-Ew for qemu-devel@nongnu.org; Tue, 17 Mar 2026 14:24:39 -0400 Received: from smtp-out1.suse.de ([195.135.223.130]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w2Z5j-0003AI-Ib for qemu-devel@nongnu.org; Tue, 17 Mar 2026 14:24:35 -0400 Received: from imap1.dmz-prg2.suse.org (unknown [10.150.64.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 07C1F4D3B0; Tue, 17 Mar 2026 18:23:39 +0000 (UTC) Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id D719D4273B; Tue, 17 Mar 2026 18:23:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id OHoIJymcuWnXdQAAD6G6ig (envelope-from ); Tue, 17 Mar 2026 18:23:37 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773771819; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQWEuBKAi2YbC0czpsuizw7lRBNrGsjzEhd6lT/BdAI=; b=uNOLZyARjwCia6K+VipW0qxlYkyVeGLh60WB6OYcGJ9q/4FZ04m0G4Nj/5GIor86SjyXld Mdtn8u93OftyN7lzguNBINrK85tRC+Rg7ELt1llW/WJCpElPVDdht1gZveFi54eb9zrDzk fko4Lb2q+XRe4omM64g886OTAXYiiBs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773771819; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQWEuBKAi2YbC0czpsuizw7lRBNrGsjzEhd6lT/BdAI=; b=/Zj3Vb/l+8kFKWqpoSwaMeGWvL9DpHXsHh0m74tMAc2Y6g88mSyWpEB0JOG6uCS38ZX5t4 +WsH7eNd4w7mrLDw== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1773771819; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQWEuBKAi2YbC0czpsuizw7lRBNrGsjzEhd6lT/BdAI=; b=uNOLZyARjwCia6K+VipW0qxlYkyVeGLh60WB6OYcGJ9q/4FZ04m0G4Nj/5GIor86SjyXld Mdtn8u93OftyN7lzguNBINrK85tRC+Rg7ELt1llW/WJCpElPVDdht1gZveFi54eb9zrDzk fko4Lb2q+XRe4omM64g886OTAXYiiBs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1773771819; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=XQWEuBKAi2YbC0czpsuizw7lRBNrGsjzEhd6lT/BdAI=; b=/Zj3Vb/l+8kFKWqpoSwaMeGWvL9DpHXsHh0m74tMAc2Y6g88mSyWpEB0JOG6uCS38ZX5t4 +WsH7eNd4w7mrLDw== From: Fabiano Rosas To: qemu-devel@nongnu.org Cc: Peter Xu , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PULL 09/10] tests/qtest: Don't dup machine name in qtest_cb_for_every_machine callbacks Date: Tue, 17 Mar 2026 15:23:19 -0300 Message-ID: <20260317182320.31991-10-farosas@suse.de> X-Mailer: git-send-email 2.51.0 In-Reply-To: <20260317182320.31991-1-farosas@suse.de> References: <20260317182320.31991-1-farosas@suse.de> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-Spam-Score: -3.30 X-Spamd-Result: default: False [-3.30 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_SHORT(-0.20)[-0.998]; MIME_GOOD(-0.10)[text/plain]; RCVD_VIA_SMTP_AUTH(0.00)[]; ARC_NA(0.00)[]; RCVD_TLS_ALL(0.00)[]; TO_DN_SOME(0.00)[]; MIME_TRACE(0.00)[0:+]; FUZZY_RATELIMITED(0.00)[rspamd.com]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; TO_MATCH_ENVRCPT_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; FROM_EQ_ENVFROM(0.00)[]; RCVD_COUNT_TWO(0.00)[2]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap1.dmz-prg2.suse.org:helo, suse.de:mid, suse.de:email] 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=195.135.223.130; envelope-from=farosas@suse.de; helo=smtp-out1.suse.de X-Spam_score_int: -26 X-Spam_score: -2.7 X-Spam_bar: -- X-Spam_report: (-2.7 / 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_MED=-2.3, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, 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 @suse.de) X-ZM-MESSAGEID: 1773771898256158500 The qtest_get_machines function caches the list of machines in a static variable. Dup'ing the machine->name string only serves to leak that memory when a single test is executed. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Link: https://lore.kernel.org/qemu-devel/20260313182957.28432-2-farosas@sus= e.de Signed-off-by: Fabiano Rosas --- tests/qtest/cpu-plug-test.c | 11 +++++------ tests/qtest/qom-test.c | 3 +-- tests/qtest/test-hmp.c | 3 +-- 3 files changed, 7 insertions(+), 10 deletions(-) diff --git a/tests/qtest/cpu-plug-test.c b/tests/qtest/cpu-plug-test.c index 0aa4ccc5b6..e68f39cf56 100644 --- a/tests/qtest/cpu-plug-test.c +++ b/tests/qtest/cpu-plug-test.c @@ -14,7 +14,7 @@ #include "qobject/qlist.h" =20 struct PlugTestData { - char *machine; + const char *machine; const char *cpu_model; char *device_model; unsigned sockets; @@ -73,7 +73,6 @@ static void test_data_free(gpointer data) { PlugTestData *pc =3D data; =20 - g_free(pc->machine); g_free(pc->device_model); g_free(pc); } @@ -87,7 +86,7 @@ static void add_pc_test_case(const char *mname) return; } data =3D g_new(PlugTestData, 1); - data->machine =3D g_strdup(mname); + data->machine =3D mname; data->cpu_model =3D "Haswell"; /* 1.3+ theoretically */ data->device_model =3D g_strdup_printf("%s-%s-cpu", data->cpu_model, qtest_get_arch()); @@ -114,7 +113,7 @@ static void add_pseries_test_case(const char *mname) return; } data =3D g_new(PlugTestData, 1); - data->machine =3D g_strdup(mname); + data->machine =3D mname; data->cpu_model =3D "power8_v2.0"; data->device_model =3D g_strdup("power8_v2.0-spapr-cpu-core"); data->sockets =3D 2; @@ -140,7 +139,7 @@ static void add_s390x_test_case(const char *mname) } =20 data =3D g_new(PlugTestData, 1); - data->machine =3D g_strdup(mname); + data->machine =3D mname; data->cpu_model =3D "qemu"; data->device_model =3D g_strdup("qemu-s390x-cpu"); data->sockets =3D 1; @@ -162,7 +161,7 @@ static void add_loongarch_test_case(const char *mname) PlugTestData *data; =20 data =3D g_new(PlugTestData, 1); - data->machine =3D g_strdup(mname); + data->machine =3D mname; data->cpu_model =3D "la464"; data->device_model =3D g_strdup("la464-loongarch-cpu"); data->sockets =3D 1; diff --git a/tests/qtest/qom-test.c b/tests/qtest/qom-test.c index 2da9918e16..6421f2d9d9 100644 --- a/tests/qtest/qom-test.c +++ b/tests/qtest/qom-test.c @@ -216,7 +216,6 @@ static void test_machine(gconstpointer data) test_list_get_value(qts); =20 qtest_quit(qts); - g_free((void *)machine); } =20 static void add_machine_test_case(const char *mname) @@ -224,7 +223,7 @@ static void add_machine_test_case(const char *mname) char *path; =20 path =3D g_strdup_printf("qom/%s", mname); - qtest_add_data_func(path, g_strdup(mname), test_machine); + qtest_add_data_func(path, mname, test_machine); g_free(path); } =20 diff --git a/tests/qtest/test-hmp.c b/tests/qtest/test-hmp.c index 1b2e07522f..60f742e83f 100644 --- a/tests/qtest/test-hmp.c +++ b/tests/qtest/test-hmp.c @@ -135,7 +135,6 @@ static void test_machine(gconstpointer data) =20 qtest_quit(qts); g_free(args); - g_free((void *)data); } =20 static void add_machine_test_case(const char *mname) @@ -143,7 +142,7 @@ static void add_machine_test_case(const char *mname) char *path; =20 path =3D g_strdup_printf("hmp/%s", mname); - qtest_add_data_func(path, g_strdup(mname), test_machine); + qtest_add_data_func(path, mname, test_machine); g_free(path); } =20 --=20 2.51.0