From nobody Tue May 13 11:17:07 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.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 15326391748761006.2742497139642; Thu, 26 Jul 2018 14:06:14 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 18BFA3086272; Thu, 26 Jul 2018 21:06:13 +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 6410410E4D0C; Thu, 26 Jul 2018 21:06:12 +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 0A1832478B; Thu, 26 Jul 2018 21:06:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL5PS1024874 for ; Thu, 26 Jul 2018 17:05:25 -0400 Received: by smtp.corp.redhat.com (Postfix) id 950C52010CC9; Thu, 26 Jul 2018 21:05:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D73B2010CC4 for ; Thu, 26 Jul 2018 21:05:19 +0000 (UTC) Received: from mail-pl0-f50.google.com (mail-pl0-f50.google.com [209.85.160.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CCD3532B68D for ; Thu, 26 Jul 2018 21:05:15 +0000 (UTC) Received: by mail-pl0-f50.google.com with SMTP id j8-v6so1337776pll.12 for ; Thu, 26 Jul 2018 14:05:15 -0700 (PDT) Received: from centos.localdomain ([42.106.3.93]) by smtp.gmail.com with ESMTPSA id z10-v6sm3279182pfh.83.2018.07.26.14.05.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=XxY5c2iCsyPilXegyQu4kMBpCOxGsrYi9syeBCGb7ZU=; b=edqiSdNvlIvjRKs4ftu1BKQNAtHH8c3u1eICQPCDBQSy/scZA6Tp25w+EM9qGZAEzP Jyq33DWVI+VKksALLEaoCf/tCfTEZexMvAHQovUs3P3jkltdQHDRHg5cNm+e+hht2UFG 9LGMLaOWOtNjLbPdF3sW6kTbyLbM2/0sEHLS5P2p66CgXLYaTWxIFFt5FUY8XiMVl6QK EF2aj4pfSbtUy+F1bewOdRkhYcRXz/xL8OOHiFuLfRKdnRVn5OdlYiDRsHNjklOP7LY9 xf9WY6B+OtFUjbiWGGVNsyE7QjM672MLnYZCKYMvjaJ6zYwRjE2APfzEfCSEUIeGWIVl aJbw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=XxY5c2iCsyPilXegyQu4kMBpCOxGsrYi9syeBCGb7ZU=; b=oRekQyBH31hctSd63tZ3k4PdYYHis2SrnvzB5u2E58lvd7frLuvW5i7rZsomTxiEpR eiQRQ9vzbzoWHSEBc0n2D2n3BO96bdqSMsrY61Alb9SfPVTBEypmwGIOgLtXIogOzodU ZGVTCqhfZEUKXdEXTKUepeSwyRz65gOAoZHB5QjXOaGLARrWzsgSUreS6jt9Q7ylsiom XP2wUpcjVISg8EjcyynZGmMpdLlDQ+90gcNa3Vhhj6yQiSGWrhALTwEi2dNoRJMvFcSs OYT2CUA89VAk0yzhrrFFBSlgXlu8ogDttmHl0H2PyaztuczRtoYIb8Sg+LMmvqTCNfUC m3sA== X-Gm-Message-State: AOUpUlE/sqCzSH8JwT/HCT54+kqVffyTOQxjSL4C0oHo/xp5nyIq3deG x52avebqMLULvxfSdcDaON4pPf3d X-Google-Smtp-Source: AAOMgpcbprvnfALhc13W1T611gtNIA9g6/s2AahDVQgTUgUR6INUwTyBctacWtvMLplazXpDInTiJA== X-Received: by 2002:a17:902:8210:: with SMTP id x16-v6mr3332605pln.307.1532639115023; Thu, 26 Jul 2018 14:05:15 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:20 +0530 Message-Id: <1532447562-24010-20-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> References: <1532447562-24010-1-git-send-email-skrtbhtngr@gmail.com> X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 26 Jul 2018 21:05:19 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Thu, 26 Jul 2018 21:05:19 +0000 (UTC) for IP:'209.85.160.50' DOMAIN:'mail-pl0-f50.google.com' HELO:'mail-pl0-f50.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.39 * (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_WEB, SPF_PASS) 209.85.160.50 mail-pl0-f50.google.com 209.85.160.50 mail-pl0-f50.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 19/41] util: pci: define cleanup function using VIR_DEFINE_AUTOPTR_FUNC 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.49]); Thu, 26 Jul 2018 21:06:13 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Using the new VIR_DEFINE_AUTOPTR_FUNC macro defined in src/util/viralloc.h, define a new wrapper around an existing cleanup function which will be called when a variable declared with VIR_AUTOPTR macro goes out of scope. Also, drop the redundant viralloc.h include, since that has moved from the source module into the header. When variables of types virPCIDevicePtr, virPCIDeviceAddressPtr and virPCIEDeviceInfoPtr are declared using VIR_AUTOPTR, the functions virPCIDeviceFree, virPCIDeviceAddressFree and virPCIEDeviceInfoFree, respectively, will be run automatically on them when they go out of scope. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virpci.c | 7 ++++++- src/util/virpci.h | 7 +++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/util/virpci.c b/src/util/virpci.c index 8d02366..46f9905 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -39,7 +39,6 @@ =20 #include "dirname.h" #include "virlog.h" -#include "viralloc.h" #include "vircommand.h" #include "virerror.h" #include "virfile.h" @@ -3288,3 +3287,9 @@ virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev) VIR_FREE(dev->link_sta); VIR_FREE(dev); } + +void +virPCIDeviceAddressFree(virPCIDeviceAddressPtr address) +{ + VIR_FREE(address); +} diff --git a/src/util/virpci.h b/src/util/virpci.h index 794b7e5..2ac8769 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -28,6 +28,7 @@ # include "virmdev.h" # include "virobject.h" # include "virutil.h" +# include "viralloc.h" =20 typedef struct _virPCIDevice virPCIDevice; typedef virPCIDevice *virPCIDevicePtr; @@ -253,4 +254,10 @@ void virPCIEDeviceInfoFree(virPCIEDeviceInfoPtr dev); ssize_t virPCIGetMdevTypes(const char *sysfspath, virMediatedDeviceType ***types); =20 +void virPCIDeviceAddressFree(virPCIDeviceAddressPtr address); + +VIR_DEFINE_AUTOPTR_FUNC(virPCIDevice, virPCIDeviceFree) +VIR_DEFINE_AUTOPTR_FUNC(virPCIDeviceAddress, virPCIDeviceAddressFree) +VIR_DEFINE_AUTOPTR_FUNC(virPCIEDeviceInfo, virPCIEDeviceInfoFree) + #endif /* __VIR_PCI_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list