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 1533714217224896.1336781780851; Wed, 8 Aug 2018 00:43:37 -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 22E6612C30; Wed, 8 Aug 2018 07:43:35 +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 D58C31001F49; Wed, 8 Aug 2018 07:43:34 +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 6767D3F7CC; Wed, 8 Aug 2018 07:43:34 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787hRb3005538 for ; Wed, 8 Aug 2018 03:43:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5403238192; Wed, 8 Aug 2018 07:43:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4D45D5C480 for ; Wed, 8 Aug 2018 07:43:27 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) (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 3DD615D5EE for ; Wed, 8 Aug 2018 07:43:26 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id e11-v6so662438plb.3 for ; Wed, 08 Aug 2018 00:43:26 -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.23 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:43:24 -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=zD4K7A56pqBMV1DacCHCCui9ATMkWwkbIvMfOiR+stc=; b=LHRiDGGmlTBoa4cobjnh+CFUSqd0jgTCm+JeZ+e8HgEznOKfKCFpJCPQnT/j+1i042 mlnZM9bmad3F5L5AjzpI3cqD1XknMetgzFzqllP/w1ZWrFfxODHoIEgkfEen/Qxr7kDW jnm493HxeIfcz2idHmJBEMN0GU2m+AQWSMS5a6SK9nzM9PmobtbhCeTh1WYL2nnF1yTi KkdhaHTbpEYLb/49gU7klOHxGhAQZSXD6rxs9GHFcSMElTD4cZnmaUBC9Tmliqs+xqks OWJWXTPNs2T2tXQRQuW+G6sp+qAqa9KH2AM+INdL+zg4KB8Q+z56f00jxY5NDPBrLPyc 8EjQ== 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=zD4K7A56pqBMV1DacCHCCui9ATMkWwkbIvMfOiR+stc=; b=uJSS8GF/Sfb/ZrcUjuEVuYAuDLdQGb1Jn6PV3tW+XaWxXisiiOihywKcff3UhLd/tN DWBGrDThKg6IPEs5xCIO3fDA/l6eGAyLUy5E+deBtLXxSWOjP0Ka7TzFCPZeA/UsKska 8sv37agqTZfmyTBhZ3FyMCABWAlYmHB7PAboXkgLE18nJ02Ye/wUy1UtK35VxOZY1lvx GmQ+322eQi6G4CuKg8/XCLGwqKhWW8PVKdmRZYnlaxxGZSL1ouMyeEiKwayoMn9TjD6B tqGXRpU8L5GMFp4HRbIW+lG9JWI/xJ4ZUtb9WsCKw3kij5CGQAhpmfCVoOZ2khQf+GPk hfUw== X-Gm-Message-State: AOUpUlHds8ev02BArapDkj+XT0oNHAV+3tif+MQhAexdIaeYe4GbhD03 jMRWxVOBmn8YLKNgDHZVt6Bebtkd X-Google-Smtp-Source: AA+uWPy2nxbNFUVizqqvOz7Gj4PnWJg99/T2oNeJqD/afWB4MMm89mQqX++J7lkD4gDUDYxXf4Vz0A== X-Received: by 2002:a17:902:1e6:: with SMTP id b93-v6mr1515044plb.149.1533714205355; Wed, 08 Aug 2018 00:43:25 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:35 +0530 Message-Id: <1533501842-24503-9-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.39]); Wed, 08 Aug 2018 07:43:26 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 08 Aug 2018 07:43:26 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.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.160.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 08/35] util: macaddr: 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.26]); Wed, 08 Aug 2018 07:43:35 +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 virMacAddrPtr is declared using VIR_AUTOPTR, the function virMacAddrFree will be run automatically on it when it goes out of scope. Signed-off-by: Sukrit Bhatnagar --- src/util/virmacaddr.c | 6 ++++++ src/util/virmacaddr.h | 4 ++++ 2 files changed, 10 insertions(+) diff --git a/src/util/virmacaddr.c b/src/util/virmacaddr.c index 7afe032..e739775 100644 --- a/src/util/virmacaddr.c +++ b/src/util/virmacaddr.c @@ -252,3 +252,9 @@ virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_= BUFLEN]) { return memcmp(virMacAddrBroadcastAddrRaw, s, sizeof(*s)) =3D=3D 0; } + +void +virMacAddrFree(virMacAddrPtr addr) +{ + VIR_FREE(addr); +} diff --git a/src/util/virmacaddr.h b/src/util/virmacaddr.h index d0dd4a4..39dd51b 100644 --- a/src/util/virmacaddr.h +++ b/src/util/virmacaddr.h @@ -25,6 +25,7 @@ # define __VIR_MACADDR_H__ =20 # include "internal.h" +# include "viralloc.h" =20 # define VIR_MAC_BUFLEN 6 # define VIR_MAC_HEXLEN (VIR_MAC_BUFLEN * 2) @@ -64,5 +65,8 @@ int virMacAddrParseHex(const char* str, bool virMacAddrIsUnicast(const virMacAddr *addr); bool virMacAddrIsMulticast(const virMacAddr *addr); bool virMacAddrIsBroadcastRaw(const unsigned char s[VIR_MAC_BUFLEN]); +void virMacAddrFree(virMacAddrPtr addr); + +VIR_DEFINE_AUTOPTR_FUNC(virMacAddr, virMacAddrFree) =20 #endif /* __VIR_MACADDR_H__ */ --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list