From nobody Wed May 14 01:32:38 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 1527627652411911.4484053224897; Tue, 29 May 2018 14:00:52 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C4C9030CE670; Tue, 29 May 2018 21:00:49 +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 78771174BD; Tue, 29 May 2018 21:00:49 +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 1A6204CA84; Tue, 29 May 2018 21:00:49 +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 w4TL0cUP023416 for ; Tue, 29 May 2018 17:00:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9C95397399; Tue, 29 May 2018 21:00:38 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93250977D8 for ; Tue, 29 May 2018 21:00:38 +0000 (UTC) Received: from mail-pg0-f48.google.com (mail-pg0-f48.google.com [74.125.83.48]) (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 ACEA430B9090 for ; Tue, 29 May 2018 21:00:27 +0000 (UTC) Received: by mail-pg0-f48.google.com with SMTP id z1-v6so182136pgv.12 for ; Tue, 29 May 2018 14:00:27 -0700 (PDT) Received: from centos.localdomain ([49.32.89.162]) by smtp.gmail.com with ESMTPSA id v6-v6sm52176763pfm.120.2018.05.29.14.00.24 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 29 May 2018 14:00:26 -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=fGd1VkabJB4Eq3ASDJMhI5jqRQWH42tCX8wUWPvduDg=; b=PyetUlRv5nes9kRuwRcAVbiiaKh2DSEeupjD7EP9xl69i+uPdoivj9A5tFHCeW3Uui mp9pUay+Y7MzkNqQa2/wVyiwgJ6ZGfDEPY8kWBwuK8jiIxz3Prmuk5Auo2gp7tex0THb dCWG6qzmrF2eHe5Gy9nQ1XTkR5EgedDUWI9jzv0twzigQ2excigoi14kzmLhQjYDrbli RlVc5KHd2m6t0TKE9n5oEz8xUB8p9ghcdaE1Avw2JMkZytmzIzMQpFdQbnEBYd5MwvBg YTXLCgx9sO37jWpY4gmAm2qlt4S2y95ALBLtvVi9ueqNBN5nayY5p3yFI7MQfHjpefY3 6hOQ== 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=fGd1VkabJB4Eq3ASDJMhI5jqRQWH42tCX8wUWPvduDg=; b=RzqJw/JnA14rOOa2WBXS3JLzfHQwVL+98z5br5x+hUTlUgd5BNeeiCJuK58FLTNW5n kzh0c/yIeTKZ08XSIASx5VEzRLrRtTe/7dfWVWDR+/N8yBD/ldnOK9LOvGGfXN1BiYJG mopV7eJrCco/0PWXNZxhl0leh59UOT6LUU0JD2mGkSJJ3L7Tw2+3ceX/OGnFveN3N0L2 s/+P+qbkhzGex6fZ0gC/2tSMzxrnPKMPnoMuDNJJu8f1Y/KbwIYRW9PlBmPc/ngPama3 h9AkTOPTiqm2pgNAfXYR53BtodiCN3DPqy20doU4didiYDmv2gYcxj/X+oCa11hZ4/UN olAw== X-Gm-Message-State: ALKqPwfyhBqi3DL9vf8C1qKA8CgPIF90Jmv+Meuz0zOXdtDdRvieqIUq 1toY3MqrsnzWK0FEQ2eAWg/5LjUz X-Google-Smtp-Source: ADUXVKJQhk/IOzhyof1RufMqeqkejx63vlL9zqfERz4pdJmA91zTkJDYtjX0nROg8FDRVtj/ZEjA7A== X-Received: by 2002:a63:7d43:: with SMTP id m3-v6mr3525pgn.117.1527627626929; Tue, 29 May 2018 14:00:26 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Wed, 30 May 2018 02:30:05 +0530 Message-Id: <1527627607-15698-3-git-send-email-skrtbhtngr@gmail.com> In-Reply-To: <1527627607-15698-1-git-send-email-skrtbhtngr@gmail.com> References: <1527627607-15698-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.47]); Tue, 29 May 2018 21:00:27 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Tue, 29 May 2018 21:00:27 +0000 (UTC) for IP:'74.125.83.48' DOMAIN:'mail-pg0-f48.google.com' HELO:'mail-pg0-f48.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.48 mail-pg0-f48.google.com 74.125.83.48 mail-pg0-f48.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [RFC 2/4] add automatic cleanup support in src/util/virarptable.c 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Tue, 29 May 2018 21:00:50 +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" Modifiy code to use cleanup macros where required. Signed-off-by: Sukrit Bhatnagar --- src/util/virarptable.c | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/util/virarptable.c b/src/util/virarptable.c index c0e90dc..f53a479 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; @@ -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]) { @@ -155,13 +153,10 @@ virArpTableGet(void) } =20 end_of_netlink_messages: - VIR_FREE(nlData); return table; =20 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