From nobody Sun Feb 8 17:47:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1611667670; cv=none; d=zohomail.com; s=zohoarc; b=ebGzhK4e4orfxptfyKpgf6Oa0uI0lQnNcl4picjVb/e8y+O1iVklfOt18izxW08tnmGmjzBxzYaZ1ci8JYhf1zm6kRCFOBsmac7mh33cqu5TZ6qzaOY/gvKeqFnBcNM8tEf90c1m4AqHtgPy09QGneHwxMOVRiONBmZIg1kKor4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1611667670; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=1s0lhd7PeSkupsOKPmM0KXdecsdC926gW7+hAtEDmAE=; b=TMJphDHRLZbYvWdCbbPu9qKxGLkywusmMphoQWcuIuvTQjuiop2FM7BE9AFCLE/Vh3GqN56MiO3khqWR00fq5yo2DNFwtVmF2XtBMyV+Otq9vH/3APzb4alQ7lFheByL7CikhqCx9x/3iGreReH4TwhSyCOJ4YAFNL0BV4IOwcs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 161166767060156.64591745772043; Tue, 26 Jan 2021 05:27:50 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-502-gRZwgM6iMX-S_Xep1K1OuQ-1; Tue, 26 Jan 2021 08:27:46 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B397F8015D4; Tue, 26 Jan 2021 13:27:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D9B75FC29; Tue, 26 Jan 2021 13:27:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4E5305002F; Tue, 26 Jan 2021 13:27:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 10QDRPSL001359 for ; Tue, 26 Jan 2021 08:27:26 -0500 Received: by smtp.corp.redhat.com (Postfix) id F0A455C276; Tue, 26 Jan 2021 13:27:25 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.193.116]) by smtp.corp.redhat.com (Postfix) with ESMTP id 722C55C73F for ; Tue, 26 Jan 2021 13:27:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1611667669; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=1s0lhd7PeSkupsOKPmM0KXdecsdC926gW7+hAtEDmAE=; b=a3GZdBT4oPItTPVpkJgEHecayA4e+x4OY8GKUmPgWa+3D7Ord3MEEcPNm8i0MW+j9Y4779 WdT0nY4BfDRzsZHPcR+pIaZkO+INB5IApP0ETNTF5Exe63wOLqHnl/nLsbFydZJ8aJBfwP vp6GykgeJ2YLb0cawMlUOBN+zs0mrwo= X-MC-Unique: gRZwgM6iMX-S_Xep1K1OuQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/9] vshReadlineParse: Use g_auto*() Date: Tue, 26 Jan 2021 14:27:08 +0100 Message-Id: <6af704f87f4de9a4b11a87385409b1406594d475.1611667532.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Instead of freeing @partial and @buf explicitly, we can use g_auto*() to do that automatically. Signed-off-by: Michal Privoznik --- tools/vsh.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/tools/vsh.c b/tools/vsh.c index ba6299aae4..9a7ca6776b 100644 --- a/tools/vsh.c +++ b/tools/vsh.c @@ -739,6 +739,8 @@ vshCommandFree(vshCmd *cmd) } } =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(vshCmd, vshCommandFree); + /** * vshCommandOpt: * @cmd: parsed command line to search @@ -2704,10 +2706,10 @@ vshReadlineParse(const char *text, int state) * initialize those static variables above. On subsequent * calls @state is non zero. */ if (!state) { - vshCmd *partial =3D NULL; + g_autoptr(vshCmd) partial =3D NULL; const vshCmdDef *cmd =3D NULL; const vshCmdOptDef *opt =3D NULL; - char *buf =3D g_strdup(rl_line_buffer); + g_autofree char *buf =3D g_strdup(rl_line_buffer); =20 g_strfreev(list); list =3D NULL; @@ -2717,8 +2719,6 @@ vshReadlineParse(const char *text, int state) =20 vshCommandStringParse(NULL, buf, &partial); =20 - VIR_FREE(buf); - if (partial) { cmd =3D partial->def; partial->skipChecks =3D true; @@ -2759,12 +2759,10 @@ vshReadlineParse(const char *text, int state) (vshCompleterFilter(&completer_list, text) < 0 || virStringListMerge(&list, &completer_list) < 0)) { g_strfreev(completer_list); - vshCommandFree(partial); goto cleanup; } } } - vshCommandFree(partial); } =20 if (list) { --=20 2.26.2