From nobody Mon Feb 9 05:20:56 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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 170.10.129.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=1646229416; cv=none; d=zohomail.com; s=zohoarc; b=fWeU+aJ3fVUBRzy2brDVM3RUDrF1nHjVUmoQOFwIs6JlzWryudZeIaV620fDD/+K26Qfyaa3N06W+BEumlXruMfOrgAS3yaRhfkT221jpFwhgN8Zs+aAWFR22qdCAO4DR47cLm2ZKrH5CRCEGiMoqadKvxK2SkTXzp8tjpFIBNI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1646229416; 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=p6ZEWYxkgSFpyviWtH08fDLJjzg2mBf2cxvV2bwZwqw=; b=Vr6prH0J+IigdzLlE4GtEAVI3rJlEMyXDixShnQqcvonWAcsfGvgB7bpuO+FNONsPNZtVmeDCluNN2rCc8ahAZ4UpYdmJPodBRFBzo3fM7QDriPdT+jX7TsMBO/LJ36LiD6jkg8RxEm98qyTWMer71yQUKzN+VN0VZvLg9VOe+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1646229416777420.0595908232542; Wed, 2 Mar 2022 05:56:56 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-641-qP9AZMwTNOeVR2feaZuBMg-1; Wed, 02 Mar 2022 08:56:53 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3EAE6188E3FD; Wed, 2 Mar 2022 13:56:46 +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 DAACE26DFE; Wed, 2 Mar 2022 13:56:45 +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 A64C54EA37; Wed, 2 Mar 2022 13:56:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 222DugX5018260 for ; Wed, 2 Mar 2022 08:56:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 52A0D83788; Wed, 2 Mar 2022 13:56:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id B446D83783 for ; Wed, 2 Mar 2022 13:56:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1646229416; 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=p6ZEWYxkgSFpyviWtH08fDLJjzg2mBf2cxvV2bwZwqw=; b=WbW8w5t8vXr56NnVETs+g7GZDl5XE06sXK3BxutdMPlOfyhegWJYG6WIQ0ja0sVKkkBDUO pAu3Li61sDPv9Qmd/q+NgLADua1zBan6WzD5+Pb+aEjnDjI8nzxc9V/yoDYJN2jHVBDLph c76IGzftcwVX33gQ9scr+pGJR3e70j8= X-MC-Unique: qP9AZMwTNOeVR2feaZuBMg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/23] virsh: cmdDesc: Automatically free memory Date: Wed, 2 Mar 2022 14:55:19 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.84 on 10.5.11.23 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) X-ZM-MESSAGEID: 1646229421619100003 Content-Type: text/plain; charset="utf-8" Decrease scope of variables and use automatic freeing. Signed-off-by: Peter Krempa --- tools/virsh-domain.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index dcf0f712f6..4d9722f400 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -8333,9 +8333,7 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) int state; int type; - char *desc =3D NULL; - char *desc_edited =3D NULL; - char *tmpstr; + g_autofree char *desc =3D NULL; const vshCmdOpt *opt =3D NULL; g_auto(virBuffer) buf =3D VIR_BUFFER_INITIALIZER; bool ret =3D false; @@ -8379,6 +8377,8 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) if (edit) { g_autoptr(vshTempFile) tmp =3D NULL; + g_autofree char *desc_edited =3D NULL; + char *tmpstr; /* Create and open the temporary file. */ if (!(tmp =3D vshEditWriteToTempFile(ctl, desc))) @@ -8438,8 +8438,6 @@ cmdDesc(vshControl *ctl, const vshCmd *cmd) ret =3D true; cleanup: - VIR_FREE(desc_edited); - VIR_FREE(desc); return ret; } --=20 2.35.1