From nobody Fri May 16 03:34:05 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1498759480593357.2551087686569; Thu, 29 Jun 2017 11:04:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A267EC00AFB3; Thu, 29 Jun 2017 18:04:36 +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 6973717496; Thu, 29 Jun 2017 18:04:36 +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 22EDB3FAE7; Thu, 29 Jun 2017 18:04:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v5TI4Io7006715 for ; Thu, 29 Jun 2017 14:04:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 04DF1179DB; Thu, 29 Jun 2017 18:04:18 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.82]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 82CB5179DE for ; Thu, 29 Jun 2017 18:04:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A267EC00AFB3 Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A267EC00AFB3 From: Andrea Bolognani To: libvir-list@redhat.com Date: Thu, 29 Jun 2017 20:04:00 +0200 Message-Id: <1498759443-10136-8-git-send-email-abologna@redhat.com> In-Reply-To: <1498759443-10136-1-git-send-email-abologna@redhat.com> References: <1498759443-10136-1-git-send-email-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 07/10] conf: Clean up virDomainDeviceInfo functions 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Thu, 29 Jun 2017 18:04:37 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Mostly style changes to make them a little bit nicer. Signed-off-by: Andrea Bolognani --- src/conf/device_conf.c | 38 +++++++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 7 deletions(-) diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index 6ead830..facde0e 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -45,21 +45,44 @@ virDomainDeviceInfoNew(void) return info; } =20 +/** + * virDomainDeviceInfoClear: + * @info: device info + * + * Reset @info to its default state: all members will be set to their defa= ult + * value, and any memory associated with @info will be released. @info its= elf + * will still be valid after this function returns. + * + * You only need to call this function if you're allocating a + * virDomainDeviceInfo on the stack or embedding one inside your own struc= t: + * virDomainDeviceInfoNew() already takes care of calling it for you. + */ void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) { - VIR_FREE(info->alias); - memset(&info->addr, 0, sizeof(info->addr)); info->type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; + memset(&info->addr, 0, sizeof(info->addr)); + + VIR_FREE(info->alias); VIR_FREE(info->romfile); VIR_FREE(info->loadparm); } =20 +/** + * virDomainDeviceInfoCopy: + * @dst: destination virDomainDeviceInfo + * @src: source virDomainDeviceInfo + * + * Perform a deep copy of @src into @dst. + * + * Return: 0 on success, <0 on failure + */ int virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, virDomainDeviceInfoPtr src) { - /* Assume that dst is already cleared */ + /* Clear the destination */ + virDomainDeviceInfoClear(dst); =20 /* first a shallow copy of *everything* */ *dst =3D *src; @@ -77,10 +100,11 @@ virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, void virDomainDeviceInfoFree(virDomainDeviceInfoPtr info) { - if (info) { - virDomainDeviceInfoClear(info); - VIR_FREE(info); - } + if (!info) + return; + + virDomainDeviceInfoClear(info); + VIR_FREE(info); } =20 bool --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list