From nobody Tue May 13 18:42:46 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 1530481545052133.8545145033147; Sun, 1 Jul 2018 14:45:45 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0772C059B7A; Sun, 1 Jul 2018 21:45:43 +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 9EAE24B7; Sun, 1 Jul 2018 21:45:43 +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 2EA10EFD2; Sun, 1 Jul 2018 21:45:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w61LjRqY009600 for ; Sun, 1 Jul 2018 17:45:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id BAAE71001925; Sun, 1 Jul 2018 21:45:27 +0000 (UTC) Received: from mx1.redhat.com (ext-mx13.extmail.prod.ext.phx2.redhat.com [10.5.110.42]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A9888100164E for ; Sun, 1 Jul 2018 21:45:27 +0000 (UTC) Received: from mail-pf0-f195.google.com (mail-pf0-f195.google.com [209.85.192.195]) (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 D663B308212C for ; Sun, 1 Jul 2018 21:45:16 +0000 (UTC) Received: by mail-pf0-f195.google.com with SMTP id j3-v6so6524985pfh.11 for ; Sun, 01 Jul 2018 14:45:16 -0700 (PDT) Received: from centos.localdomain ([157.37.164.55]) by smtp.gmail.com with ESMTPSA id v68-v6sm15006933pfv.143.2018.07.01.14.45.14 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 01 Jul 2018 14:45: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=aRUeMHF/7MrFY/oGmg8WCmEp385Hz8Tr71SDIPyUS5I=; b=F/n4Ow54SSgz4pv/IrOSVmx3+ixsh8iIm1pHeSzFoem/x5JoAi2RUJwCnPvhAe/whT x4J8rwIOl+zcL/WS41TZkMrHsHpdwlbhts1au3xSzqjJC4GnrT52y6Lx1Lcc6bsp84+r A4/oBAOB1gRasom+mI1Qrzx/uwJ+jor36xrPE+MHQEhfQEMG0X5Hv80HBxaCSaWbdrl8 6lcRBunw/EiWly6Dzz63xVyiI3hDbXGK/pMf0tsrcWEDeS5TuuMMJyuTcLdHnMmaNBTX VQz9qvpQIsKRDylaJ56OoMWvBnjq3Ee3jiivgpwHXNviKd194AzsNuMCYysnsRiM0Q04 448w== 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=aRUeMHF/7MrFY/oGmg8WCmEp385Hz8Tr71SDIPyUS5I=; b=LKTm4iG80u/vbNhbyFHCE/ZD1EOf/ownQQgv4+E3EsbRZ9D5VQQ8XKY1RZjnRdrd9w QCJDqO3vu55bscErLQZaFyKjjoHEpHUuVYyFrIN8kXBoHezAeIvh72pOPNdRjqrjifce QDl/0nFdtN4yH5TrxXLOBeU6KowXXvANJbG+bkQgUh+YfGvkGi8yIGAnALypTnqNeblW u2g4J5CkSa4QP5oQ4DaAAZMcmXWAMfj7i2tNbz+NQhJ6wkLT1rHbWRryw9qSwXBeeu0H wG5yoExCYrvhgVJBd+/e2nG4DnUOKcDiZFsSaR9LQ1qOYQAZoV19h+4AEOYtXYfxdGzV etMg== X-Gm-Message-State: APt69E0Oa0QjJIpO1G+SnWqoJ1MIGkmg/5hN5KiS/PCdOdyFLbGTivFU c+gPW5FVF9WGC0n6gwSizEGsIVSo X-Google-Smtp-Source: AAOMgpdQiOcSRBGIzPyiyukZ4d7dc3cVCn7uKljflv3pdDDkry+pzgLpnDBFr8zXAnmsBI7K+swauw== X-Received: by 2002:a62:6a01:: with SMTP id f1-v6mr6239366pfc.156.1530481516157; Sun, 01 Jul 2018 14:45:16 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 30 Jun 2018 14:30:34 +0530 Message-Id: <1530349239-22049-31-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1530349239-22049-1-git-send-email-skrtbhtngr@gmail.com> References: <1530349239-22049-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.42]); Sun, 01 Jul 2018 21:45:16 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Sun, 01 Jul 2018 21:45:16 +0000 (UTC) for IP:'209.85.192.195' DOMAIN:'mail-pf0-f195.google.com' HELO:'mail-pf0-f195.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: 1.785 * (DATE_IN_PAST_24_48, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, NML_ADSP_CUSTOM_MED, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_PASS, T_DKIM_INVALID) 209.85.192.195 mail-pf0-f195.google.com 209.85.192.195 mail-pf0-f195.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.42 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v3 30/35] 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.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Sun, 01 Jul 2018 21:45:44 +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_AUTOFREE macro for declaring scalar variables, majority of the VIR_FREE calls 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/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