From nobody Mon Feb 9 09:01:25 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=quarantine dis=none) header.from=crudebyte.com ARC-Seal: i=1; a=rsa-sha256; t=1644493782; cv=none; d=zohomail.com; s=zohoarc; b=XalMs0gHZoIvRIWkRkgxZQyfPPsuGBsLYdQ1hLkM4gp2ZkcHJRomvlTgtvO1xU01pVSQEwuP8se+zMFmiGIKtapniymfIWLhVF9ISa5QuqLPMDXekldga/qsTMC11h7itxkY4LmWLhGIFngtwGMWU+vMWoKZeZQhrY1spGFEIjc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644493782; h=Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:Message-ID:References:Sender:Subject:To; bh=mcbRg2xlZAZHldg9PdPezpruRYnaMN84QxS/hR585+U=; b=aiCDHefHURCiBf0xh7ZlVFer8UQdcrgQYjPPD5MpIPA3s/59p3Y9FycGUuX0DQJyVn9/dyFrCR1v8YnsZLNpWGjoHTLKrxOgEwkIU1xVRC94fWH6fs2K8gBqEOmIwtnzIDgTsQJjyisyavEMSzFaT9I7xhQsYL/W3EA3RryF/qA= 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=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1644493782643331.4123622948829; Thu, 10 Feb 2022 03:49:42 -0800 (PST) Received: from localhost ([::1]:59380 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nI7xG-0007Sj-5O for importer@patchew.org; Thu, 10 Feb 2022 06:49:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:43344) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7c1101e9be922915491bc9ec2ca2150554192d53@lizzy.crudebyte.com>) id 1nI7kC-0007ej-JT for qemu-devel@nongnu.org; Thu, 10 Feb 2022 06:36:14 -0500 Received: from lizzy.crudebyte.com ([91.194.90.13]:59481) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from <7c1101e9be922915491bc9ec2ca2150554192d53@lizzy.crudebyte.com>) id 1nI7jp-0003U0-G9 for qemu-devel@nongnu.org; Thu, 10 Feb 2022 06:36:07 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=crudebyte.com; s=lizzy; h=Cc:To:Subject:Date:From:References:In-Reply-To: Message-Id:Content-Type:Content-Transfer-Encoding:MIME-Version:Content-ID: Content-Description; bh=mcbRg2xlZAZHldg9PdPezpruRYnaMN84QxS/hR585+U=; b=hPSY5 IwO0dXLNPdNr8awmLIiKCOgB6DPOPIvdWMQushRilJ+rUH9Dy8aKKY0s4lw4bzOgo9aruCD6cXSS+ uWn6fzGm93KtIdz/vKa7iEe29VDSOqFWa5M/UUE0ArW+R0ReB/AiX2bMQTkbf45wTftlm9MNguYsm 9WBC9sWvVvQiWmxgIL7qoIJ47H1sSenr7MC6oUygo0cN6G3GwfePVYH7h9a/eNm8oppBX6AGItNjy 3bbJmBYRCCvQO+yYpcFRRLZ9fhRryhLWiCa7jnoqtLnOJyi0NRzNpDoMZ4NI35DamdUfyFoJeKmFM 1v2lJm7qTyYKd82qr3tcsaHBSvdpg==; Message-Id: <7c1101e9be922915491bc9ec2ca2150554192d53.1644492115.git.qemu_oss@crudebyte.com> In-Reply-To: References: From: Christian Schoenebeck Date: Thu, 10 Feb 2022 12:21:55 +0100 Subject: [PULL 4/5] tests/9pfs: Use g_autofree and g_autoptr where possible To: qemu-devel@nongnu.org, Peter Maydell Cc: Greg Kurz 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: none client-ip=91.194.90.13; envelope-from=7c1101e9be922915491bc9ec2ca2150554192d53@lizzy.crudebyte.com; helo=lizzy.crudebyte.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, SPF_HELO_NONE=0.001, SPF_NONE=0.001, T_SCC_BODY_TEXT_LINE=-0.01 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: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @crudebyte.com) X-ZM-MESSAGEID: 1644493784583100001 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Greg Kurz It is recommended to use g_autofree or g_autoptr as it reduces the odds of introducing memory leaks in future changes. Signed-off-by: Greg Kurz Message-Id: <20220201151508.190035-3-groug@kaod.org> Reviewed-by: Christian Schoenebeck Signed-off-by: Christian Schoenebeck --- tests/qtest/libqos/virtio-9p.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/tests/qtest/libqos/virtio-9p.c b/tests/qtest/libqos/virtio-9p.c index 5d18e5eae5..f51f0635cc 100644 --- a/tests/qtest/libqos/virtio-9p.c +++ b/tests/qtest/libqos/virtio-9p.c @@ -41,7 +41,7 @@ void virtio_9p_create_local_test_dir(void) { g_assert(local_test_path =3D=3D NULL); struct stat st; - char *pwd =3D g_get_current_dir(); + g_autofree char *pwd =3D g_get_current_dir(); /* * template gets cached into local_test_path and freed in * virtio_9p_remove_local_test_dir(). @@ -52,7 +52,6 @@ void virtio_9p_create_local_test_dir(void) if (!local_test_path) { g_test_message("mkdtemp('%s') failed: %s", template, strerror(errn= o)); } - g_free(pwd); =20 g_assert(local_test_path !=3D NULL); =20 @@ -65,12 +64,11 @@ void virtio_9p_create_local_test_dir(void) void virtio_9p_remove_local_test_dir(void) { g_assert(local_test_path !=3D NULL); - char *cmd =3D g_strdup_printf("rm -fr '%s'\n", local_test_path); + g_autofree char *cmd =3D g_strdup_printf("rm -fr '%s'\n", local_test_p= ath); int res =3D system(cmd); if (res < 0) { /* ignore error, dummy check to prevent compiler error */ } - g_free(cmd); g_free(local_test_path); local_test_path =3D NULL; } @@ -216,8 +214,8 @@ static void *virtio_9p_pci_create(void *pci_bus, QGuest= Allocator *t_alloc, static void regex_replace(GString *haystack, const char *pattern, const char *replace_fmt, ...) { - GRegex *regex; - char *replace, *s; + g_autoptr(GRegex) regex =3D NULL; + g_autofree char *replace =3D NULL, *s =3D NULL; va_list argp; =20 va_start(argp, replace_fmt); @@ -227,9 +225,6 @@ static void regex_replace(GString *haystack, const char= *pattern, regex =3D g_regex_new(pattern, 0, 0, NULL); s =3D g_regex_replace(regex, haystack->str, -1, 0, replace, 0, NULL); g_string_assign(haystack, s); - g_free(s); - g_regex_unref(regex); - g_free(replace); } =20 void virtio_9p_assign_local_driver(GString *cmd_line, const char *args) --=20 2.20.1