From nobody Mon Feb 9 16:22:02 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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.133.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=1642171233; cv=none; d=zohomail.com; s=zohoarc; b=OG6+5+yPuZCn36G2+CQRPMcDBdhRSemg7glo5XoQd7JzNQuEsKpsxZytRaKhkIfnOFQnNQft+Owjh++XB4ZnXZI2ajPPBJuwyYpQAa/coBwR3+EoqgvxbvH8X8O4wS6MQdQLfDiKLi2p3tWiwNwCKnL6zndKR++zRKJhxe7uwJk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642171233; 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=veCBA8sKywSXuVxtQue80ndMcog+TbwjDyGeQ8n4EJY=; b=LOGAnz9ou4pz24VlJ3RNuhGZrC9DA0cgIOQ1NS8j6MWurPItkwDjJ76uL96eW6/AgaRB89bTh2+kn+QABDv49/QoCbNxHBxKrf46dgaN4Fm0tjeuo0bQD12Qo0OTmB6epNZKQtF3L4vPxY8dYQIp+2yhbeblCukslT0lWL8IgHQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.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.133.124]) by mx.zohomail.com with SMTPS id 1642171233453340.0380078901645; Fri, 14 Jan 2022 06:40:33 -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-526-ouBlnN7MMDSkQKsFfeNuNA-1; Fri, 14 Jan 2022 09:40:28 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 262CF1054FA4; Fri, 14 Jan 2022 14:40:23 +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 EBF7484D1F; Fri, 14 Jan 2022 14:40:22 +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 B514B4A705; Fri, 14 Jan 2022 14:40:22 +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 20EEeFBc029284 for ; Fri, 14 Jan 2022 09:40:15 -0500 Received: by smtp.corp.redhat.com (Postfix) id 42BBF7B6EB; Fri, 14 Jan 2022 14:40:15 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.56]) by smtp.corp.redhat.com (Postfix) with ESMTP id A36CA7B6F1 for ; Fri, 14 Jan 2022 14:40:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642171232; 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=veCBA8sKywSXuVxtQue80ndMcog+TbwjDyGeQ8n4EJY=; b=Xcz75YSeqz8LqiCV48ODace+P2mMiYoaqwNLBJaovX4Fg6FDLiFdcepGqWbjGnrkoLZzM8 LExNJlydAeSFxy7x5JfRIv8v44BHRZS3hYFNxSx2kk5IL+RD8ucxRt2M6zqgaF+KUMgt+z ew6KHhwBFjHWVpkP5hoYHrAq6XDXZUg= X-MC-Unique: ouBlnN7MMDSkQKsFfeNuNA-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 08/11] xen_xl.c: Use g_autofree more Date: Fri, 14 Jan 2022 15:39:52 +0100 Message-Id: <03544966a21979b3c8c04c10a467749a0078e32b.1642171139.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.13 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: 1642171235292100002 Content-Type: text/plain; charset="utf-8" There are few places inside src/libxl/xen_xl.c that can benefit from g_autofree. Let them use automatic memory freeing. Signed-off-by: Michal Privoznik --- src/libxl/xen_xl.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/src/libxl/xen_xl.c b/src/libxl/xen_xl.c index f32a6cd65a..043f3c27db 100644 --- a/src/libxl/xen_xl.c +++ b/src/libxl/xen_xl.c @@ -321,10 +321,11 @@ xenParseXLSpice(virConf *conf, virDomainDef *def) { virDomainGraphicsDef *graphics =3D NULL; unsigned long port; - char *listenAddr =3D NULL; int val; =20 if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM) { + g_autofree char *listenAddr =3D NULL; + if (xenConfigGetBool(conf, "spice", &val, 0) < 0) return -1; =20 @@ -335,7 +336,6 @@ xenParseXLSpice(virConf *conf, virDomainDef *def) goto cleanup; if (virDomainGraphicsListenAppendAddress(graphics, listenAddr)= < 0) goto cleanup; - VIR_FREE(listenAddr); =20 if (xenConfigGetULong(conf, "spicetls_port", &port, 0) < 0) goto cleanup; @@ -384,7 +384,6 @@ xenParseXLSpice(virConf *conf, virDomainDef *def) return 0; =20 cleanup: - VIR_FREE(listenAddr); virDomainGraphicsDefFree(graphics); return -1; } @@ -575,7 +574,6 @@ xenParseXLXenbusLimits(virConf *conf, virDomainDef *def) static int xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) { - char *tmpstr =3D NULL; int ret =3D -1; =20 /* A NULL source is valid, e.g. an empty CDROM */ @@ -583,6 +581,8 @@ xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) return 0; =20 if (STRPREFIX(srcstr, "rbd:")) { + g_autofree char *tmpstr =3D NULL; + if (!(tmpstr =3D virStringReplace(srcstr, "\\\\", "\\"))) goto cleanup; =20 @@ -596,7 +596,6 @@ xenParseXLDiskSrc(virDomainDiskDef *disk, char *srcstr) } =20 cleanup: - VIR_FREE(tmpstr); return ret; } =20 @@ -952,13 +951,13 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) { virConfValue *list =3D virConfGetValue(conf, "channel"); virDomainChrDef *channel =3D NULL; - char *name =3D NULL; - char *path =3D NULL; =20 if (list && list->type =3D=3D VIR_CONF_LIST) { list =3D list->list; while (list) { g_autofree char *type =3D NULL; + g_autofree char *name =3D NULL; + g_autofree char *path =3D NULL; char *key; =20 if ((list->type !=3D VIR_CONF_STRING) || (list->str =3D=3D NUL= L)) @@ -1003,7 +1002,6 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) channel->source->data.nix.path =3D g_steal_pointer(&path); } else if (STRPREFIX(type, "pty")) { channel->source->type =3D VIR_DOMAIN_CHR_TYPE_PTY; - VIR_FREE(path); } else { goto cleanup; } @@ -1023,8 +1021,6 @@ xenParseXLChannel(virConf *conf, virDomainDef *def) =20 cleanup: virDomainChrDefFree(channel); - VIR_FREE(path); - VIR_FREE(name); return -1; } =20 @@ -1382,7 +1378,6 @@ xenFormatXLVnuma(virConfValue *list, list->list =3D numaVnode; ret =3D 0; =20 - VIR_FREE(nodeVcpus); return ret; } =20 --=20 2.34.1