From nobody Tue May 13 22:20:02 2025 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 1528400114854616.593848645538; Thu, 7 Jun 2018 12:35:14 -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 21B903683B; Thu, 7 Jun 2018 19:35:13 +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 D2379A1433; Thu, 7 Jun 2018 19:35:12 +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 762284CA80; Thu, 7 Jun 2018 19:35:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w57JZAJV018895 for ; Thu, 7 Jun 2018 15:35:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 98036679C4; Thu, 7 Jun 2018 19:35:10 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8F906679D0 for ; Thu, 7 Jun 2018 19:35:08 +0000 (UTC) Received: from mail-pg0-f46.google.com (mail-pg0-f46.google.com [74.125.83.46]) (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 1136183F42 for ; Thu, 7 Jun 2018 19:34:57 +0000 (UTC) Received: by mail-pg0-f46.google.com with SMTP id 15-v6so5230754pge.2 for ; Thu, 07 Jun 2018 12:34:57 -0700 (PDT) Received: from centos.localdomain ([49.32.106.159]) by smtp.gmail.com with ESMTPSA id d23-v6sm86686407pfn.3.2018.06.07.12.34.53 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Jun 2018 12:34:55 -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=3qmEoRH7FJ1Vph2O+isaAbNFFoDo+bOUMmmv1thaLpU=; b=Zqg5QZEZ7c702eqj7r9E700MElIIFoU1EbcKnD6eZ6Eq7U9rfTTBkqyBJDTgzXlm3U fPDiIjgyYHH4JQUUSO5GvHKkwEP2frDVT8dg07Byu2oQkdQHD3NZbVO6BmFrIxiR/5/x 2rvQ+sW0z8QpsWeH/KWHPYdhCoh+QcqT2Oi+YAndq2FuqD2poITjn+9KsqaJTu4rtCnA B0Y0nTjk6IirOZtoAGNxFU1FY7wAEAF6DN6RAbqBCUhgjjRl2jOr5bqxdra3ZFSkcfjF stNdWMs/9GPIAe7KXG2G6sDRUvEQJKOW1iALO9L/mu1PWXawa/xo2hb/q7IqTY7bhj/G gbaw== 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=3qmEoRH7FJ1Vph2O+isaAbNFFoDo+bOUMmmv1thaLpU=; b=FfEyxXKcYEohE62s6QMf8ezsD/KhTA7i7FIJptkCgenw5HgFdGR26UHXmY5F8KJ/iB H5uCtkCYcUL+mDjgikvOd4IEL8ZJ8gAH/RT4LZC5UFCOE1gZU1yPAoi7vJHo3ZoHwYyU jDP1kyIy/mY7kO2DHNMshAOFrvBAx0Jz/f1NFQXTub2VmpZje2ZSaodsx58AlBFrbzzU W0ww1LR1pyrMMGMxK/3N6losAdGUJamPTKUXNTdC5ToT+A9jO2EF/NPFrlb3u6utQpt7 jdlR6/nC45ZNZbmIC0DFgQArfTt5CGIonSRmmsEonL8G0uwpFpbmuAOthiZdN53Mgwu6 SHig== X-Gm-Message-State: APt69E1uSy4D6Aa1pJ9sieAuJIaVu+VxV0ljIx8O6SnsA6xJlEbcc7D/ K7YyCyXvq6GOmrHF/NK1PzdjP62b X-Google-Smtp-Source: ADUXVKIc9oZ5pCgufl7xjA0PGcxgYRZWqGmWfBXK3LItPlynScGiUBI2zHOYZniuRM9SZF5l1WOueg== X-Received: by 2002:a62:4556:: with SMTP id s83-v6mr2968959pfa.73.1528400096198; Thu, 07 Jun 2018 12:34:56 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Fri, 8 Jun 2018 01:04:24 +0530 Message-Id: <1528400083-6788-3-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1528400083-6788-1-git-send-email-skrtbhtngr@gmail.com> References: <1528400083-6788-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.27]); Thu, 07 Jun 2018 19:34:57 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 07 Jun 2018 19:34:57 +0000 (UTC) for IP:'74.125.83.46' DOMAIN:'mail-pg0-f46.google.com' HELO:'mail-pg0-f46.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.301 * (DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, SPF_PASS, T_DKIM_INVALID) 74.125.83.46 mail-pg0-f46.google.com 74.125.83.46 mail-pg0-f46.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 02/21] util: arptable: use VIR_AUTOFREE instead of VIR_FREE for scalar 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.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 07 Jun 2018 19:35:13 +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 the GCC's __attribute__((cleanup)) handled by VIR_AUTOFREE macro, majority of the VIR_FREE calls can be dropped, which in turn leads to getting rid of most of our cleanup sections. --- src/util/virarptable.c | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index c0e90dc..bf40267 100644 --- a/src/util/virarptable.c +++ b/src/util/virarptable.c @@ -71,9 +71,8 @@ virArpTableGet(void) { int num =3D 0; int msglen; - void *nlData =3D NULL; + VIR_AUTOFREE(void *) nlData =3D NULL; virArpTablePtr table =3D NULL; - char *ipstr =3D NULL; struct nlmsghdr* nh; struct rtattr * tb[NDA_MAX+1]; =20 @@ -89,6 +88,7 @@ virArpTableGet(void) VIR_WARNINGS_NO_CAST_ALIGN for (; NLMSG_OK(nh, msglen); nh =3D NLMSG_NEXT(nh, msglen)) { VIR_WARNINGS_RESET + VIR_AUTOFREE(char *) ipstr =3D NULL; struct ndmsg *r =3D NLMSG_DATA(nh); int len =3D nh->nlmsg_len; void *addr; @@ -108,7 +108,7 @@ virArpTableGet(void) continue; =20 if (nh->nlmsg_type =3D=3D NLMSG_DONE) - goto end_of_netlink_messages; + return table; =20 VIR_WARNINGS_NO_CAST_ALIGN parse_rtattr(tb, NDA_MAX, NDA_RTA(r), @@ -134,8 +134,6 @@ virArpTableGet(void) =20 if (VIR_STRDUP(table->t[num].ipaddr, ipstr) < 0) goto cleanup; - - VIR_FREE(ipstr); } =20 if (tb[NDA_LLADDR]) { @@ -154,14 +152,8 @@ virArpTableGet(void) } } =20 - end_of_netlink_messages: - VIR_FREE(nlData); - return table; - cleanup: virArpTableFree(table); - VIR_FREE(ipstr); - VIR_FREE(nlData); return NULL; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list