From nobody Tue May 13 11:09:59 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 1532639159058329.46085366541695; Thu, 26 Jul 2018 14:05:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6D0BFD3C38; Thu, 26 Jul 2018 21:05:46 +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 3456A608F8; Thu, 26 Jul 2018 21:05:46 +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 D154824F67; Thu, 26 Jul 2018 21:05:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6QL4t7J024706 for ; Thu, 26 Jul 2018 17:04:55 -0400 Received: by smtp.corp.redhat.com (Postfix) id 937F961D3D; Thu, 26 Jul 2018 21:04:55 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8C50661D3B for ; Thu, 26 Jul 2018 21:04:55 +0000 (UTC) Received: from mail-pl0-f52.google.com (mail-pl0-f52.google.com [209.85.160.52]) (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 234A183F45 for ; Thu, 26 Jul 2018 21:04:54 +0000 (UTC) Received: by mail-pl0-f52.google.com with SMTP id z7-v6so1336756plo.9 for ; Thu, 26 Jul 2018 14:04:54 -0700 (PDT) Received: from centos.localdomain ([42.106.3.93]) by smtp.gmail.com with ESMTPSA id z10-v6sm3279182pfh.83.2018.07.26.14.04.51 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 26 Jul 2018 14:04:52 -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=eGbyno/af3AbJ/g+LvLGvmuzg1t8FMG7l8hqzRxTTTs=; b=mT7geSw/532BGcUsrxVHMJb8rLwRTszXQoggmovwnG2we/HHbs8P/qmCpetY0lNZ1t S6E97qy8BMvxVSOfq/08edy6udb8SyxgVV8LI+ZhvsEqFYrDYX5oRTFbm/Ty7qDQFr9S ZIyR/W3Qf7CaMIZ0fDlfRH0WMicv6vXAb3YPv9kxOQ5Rg5tU7CJ6malB0Rz/scsI0IJm yoeGljfq8NtvyXtFEm4aW5dxdaSaKn+xKEqMIKQc+7SoIrCpRwipB56Eg78Q7N0ptA2K CzRT1QCA3pUvfcC4I4r9EX7zEu6b8pdw1EyqQcBDqB36UBkKKSzmqHwF5cmn1C4KX2u7 PxtQ== 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=eGbyno/af3AbJ/g+LvLGvmuzg1t8FMG7l8hqzRxTTTs=; b=TxjPHvkkaWfpK5nvMSGU4tfPNdI/vrX26MuEkFPYZl1wtzJRYVGgGymcfk3CMBG8Mw JeESinaPi2lcS/addyVl59w1pFGTI+vr5gzkES8WYWXoz+EruJTW1CXEOCJ194kew5Vw EwoTBSUqQGcTYW6cyCT2xf6vWjWPlN2bn9267je5ZCL5hde3mtOeiZ+eWk2Etx8vUxFA PwDHDWYm2M4eevpzUcQ+L9Ar8TfaF6qzS8XMjnqCP104+kGX/YmuP8Tb7HltdrLSzI+2 /sBTaXhFywTcbOkjLJq84EqET38lrKv03e6ypohIDRS9jjTEDimuItEIN/qevLF6QeHS /xuw== X-Gm-Message-State: AOUpUlGeqxHNGSnGAUOo4U2gq7ez6+2ecX3WsHXjCeWDvj347MEwCo9f EjZf2UhgeQs4YNyQFLj9zXjDq23C X-Google-Smtp-Source: AAOMgpdvr/izhnPlcvBgMvicjR25xINhSxr6ufZHUMFU3p7xEXKKFPY4OEo72FyouL+ZIAMNTy4tNw== X-Received: by 2002:a17:902:f83:: with SMTP id 3-v6mr3341658plz.282.1532639093390; Thu, 26 Jul 2018 14:04:53 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Tue, 24 Jul 2018 21:22:09 +0530 Message-Id: <1532447562-24010-9-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.27]); Thu, 26 Jul 2018 21:04:54 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 26 Jul 2018 21:04:54 +0000 (UTC) for IP:'209.85.160.52' DOMAIN:'mail-pl0-f52.google.com' HELO:'mail-pl0-f52.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.52 mail-pl0-f52.google.com 209.85.160.52 mail-pl0-f52.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 08/41] util: cgroup: 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.79 on 10.5.11.13 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:56 +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 a variable of type virCgroupPtr is declared using VIR_AUTOPTR, the function virCgroupFree will be run automatically on it when it goes out of scope. This commit also adds an intermediate typedef for virCgroup type for use with the cleanup macros. Signed-off-by: Sukrit Bhatnagar --- src/util/vircgroup.c | 1 - src/util/vircgroup.h | 9 +++++++-- src/util/vircgrouppriv.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 140b016..bc5f774 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -50,7 +50,6 @@ #include "vircgrouppriv.h" =20 #include "virutil.h" -#include "viralloc.h" #include "virerror.h" #include "virlog.h" #include "virfile.h" diff --git a/src/util/vircgroup.h b/src/util/vircgroup.h index e4ffd57..065861d 100644 --- a/src/util/vircgroup.h +++ b/src/util/vircgroup.h @@ -27,9 +27,11 @@ =20 # include "virutil.h" # include "virbitmap.h" +# include "viralloc.h" =20 -struct virCgroup; -typedef struct virCgroup *virCgroupPtr; +struct _virCgroup; +typedef struct _virCgroup virCgroup; +typedef virCgroup *virCgroupPtr; =20 enum { VIR_CGROUP_CONTROLLER_CPU, @@ -297,4 +299,7 @@ int virCgroupSetOwner(virCgroupPtr cgroup, int virCgroupHasEmptyTasks(virCgroupPtr cgroup, int controller); =20 bool virCgroupControllerAvailable(int controller); + +VIR_DEFINE_AUTOPTR_FUNC(virCgroup, virCgroupFree) + #endif /* __VIR_CGROUP_H__ */ diff --git a/src/util/vircgrouppriv.h b/src/util/vircgrouppriv.h index 722863e..a72bee1 100644 --- a/src/util/vircgrouppriv.h +++ b/src/util/vircgrouppriv.h @@ -42,7 +42,7 @@ struct virCgroupController { char *placement; }; =20 -struct virCgroup { +struct _virCgroup { char *path; =20 struct virCgroupController controllers[VIR_CGROUP_CONTROLLER_LAST]; --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list