From nobody Mon Feb 9 06:09:18 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=1594151238; cv=none; d=zohomail.com; s=zohoarc; b=MzUW0EPAfcWrvatEMXZgw+4hd7UJYXZqlEX9w1Y5EnLN6ACHuzEps7HzXVZH/Dm3YTiX1fgcm1AZG/KhspJ3ztnwhfkPVWMV/TeSGInQmzuqGPUxjIUmDpzQrmwKkOW75hPYn5HCiNnsvg7FXp74KYihx6VWUisjnPGvVK0gOsg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594151238; 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=vj7uwNpX8mZh+yzxGW0moBCDQoY37soTBGizt663q8Y=; b=kBc1+MZwEh1QbjLpVV7QnOC+NrwFQ0NtWYD0PNp5eOisNbwKDjPEC62gbWy1/bskGOmma4OWNLiDP0xE9Mpxn8ln6Fk3RyZmUFpyn1Z38XuXv7Ama+ZTOBqTP9sBVCzGsd6R2/P0z5w86O8MAtsNZ3DzMWlk0QRlGceDlkohCa8= 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 1594151238634276.9522597752908; Tue, 7 Jul 2020 12:47:18 -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-314-chrVH9CnOcSXpwzukUmRPQ-1; Tue, 07 Jul 2020 15:47:14 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 3102A108BD13; Tue, 7 Jul 2020 19:47:07 +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 123A45D9DC; Tue, 7 Jul 2020 19:47:07 +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 D653B8789F; Tue, 7 Jul 2020 19:47:06 +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 067JkhXf031442 for ; Tue, 7 Jul 2020 15:46:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id D74C6797F0; 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 56B97797EF for ; Tue, 7 Jul 2020 19:46:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594151237; 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=vj7uwNpX8mZh+yzxGW0moBCDQoY37soTBGizt663q8Y=; b=JzrF2jK9KOu4Q2x/A/cQpXltb5D6QR9jKQ2cZ6HjAZk+hKS9M5yL6i0pm32BBvihFB5mCb EtH7bVpUcky/6KpPlr8VWVSMdAgjkgBsD1WXfV+FAaH2NAXcTQwbY8ds9k6+DDU8+QfMNL uWiAwSJBulU+JdtOqu9iHJCTEVqMacQ= X-MC-Unique: chrVH9CnOcSXpwzukUmRPQ-1 From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH v2 04/17] virfdstream: Use g_new0() instead of VIR_ALLOC() Date: Tue, 7 Jul 2020 21:46:22 +0200 Message-Id: <53566f6c87099391f3d5e8e762700d10ba307732.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.14 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" This switch allow us to save a few lines of code. Signed-off-by: Michal Privoznik Reviewed-by: Peter Krempa --- src/util/virfdstream.c | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/src/util/virfdstream.c b/src/util/virfdstream.c index 25661736ca..c85dee05c3 100644 --- a/src/util/virfdstream.c +++ b/src/util/virfdstream.c @@ -452,8 +452,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, buflen > length - total) buflen =3D length - total; =20 - if (VIR_ALLOC(msg) < 0) - goto error; + msg =3D g_new0(virFDStreamMsg, 1); =20 if (sparse && *dataLen =3D=3D 0) { msg->type =3D VIR_FDSTREAM_MSG_TYPE_HOLE; @@ -474,8 +473,7 @@ virFDStreamThreadDoRead(virFDStreamDataPtr fdst, buflen > *dataLen) buflen =3D *dataLen; =20 - if (VIR_ALLOC_N(buf, buflen) < 0) - goto error; + buf =3D g_new0(char, buflen); =20 if ((got =3D saferead(fdin, buf, buflen)) < 0) { virReportSystemError(errno, @@ -805,9 +803,8 @@ static int virFDStreamWrite(virStreamPtr st, const char= *bytes, size_t nbytes) goto cleanup; } =20 - if (VIR_ALLOC(msg) < 0 || - VIR_ALLOC_N(buf, nbytes) < 0) - goto cleanup; + msg =3D g_new0(virFDStreamMsg, 1); + buf =3D g_new0(char, nbytes); =20 memcpy(buf, bytes, nbytes); msg->type =3D VIR_FDSTREAM_MSG_TYPE_DATA; @@ -1003,8 +1000,7 @@ virFDStreamSendHole(virStreamPtr st, =20 virFDStreamMsgQueuePop(fdst, fdst->fd, "pipe"); } else { - if (VIR_ALLOC(msg) < 0) - goto cleanup; + msg =3D g_new0(virFDStreamMsg, 1); =20 msg->type =3D VIR_FDSTREAM_MSG_TYPE_HOLE; msg->stream.hole.len =3D length; @@ -1123,8 +1119,7 @@ static int virFDStreamOpenInternal(virStreamPtr st, =20 /* Create the thread after fdst and st were initialized. * The thread worker expects them to be that way. */ - if (VIR_ALLOC(fdst->thread) < 0) - goto error; + fdst->thread =3D g_new0(virThread, 1); =20 if (virCondInit(&fdst->threadCond) < 0) { virReportSystemError(errno, "%s", @@ -1277,8 +1272,7 @@ virFDStreamOpenFileInternal(virStreamPtr st, if (virPipe(pipefds) < 0) goto error; =20 - if (VIR_ALLOC(threadData) < 0) - goto error; + threadData =3D g_new0(virFDStreamThreadData, 1); =20 threadData->st =3D virObjectRef(st); threadData->length =3D length; --=20 2.26.2