From nobody Mon Feb 9 03:52:29 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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=1594151235; cv=none; d=zohomail.com; s=zohoarc; b=VjSf2otZSo1Evlbe2cqnzWoh1D1s4BJ60cMFRWcHAKxoqn20swXUAuV3Z2vNfuTqEAGjcSvKFLTPfownzoLhZBKDu8YDkGrTR5xqhqPoeRXFO1Es9t7on2YDFfrGcR6Y5/7eAZ9sQv61/NICQI8iUdwfkLHzco1Y1QofGj5/6pk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594151235; 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=mFuoMjmt3nEbtNeLgfXpFBKFGHjgPz96XukDr09r8H0=; b=FyFBgmaSgaWldKJcQ3PeVHPViGzjgxni5tIML5Zf4NFMhflb6hh69VydKSMe4pLlnDML593y0U7jgk+ElfQSA5TZta/q54rVqq+O89DgXwjUpYkAwF6sjxJvC3LeZRblh/aVD3mi7luRRVgoYYMKRlWkUCEVlHCEtRrSWsIz9rQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 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-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1594151235331146.82585802363997; Tue, 7 Jul 2020 12:47:15 -0700 (PDT) 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-240-qiIXH285OVyQ0DAzNCJpxw-1; Tue, 07 Jul 2020 15:47:11 -0400 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 DD9AF8005B0; Tue, 7 Jul 2020 19:47:04 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BC1A619D7D; Tue, 7 Jul 2020 19:47:04 +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 893921800433; Tue, 7 Jul 2020 19:47:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 067Jkh74031436 for ; Tue, 7 Jul 2020 15:46:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0361F797F0; Tue, 7 Jul 2020 19:46:43 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id 77082797EF for ; Tue, 7 Jul 2020 19:46:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594151234; 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=mFuoMjmt3nEbtNeLgfXpFBKFGHjgPz96XukDr09r8H0=; b=J2d78KGyCRRtdtonus3B+6PCJvwT/uCwt44G97HCyrZnb76Q6lteja5lmy8NdzDK4JDTUN rROsuKtpx07NwLAErkaC3X4ClO9cdLR6EJDou9M1OSmpgaXp3u6j1eA8CsMnPcnUD00RcS 9V8rt48ENz7Ot0sKAL8SCfgCiUyWjeg= X-MC-Unique: qiIXH285OVyQ0DAzNCJpxw-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 03/17] virfdstream: Use autoptr for virFDStreamMsg Date: Tue, 7 Jul 2020 21:46:21 +0200 Message-Id: <48fe3808730de26d4301842499f9a784d4303577.1594150891.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 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) Content-Type: text/plain; charset="utf-8" A cleanup function can be declared for virFDStreamMsg type so that the structure doesn't have to be freed explicitly. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virfdstream.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 6efe6c17ad..25661736ca 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -208,6 +208,8 @@ virFDStreamMsgFree(virFDStreamMsgPtr msg) VIR_FREE(msg); } =20 +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virFDStreamMsg, virFDStreamMsgFree); + =20 static void virFDStreamMsgQueueFree(virFDStreamMsgPtr *queue) @@ -428,7 +430,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, size_t *dataLen, size_t buflen) { - virFDStreamMsgPtr msg =3D NULL; + g_autoptr(virFDStreamMsg) msg =3D NULL; int inData =3D 0; long long sectionLen =3D 0; g_autofree char *buf =3D NULL; @@ -494,7 +496,6 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, return got; =20 error: - virFDStreamMsgFree(msg); return -1; } =20 @@ -761,7 +762,7 @@ virFDStreamAbort(virStreamPtr st) static int virFDStreamWrite(virStreamPtr st, const char *bytes, size_t nby= tes) { virFDStreamDataPtr fdst =3D st->privateData; - virFDStreamMsgPtr msg =3D NULL; + g_autoptr(virFDStreamMsg) msg =3D NULL; int ret =3D -1; =20 if (nbytes > INT_MAX) { @@ -838,7 +839,6 @@ static int virFDStreamWrite(virStreamPtr st, const char= *bytes, size_t nbytes) =20 cleanup: virObjectUnlock(fdst); - virFDStreamMsgFree(msg); return ret; } =20 @@ -960,7 +960,7 @@ virFDStreamSendHole(virStreamPtr st, unsigned int flags) { virFDStreamDataPtr fdst =3D st->privateData; - virFDStreamMsgPtr msg =3D NULL; + g_autoptr(virFDStreamMsg) msg =3D NULL; off_t off; int ret =3D -1; =20 @@ -1028,7 +1028,6 @@ virFDStreamSendHole(virStreamPtr st, ret =3D 0; cleanup: virObjectUnlock(fdst); - virFDStreamMsgFree(msg); return ret; } =20 --=20 2.26.2