From nobody Sun Feb 8 07:07:42 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 1532806902392567.3999806159457; Sat, 28 Jul 2018 12:41:42 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B1264300177A; Sat, 28 Jul 2018 19:41:40 +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 7CBDCCFC0B; Sat, 28 Jul 2018 19:41:40 +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 2F3A924F63; Sat, 28 Jul 2018 19:41:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6SJfUP5020998 for ; Sat, 28 Jul 2018 15:41:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5C419308BDB3; Sat, 28 Jul 2018 19:41:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 52045308BDB2 for ; Sat, 28 Jul 2018 19:41:30 +0000 (UTC) Received: from mail-pg1-f196.google.com (mail-pg1-f196.google.com [209.85.215.196]) (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 33EE1BDC1 for ; Sat, 28 Jul 2018 19:41:29 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id x5-v6so5074863pgp.7 for ; Sat, 28 Jul 2018 12:41:29 -0700 (PDT) Received: from centos.localdomain ([49.32.98.239]) by smtp.gmail.com with ESMTPSA id m26-v6sm20270426pfi.102.2018.07.28.12.41.26 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:41: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=XYr6Wvs6VRnRK4dTT6xI/ZKGnQ8Js9Ahbhk7/9eUfnk=; b=A6mhh7Ixk6uMCgJPcZQsUytCYDEPr6JSbWQLdJ4zdaiJGcKX28sxRRKFs3vqsUiEuq 5YlfWULn/7GQcICJre8o34xlTzgsrnRhFnUcGWK+bj+QNBYPNPdh7ijN0i4yCIo7jLFO l0rxEmkdXioYICIrGAiI+WJ1jK2WYlLyCeTYMUitWpdfJjV9yr9NOOsQIsDPl94ZFQq6 b9cOv/a8EzA/oKcMV4981lX0BnfdFIaImxdujWqwMfoy2qnk5/m1XMA4bXJRySjsWCnM WNFKkCFvFKZifEko7JgvRnoyjgNtkQmmzVJu2CgYmPQMpK45CUpFDBVzSlD7+qWMHvvc 3mLA== 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=XYr6Wvs6VRnRK4dTT6xI/ZKGnQ8Js9Ahbhk7/9eUfnk=; b=KGAFwrJS1imRfIx8YwibGzLyrbHuc00CsHxWs8M2e6TjSjY19KGknHS9wDm7FBx7PC sn7zFjofEaCyP0rNlJSJPjFK5Cw/qk97L0jc/60os4aMY0hgbpjHFcq8FJ3r0cDyHJDT kFi8eznFJhR/I+ubg/OgPfOHWXUj4B1ZFnoyBt1FWTJAS4QY6Ji1KAME57psPLc02L+I eJ1spilDu2MKtYlKs8Ba8EL0ovyFlLqzCY+TU8Z+5ma+e4xRJA2GcNHlQRsrxsdflwKC f6MT308G20h5ivIzDQQjCMNp0PFuMwiIu6An6Xj5+1zDv34qiYOiQKS+z0rwO3dG6OKJ nHGg== X-Gm-Message-State: AOUpUlFWwzEmbdCzdNy0rtmEXAggVlfMHZb0tXmawwIdRvNFVB7Q5T29 IPHw+d7h7TXXxK0QK05WprtSCXw2 X-Google-Smtp-Source: AAOMgpcE01Wdn2UUV27lawGuo1iXtgANmKELHWOdbx7Twa6Llc5hjclTCJGPnx04qN4lHAj3+w167A== X-Received: by 2002:a62:e30c:: with SMTP id g12-v6mr11808669pfh.25.1532806888505; Sat, 28 Jul 2018 12:41:28 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:41 +0530 Message-Id: <1532800907-29115-27-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1532800907-29115-1-git-send-email-skrtbhtngr@gmail.com> References: <1532800907-29115-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.29]); Sat, 28 Jul 2018 19:41:29 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Sat, 28 Jul 2018 19:41:29 +0000 (UTC) for IP:'209.85.215.196' DOMAIN:'mail-pg1-f196.google.com' HELO:'mail-pg1-f196.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.13 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_PASS) 209.85.215.196 mail-pg1-f196.google.com 209.85.215.196 mail-pg1-f196.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 26/32] 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 28 Jul 2018 19:41:41 +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 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