From nobody Tue May 13 11:12:37 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 1532639152567853.9417379812489; Thu, 26 Jul 2018 14:05:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A60DA308226D; Thu, 26 Jul 2018 21:05:50 +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 EE79B3001A72; Thu, 26 Jul 2018 21:05:49 +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 93DAA24F58; Thu, 26 Jul 2018 21:05:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL5dSO024992 for ; Thu, 26 Jul 2018 17:05:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id DBA8D60F8C; Thu, 26 Jul 2018 21:05:39 +0000 (UTC) Received: from mx1.redhat.com (ext-mx06.extmail.prod.ext.phx2.redhat.com [10.5.110.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D0CDA60C80 for ; Thu, 26 Jul 2018 21:05:30 +0000 (UTC) Received: from mail-pg1-f179.google.com (mail-pg1-f179.google.com [209.85.215.179]) (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 8B70B285CF for ; Thu, 26 Jul 2018 21:05:29 +0000 (UTC) Received: by mail-pg1-f179.google.com with SMTP id x5-v6so1879473pgp.7 for ; Thu, 26 Jul 2018 14:05:29 -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.27 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:05:28 -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=KL77s56V9n+FQ8JQbeJabwguLs+NLV2slHGHHmsnOFQ=; b=G0rKsBLs4ht+EGIgFkH/jZDAFSS+7zttA0Wt02Fa6STKSGnXIYSNXZBmHpH9MR1kBx T1wpfozaxO1dsJ4WH9g6bQc3fEbYX0cOK0j+dFM5uKSZU5lZcmsilqFf3z4kYK9cNd04 9jwJcn7+gEKGD2Xs+nBHMmkVvxUjit7AQH05k3f0bTFD6yP8zFZKl7/DxVQ96LFSOmmx ptmp6Sbx6UD5YSDEbxYLDzZplh9b5vGGXmLRp0VkGkrUtw0pRM0OMwuyqDoQ8i/bpQZ6 /oS9u8UmtvQGtTpLuj8Mo1SIJl2+WdpY2t8aocevpvjrv2bzjFOFHX1eArR83kQFR5em +uZw== 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=KL77s56V9n+FQ8JQbeJabwguLs+NLV2slHGHHmsnOFQ=; b=lLlHyiC7BZLp6AWsR31Azr+MmRq3Kex+dlr06UQHz6dwjRc5+0L0A2q7Z6DDLvcmmc SriCe18ZckdfYy2PH0BpuBCUPRflqDsVqxkpLHU1Tu9l1cUN8/Xq1YA+N/j0Q9kYMrEn BF0whSZszA0jd2XCFc0iy2Dc+aH3Sk16V1PKxmkntL7675F2rzfKNPE783mAh9uZtbSh FMCg+UsxiZbkkguukbDt9kr0gLu5gsu4bCp/MkkRt6C39Pzwp+InwMh/97ZE3WunsBjw YyKTZ1tOFiZXTpop5S3yugZsLIhTQhY2xi0smX4FC6FyOrmv1DHNiyRhaUX5IWKS3kvV sZeA== X-Gm-Message-State: AOUpUlE2Juu9RdCI/j34cHeAEjkx0Nhw6uZu+RVCF2zi3x9J0OEePudX LJVjKrheBKUyMutmd57AQlgIoWm6 X-Google-Smtp-Source: AAOMgpcJ69AY9B2FyJI5kwlTQE4pHCreju3XBcIV5HyryBdjaPufwEdsanbrBT4lxWK5PmOV/VXNGw== X-Received: by 2002:a62:864a:: with SMTP id x71-v6mr3728099pfd.252.1532639128808; Thu, 26 Jul 2018 14:05:28 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:27 +0530 Message-Id: <1532447562-24010-27-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.30]); Thu, 26 Jul 2018 21:05:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 26 Jul 2018 21:05:29 +0000 (UTC) for IP:'209.85.215.179' DOMAIN:'mail-pg1-f179.google.com' HELO:'mail-pg1-f179.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.215.179 mail-pg1-f179.google.com 209.85.215.179 mail-pg1-f179.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.30 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 26/41] util: scsi: 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 26 Jul 2018 21:05:51 +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 type virSCSIDevicePtr and virUsedByInfoPtr are declared using VIR_AUTOPTR, the functions virSCSIDeviceFree and virSCSIDeviceUsedByInfoFree, respectively, will be run automatically on them when they go out of scope. This commit also adds an intermediate typedef for virUsedByInfo type for use with the cleanup macros. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virscsi.c | 5 +++-- src/util/virscsi.h | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util/virscsi.c b/src/util/virscsi.c index b51103a..33292f6 100644 --- a/src/util/virscsi.c +++ b/src/util/virscsi.c @@ -37,7 +37,6 @@ =20 #include "virlog.h" #include "virscsi.h" -#include "viralloc.h" #include "virfile.h" #include "virutil.h" #include "virstring.h" @@ -54,7 +53,8 @@ struct _virUsedByInfo { char *drvname; /* which driver */ char *domname; /* which domain */ }; -typedef struct _virUsedByInfo *virUsedByInfoPtr; +typedef struct _virUsedByInfo virUsedByInfo; +typedef virUsedByInfo *virUsedByInfoPtr; =20 struct _virSCSIDevice { unsigned int adapter; @@ -264,6 +264,7 @@ virSCSIDeviceUsedByInfoFree(virUsedByInfoPtr used_by) VIR_FREE(used_by->domname); VIR_FREE(used_by); } +VIR_DEFINE_AUTOPTR_FUNC(virUsedByInfo, virSCSIDeviceUsedByInfoFree) =20 void virSCSIDeviceFree(virSCSIDevicePtr dev) diff --git a/src/util/virscsi.h b/src/util/virscsi.h index 9f8b3ec..b96d862 100644 --- a/src/util/virscsi.h +++ b/src/util/virscsi.h @@ -26,6 +26,7 @@ =20 # include "internal.h" # include "virobject.h" +# include "viralloc.h" =20 typedef struct _virSCSIDevice virSCSIDevice; typedef virSCSIDevice *virSCSIDevicePtr; @@ -95,4 +96,6 @@ void virSCSIDeviceListDel(virSCSIDeviceListPtr list, virSCSIDevicePtr virSCSIDeviceListFind(virSCSIDeviceListPtr list, virSCSIDevicePtr dev); =20 +VIR_DEFINE_AUTOPTR_FUNC(virSCSIDevice, virSCSIDeviceFree) + #endif /* __VIR_SCSI_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list