From nobody Sat Feb 7 05:35:25 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 1533714206286472.3031661761639; Wed, 8 Aug 2018 00:43:26 -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 1A1FC307D853; Wed, 8 Aug 2018 07:43:24 +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 D63E51001F45; Wed, 8 Aug 2018 07:43:23 +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 878504A46E; Wed, 8 Aug 2018 07:43:23 +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 w787hKba005488 for ; Wed, 8 Aug 2018 03:43:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 92BC6308BDB2; Wed, 8 Aug 2018 07:43:20 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 850AB308BDA4 for ; Wed, 8 Aug 2018 07:43:17 +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 6A0D012C06 for ; Wed, 8 Aug 2018 07:43:16 +0000 (UTC) Received: by mail-pg1-f196.google.com with SMTP id r1-v6so676621pgp.11 for ; Wed, 08 Aug 2018 00:43:16 -0700 (PDT) Received: from centos.localdomain ([42.106.0.165]) by smtp.gmail.com with ESMTPSA id 9-v6sm9617719pfv.53.2018.08.08.00.43.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:43:15 -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=Rg7cQskX7OhaAp/fQcvaPAyBYmWAzulInACY3dQEalg=; b=TZrXxo4S5cCXJ4ihk04ie/GiFZn6W55roM9LCsdov/g/kAydmhkrdDYBuEvYaB2MZm kdckp6cTxyIBGCgWvfSk6ZkVOQ6S0CuIev6mU4WUj/fwoAbfFhL60Rasqn2KquJ89rRG 8Ow1y8ZVQ1pcsctVpmTuWxXxGgAf6L+8fCPKOLh2GFkcLTjWnnQJMwF6gt6jA8t7w34t 6r74o/g05cyy7koJkZPqvOZfftdfLWzloJ1/fj00p6COSHN9AKxEl9MOop40HK5JOrlK 1pDkDfrYb+eFt6NfgyCgdEtWtE5O7/GVXGyhvBAfE/UFos1+l0g9IWuJg5A9NqVJ9814 UcUQ== 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=Rg7cQskX7OhaAp/fQcvaPAyBYmWAzulInACY3dQEalg=; b=qG5lEm2ux4WhYxCpU8ZVuHCLqQrfMIzcFbimCf2iqP63AnvJ05aCcBSo8w3QcYkk91 ZZeyX2D8E0RivaQ5TCnhu/TwuFMjRMqOua6n556ChnBGURv1LHptzfSxEqGG1NXX29ml g6Jewdn2Ph4/QzLn202Ac2l+tvmVxmSApD3Q+42QNiucLravmyM27ymfAN+z0Gu9ykil VtMNQeUiQmPHOHVjGd6uzhQL3Mmm/9O57qFU3z0IUHFC4WKr7/Oblp5K1w9sBL+Y+DUH GETUwGdYw3mVPaay13BzBifb9IGO0se1luQ9wiOz1JOlj3LaMTJsWUiroDZPPAPAjcdx +OIQ== X-Gm-Message-State: AOUpUlEdvnZnOHv51va4e3SkZjA10DxpUdjO3F8BYEBDvDJ6QfqueCaZ wKnIZ+kVfKxml0oVaGzXyACj63hV X-Google-Smtp-Source: AA+uWPxYzRRoYXU3n3tRSte3Mebojd+TaG0nEqhOAyowXQQaN8jkJQU9CJBzAVUbgazgQAKbA7EE1Q== X-Received: by 2002:a62:4f5b:: with SMTP id d88-v6mr1704890pfb.225.1533714195675; Wed, 08 Aug 2018 00:43:15 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:30 +0530 Message-Id: <1533501842-24503-4-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.26]); Wed, 08 Aug 2018 07:43:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Wed, 08 Aug 2018 07:43:16 +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.26 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 03/35] util: netlink: 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.48]); Wed, 08 Aug 2018 07:43:24 +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. This commit also typedefs virNlMsg to struct nl_msg type for use with the cleanup macros. When pointers to virNlMsg and virNetlinkHandle types are declared using VIR_AUTOPTR, the functions nlmsg_free and virNetlinkFree, respectively, will be run automatically on them when they go out of scope. Signed-off-by: Sukrit Bhatnagar --- src/util/virnetlink.c | 3 ++- src/util/virnetlink.h | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/util/virnetlink.c b/src/util/virnetlink.c index fa1ba3e..1c1eac7 100644 --- a/src/util/virnetlink.c +++ b/src/util/virnetlink.c @@ -38,7 +38,6 @@ #include "virnetlink.h" #include "virnetdev.h" #include "virlog.h" -#include "viralloc.h" #include "virthread.h" #include "virmacaddr.h" #include "virerror.h" @@ -72,6 +71,8 @@ typedef struct nl_handle virNetlinkHandle; typedef struct nl_sock virNetlinkHandle; # endif =20 +VIR_DEFINE_AUTOPTR_FUNC(virNetlinkHandle, virNetlinkFree) + typedef struct _virNetlinkEventSrvPrivate virNetlinkEventSrvPrivate; typedef virNetlinkEventSrvPrivate *virNetlinkEventSrvPrivatePtr; struct _virNetlinkEventSrvPrivate { diff --git a/src/util/virnetlink.h b/src/util/virnetlink.h index 2a9de0a..647f589 100644 --- a/src/util/virnetlink.h +++ b/src/util/virnetlink.h @@ -44,6 +44,9 @@ struct nlmsghdr; =20 # endif /* __linux__ */ =20 +typedef struct nl_msg virNlMsg; +typedef virNlMsg *virNlMsgPtr; + int virNetlinkStartup(void); void virNetlinkShutdown(void); =20 @@ -123,4 +126,6 @@ int virNetlinkEventAddClient(virNetlinkEventHandleCallb= ack handleCB, int virNetlinkEventRemoveClient(int watch, const virMacAddr *macaddr, unsigned int protocol); =20 +VIR_DEFINE_AUTOPTR_FUNC(virNlMsg, nlmsg_free) + #endif /* __VIR_NETLINK_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list