From nobody Sun Feb 8 07:07:40 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 1532806879141130.42631729673144; Sat, 28 Jul 2018 12:41:19 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F6F0C0587C9; Sat, 28 Jul 2018 19:41:17 +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 B770C308BDB3; Sat, 28 Jul 2018 19:41:16 +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 6E1DF3FCC3; Sat, 28 Jul 2018 19:41:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6SJf8bH020533 for ; Sat, 28 Jul 2018 15:41:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3A4E3CFBF7; Sat, 28 Jul 2018 19:41:08 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 32782C64D5 for ; Sat, 28 Jul 2018 19:41:07 +0000 (UTC) Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) (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 403DE300175D for ; Sat, 28 Jul 2018 19:41:06 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id a26-v6so2883019pfo.4 for ; Sat, 28 Jul 2018 12:41:06 -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.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:41:05 -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=DIlvjd577YULIxeszamBnLEZywKZdXziClQO6akbe0Y=; b=tnxwUlXGh6ogU7su8r7mBZ/C5EfniVm1hpyCClcBQ4nKsKNt437Y3iZ3GxjTiTndCa J65qlziaSzKi96I/nSk31v/zO9/iXuF1H8QCpL4HF5qmM4Y9Wh5y5YDwgrfI6OAtSalF dMUL6fvFN1rEjgwnxhGV8o5yblNrZ2sUGzKmxKX0U8tfIVjrzbwwSXZVQUSxJ5qT/xLW zDXU+0zK0rQGkvNfiufM+eGf9sdf42IsiS4Sj26GiGca4B5cokJJelYGxnInDuZAxn8j cWij9fd8ORmihMIYlGmiI08KmZJ9NVupIKAKkMCZy4E1D2Ka6uxf4F//1Wug+cBkfzfW MFuQ== 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=DIlvjd577YULIxeszamBnLEZywKZdXziClQO6akbe0Y=; b=ubPsL4QonOxVmIJg8wZx7Ld1jtCFH8NNw3Idt+ZqeTE5JJg82y+fPHMbdPNH/vhNwE AyPNVSOT1JKWCl4vQ4CXuzfjteeMfpzdq0Wnb9It0AH7xJ7ruDBE8BCIAKTP06kxTb7Q zf+ZhB48X7zyCYwK9VAbOkcynDZbV+C5vxawWAiWOCuazNz0LfRyGzfpNzdVR3pPPFCD 2SSxn6siJkBYFfvNuUffX3roDuT00Ipl6amVZWiJa7NqgOTDn4YEfpJSxOT3iNpJoS61 YvIhPegP6zX809MtwyS6SKHeiETz60ZrwYgxVMXz0bvYVq9vFqvzBQNBXRzuQpYvfrz1 p7BQ== X-Gm-Message-State: AOUpUlFuvkQY2ZFUabiHcV7pFO4DQMyI4pXVn8cVSEy+oPoid8Bfvi+k y5RHWZGqxQsgTKXG649yHyszd0xj X-Google-Smtp-Source: AAOMgpfNXtg9EdASewS+VSF7gz0gPJg8NP/iUrlafy+XsTzxxRS5V77Nd1/wA/eBCKF5ECEto5F4Mw== X-Received: by 2002:a62:2744:: with SMTP id n65-v6mr11768124pfn.125.1532806865514; Sat, 28 Jul 2018 12:41:05 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:31 +0530 Message-Id: <1532800907-29115-17-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.46]); Sat, 28 Jul 2018 19:41:06 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Sat, 28 Jul 2018 19:41:06 +0000 (UTC) for IP:'209.85.210.180' DOMAIN:'mail-pf1-f180.google.com' HELO:'mail-pf1-f180.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.180 mail-pf1-f180.google.com 209.85.210.180 mail-pf1-f180.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 16/32] util: netdevmacvlan: use VIR_AUTOPTR for aggregate types 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.24 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sat, 28 Jul 2018 19:41:17 +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" By making use of GNU C's cleanup attribute handled by the VIR_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions can be dropped, which in turn leads to getting rid of most of our cleanup sections. Signed-off-by: Sukrit Bhatnagar Reviewed-by: Erik Skultety --- src/util/virnetdevmacvlan.c | 28 ++++++++++++---------------- 1 file changed, 12 insertions(+), 16 deletions(-) diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index a2ed65c..d01e5ef 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -898,19 +898,20 @@ virNetDevMacVLanVPortProfileRegisterCallback(const ch= ar *ifname, virNetDevVPortProfilePtr virt= PortProfile, virNetDevVPortProfileOp vmOp) { - virNetlinkCallbackDataPtr calld =3D NULL; + VIR_AUTOPTR(virNetlinkCallbackData) calld =3D NULL; + virNetlinkCallbackDataPtr temp ATTRIBUTE_UNUSED =3D NULL; =20 if (virtPortProfile && virNetlinkEventServiceIsRunning(NETLINK_ROUTE))= { if (VIR_ALLOC(calld) < 0) - goto error; + return -1; if (VIR_STRDUP(calld->cr_ifname, ifname) < 0) - goto error; + return -1; if (VIR_ALLOC(calld->virtPortProfile) < 0) - goto error; + return -1; memcpy(calld->virtPortProfile, virtPortProfile, sizeof(*virtPortPr= ofile)); virMacAddrSet(&calld->macaddress, macaddress); if (VIR_STRDUP(calld->linkdev, linkdev) < 0) - goto error; + return -1; memcpy(calld->vmuuid, vmuuid, sizeof(calld->vmuuid)); =20 calld->vmOp =3D vmOp; @@ -918,14 +919,12 @@ virNetDevMacVLanVPortProfileRegisterCallback(const ch= ar *ifname, if (virNetlinkEventAddClient(virNetDevMacVLanVPortProfileCallback, virNetDevMacVLanVPortProfileDestroyCa= llback, calld, macaddress, NETLINK_ROUTE) < 0) - goto error; + return -1; } =20 + VIR_STEAL_PTR(temp, calld); + return 0; - - error: - virNetlinkCallbackDataFree(calld); - return -1; } =20 =20 @@ -1184,9 +1183,9 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char= *ifname, } =20 if (mode =3D=3D VIR_NETDEV_MACVLAN_MODE_PASSTHRU) { - virMacAddrPtr MAC =3D NULL; - virMacAddrPtr adminMAC =3D NULL; - virNetDevVlanPtr vlan =3D NULL; + VIR_AUTOPTR(virMacAddr) MAC =3D NULL; + VIR_AUTOPTR(virMacAddr) adminMAC =3D NULL; + VIR_AUTOPTR(virNetDevVlan) vlan =3D NULL; =20 if ((virNetDevReadNetConfig(linkdev, -1, stateDir, &adminMAC, &vlan, &MAC) =3D=3D 0) && @@ -1194,9 +1193,6 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char= *ifname, =20 ignore_value(virNetDevSetNetConfig(linkdev, -1, adminMAC, vlan, MAC, !!vlan= )); - VIR_FREE(MAC); - VIR_FREE(adminMAC); - virNetDevVlanFree(vlan); } } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list