From nobody Mon Feb 9 15:08:19 2026 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 1533714264847757.0506683359512; Wed, 8 Aug 2018 00:44:24 -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 04DE065CFC; Wed, 8 Aug 2018 07:44:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A71E3001A65; Wed, 8 Aug 2018 07:44:21 +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 1C2ED1800BDD; Wed, 8 Aug 2018 07:44:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787iF9i005928 for ; Wed, 8 Aug 2018 03:44:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id D005E27BD1; Wed, 8 Aug 2018 07:44:15 +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 C3035277D0 for ; Wed, 8 Aug 2018 07:44:12 +0000 (UTC) Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) (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 38E582D1D5 for ; Wed, 8 Aug 2018 07:44:11 +0000 (UTC) Received: by mail-pf1-f172.google.com with SMTP id y10-v6so715419pfn.8 for ; Wed, 08 Aug 2018 00:44:11 -0700 (PDT) Received: from centos.localdomain ([42.106.0.165]) by smtp.gmail.com with ESMTPSA id 9-v6sm9617719pfv.53.2018.08.08.00.44.08 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:44:09 -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=Thq8OLUUQPp60sfKqBOUqk77DJ+XR1qW0yRh+Ipl8NY=; b=HXl/NsbwH7gKByT/gJXEMIYxsfo4c10qf9PvahJdANYjVMkpB8XzBz6z2xZk1H+kWn sTW5dA1q782rnAwjOMB+5evsf1DrBH+FMm18z8IpbkEmrx2j/HBqMuS8+PGo16eSMnxt isiWUNgS7iBJUM4X09STGF2H84IsnWt19RMStereNZZf7qhxEELKTu6FCBetkX8jL3PN VFb44u96bo7kDWZTKB4THAqtnn6QtGRBeUV7YJVx2RzgDkG7ZHCpLPtkmVv5CYEPrnuk rBzmEmPWg+rm8Sr8C7UKHDQ0KVjSB4zDNDhiQBBkICwMOkU/5oqqlIoh9XsZHdu7OU5A YFvA== 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=Thq8OLUUQPp60sfKqBOUqk77DJ+XR1qW0yRh+Ipl8NY=; b=eJ/j4pGK8ADOiaDy+wDrTJrhrg8CBlTtnfCwc9GWi5drL+hvkaFaDF212+Js6rrutH 5nxsgSLF/OL35KREYKrgxZw/I3d7q2azw+0dF3sSCFm2MbBSI/Mjg1R31En5fcTHUqmO fhZ6j80j1Y8pavDWwPbNp+fhF+ooME6794Nnl6YMNSOZBVMqqn+dWE3HQz156Z2Hj7vj vfaulIttPVTOQ7pCtR01NvJKq86Gl1NQPtJ2bHrKNXRH9Q/c0VxEisu0pfaiSqKothAI YMD/OI4QGgo6WU6JpSSFy7MIB7xnIK/B9DpnV70U1tgai4w8tQMrCs6xB50lWP8cDDPH GQ9w== X-Gm-Message-State: AOUpUlG98Ulul6hOAxGBldGP0mqB/ieyYH7WJqkuyYUEPJQCoZYcLOed SKZV9yKPYqBBMIC3wUJobx3btaxt X-Google-Smtp-Source: AA+uWPx/mW72B77kccVIIu+lqeacZcdJUAWUe1KLC31GkGuneMttiVQanD5i98ylTbyd1T+d4HTjnQ== X-Received: by 2002:a65:5304:: with SMTP id m4-v6mr1440560pgq.250.1533714250437; Wed, 08 Aug 2018 00:44:10 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:56 +0530 Message-Id: <1533501842-24503-30-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1533501842-24503-1-git-send-email-skrtbhtngr@gmail.com> References: <1533501842-24503-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]); Wed, 08 Aug 2018 07:44:11 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 08 Aug 2018 07:44:11 +0000 (UTC) for IP:'209.85.210.172' DOMAIN:'mail-pf1-f172.google.com' HELO:'mail-pf1-f172.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.172 mail-pf1-f172.google.com 209.85.210.172 mail-pf1-f172.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 29/35] util: perf: 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.38]); Wed, 08 Aug 2018 07:44:23 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 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 virPerfPtr is declared using VIR_AUTOPTR, the function virPerfFree will be run automatically on it when it goes out of scope. This commit also adds an intermediate typedef for virPerf type for use with the cleanup macros. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virperf.c | 3 +-- src/util/virperf.h | 8 ++++++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/util/virperf.c b/src/util/virperf.c index 2c832b3..4537cd0 100644 --- a/src/util/virperf.c +++ b/src/util/virperf.c @@ -26,7 +26,6 @@ #endif =20 #include "virperf.h" -#include "viralloc.h" #include "virerror.h" #include "virlog.h" #include "virfile.h" @@ -61,7 +60,7 @@ struct virPerfEvent { }; typedef struct virPerfEvent *virPerfEventPtr; =20 -struct virPerf { +struct _virPerf { struct virPerfEvent events[VIR_PERF_EVENT_LAST]; }; =20 diff --git a/src/util/virperf.h b/src/util/virperf.h index eee7a03..9d0d5ac 100644 --- a/src/util/virperf.h +++ b/src/util/virperf.h @@ -23,6 +23,7 @@ # define __VIR_PERF_H__ =20 # include "virutil.h" +# include "viralloc.h" =20 /* Some Intel processor families introduced some RDT (Resource Director * Technology) features to monitor or control shared resource based on @@ -62,8 +63,9 @@ typedef enum { =20 VIR_ENUM_DECL(virPerfEvent); =20 -struct virPerf; -typedef struct virPerf *virPerfPtr; +struct _virPerf; +typedef struct _virPerf virPerf; +typedef virPerf *virPerfPtr; =20 virPerfPtr virPerfNew(void); =20 @@ -83,4 +85,6 @@ int virPerfReadEvent(virPerfPtr perf, virPerfEventType type, uint64_t *value); =20 +VIR_DEFINE_AUTOPTR_FUNC(virPerf, virPerfFree) + #endif /* __VIR_PERF_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list