From nobody Sun Feb 8 18:35:23 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1594151231; cv=none; d=zohomail.com; s=zohoarc; b=dS+cWaz75FUEEYJfgIgHs8Vq95Z9c8ML+NIjTo+Q5Y9HzH3huWT76mO9zBzamDGRabC5Y2rn+LLLieXqdUOhWKY+H2ea1s0Yjv2b6AOg/2rmR45/tdl5YQSd7szrNWJ56j9W/a9NTTMpvoKFT6XTHypKI3X7DYfFiBL9zqstnTo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594151231; 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=oTB51Dv26vqoCgsjETYiwf5dUan5a2myfSEcrgGmBYQ=; b=WKc+r4xVTj8cjJWOBw1SEM2Vk5LIDVLP8nzAKFebQaLyNtEKTRwoKruagEHrf7F6nEJpG9BhmnFYjB9CfZdlFp0cpb3yh0oOpx5gsWPFSY959yYOUOu4g4/M5QN1FeEW203Ot7jM/mIg7NxiUdUK55R+HymIKnxIu4wpIUcKTio= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594151231378985.0809665502787; Tue, 7 Jul 2020 12:47:11 -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-322-dbAo15iFObeSIzNFSGFINQ-1; Tue, 07 Jul 2020 15:47:07 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 965CD800408; Tue, 7 Jul 2020 19:47:02 +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 72A7860E1C; Tue, 7 Jul 2020 19:47:02 +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 403F21809554; Tue, 7 Jul 2020 19:47:02 +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 067JkfxK031414 for ; Tue, 7 Jul 2020 15:46:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 441E5797EF; Tue, 7 Jul 2020 19:46:41 +0000 (UTC) Received: from localhost.localdomain (unknown [10.40.192.152]) by smtp.corp.redhat.com (Postfix) with ESMTP id B7CFF797F2 for ; Tue, 7 Jul 2020 19:46:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594151230; 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=oTB51Dv26vqoCgsjETYiwf5dUan5a2myfSEcrgGmBYQ=; b=TJIOiFZ4r10/JwTPFlwHRp3HfyWsWJ3pfWcVv8sZGjOw6a4i+GjmtPDNpD5JGKWn0uuStg DUzSgm0wixs+vIEzpsVTzYw7SJiZQS4SLicobYis4Dp7zK5OZLLXd0lXIG/ZXcQlQtRmvi woElOjfWRU5T31v9+amznaqf+++7HkI= X-MC-Unique: dbAo15iFObeSIzNFSGFINQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 01/17] virfdstream: Use g_autofree in virFDStreamThreadDoRead() Date: Tue, 7 Jul 2020 21:46:19 +0200 Message-Id: <08e6cbf6f3ce02884b1cba1ed980e111f881aa61.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.79 on 10.5.11.12 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" The buffer that allocated in the virFDStreamThreadDoRead() can be automatically freed, or if saved into the message structure it can be stolen. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virfdstream.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 1c32be47a9..e29c95690b 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -431,7 +431,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, virFDStreamMsgPtr msg =3D NULL; int inData =3D 0; long long sectionLen =3D 0; - char *buf =3D NULL; + g_autofree char *buf =3D NULL; ssize_t got; =20 if (sparse && *dataLen =3D=3D 0) { @@ -483,9 +483,8 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, } =20 msg->type =3D VIR_FDSTREAM_MSG_TYPE_DATA; - msg->stream.data.buf =3D buf; + msg->stream.data.buf =3D g_steal_pointer(&buf); msg->stream.data.len =3D got; - buf =3D NULL; if (sparse) *dataLen -=3D got; } @@ -496,7 +495,6 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, return got; =20 error: - VIR_FREE(buf); virFDStreamMsgFree(msg); return -1; } --=20 2.26.2