From nobody Mon Feb 9 15:10:07 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 1533714258855953.5734319313406; Wed, 8 Aug 2018 00:44:18 -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 66DED3084024; Wed, 8 Aug 2018 07:44:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2369E10694F2; Wed, 8 Aug 2018 07:44: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 B9F481800C9C; Wed, 8 Aug 2018 07:44:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787iDov005902 for ; Wed, 8 Aug 2018 03:44:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id D48673083332; Wed, 8 Aug 2018 07:44:13 +0000 (UTC) Received: from mx1.redhat.com (ext-mx15.extmail.prod.ext.phx2.redhat.com [10.5.110.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CA6083083331 for ; Wed, 8 Aug 2018 07:43:58 +0000 (UTC) Received: from mail-pl0-f66.google.com (mail-pl0-f66.google.com [209.85.160.66]) (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 000FF30832D2 for ; Wed, 8 Aug 2018 07:43:57 +0000 (UTC) Received: by mail-pl0-f66.google.com with SMTP id d5-v6so666056pll.4 for ; Wed, 08 Aug 2018 00:43:57 -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.55 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:43:56 -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=yqh5y/xyzAhg8E54Bf49i2GyB9uCe9KG/jTqINVaPbQ=; b=OTmZmvdMdBc+fligSWiB5MTrBxejkkW5CCqrWnCFRxsYT17vuquQEP3zVElK8SkQss UwuLbB0KUpGY39OY2IwezVEuhumLLVYUWjAZEw6KQGk4fTGvycp5+jomgwIelNrrrslA pEmvwZ6WGK2ap8h805sFgD4nMleFB4i6zL8o0HOHNghPsrwURh/p5ia962bejrxtoe00 wXHTTqFALPt1x5D9gIsrK98pOZFTjl5M7xj0s/k1Qjv7HGPIiqyZX5gEBFiNTeI9sf4I Vz1+zHmkf5uD1OYZ0kZ4WudT58PII+r3VPyniyLhdT/27knTLp5CWFv8tgK09BK/UEbI vqNg== 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=yqh5y/xyzAhg8E54Bf49i2GyB9uCe9KG/jTqINVaPbQ=; b=LZIPKB5r5dzHQAfrNHst3U0SVrl2BN7CG58uaIs5hsYzDL/xNXYdewqQFWgiG13/lM erze2icrhiXnUtqqqlAr+O0krigqmvaaYu5ka2o28PJMXqPcTTYObxsn7svegYPKc9Jg CnB9YKhmhklrqsG35ecV+Xf7AnS7SNxqRsDM+sJsiatmGRWF+N4EvceiOS4k5u00i3nj FNIuAUybWlml0Y3nZs0EmPePWoEIEWO3V8VObW4XELy5UuGLY7GhKHwGbP8CMKug6NVQ 0bQKsruMB6qwhSHv29RY1kISffrhhVb8ohiaHVb4g4PfWw8HoP98/TBWP6EjaPAfEENR 4hHQ== X-Gm-Message-State: AOUpUlFmoAYx0mLM+DhTMe+GZCHJm9qO2mxhkJ/qF3tux1nfEc//2Pma T3a1/rN/aPgiBQaogktXDLtnuGZz X-Google-Smtp-Source: AA+uWPwUnoXefTLmuUpTen2HkuYGquAuB3KoJFL7Og1y1ZhpdxinD/mr1s0b6PpLr7MFQOlU0NjTjg== X-Received: by 2002:a17:902:d906:: with SMTP id c6-v6mr1497366plz.65.1533714237243; Wed, 08 Aug 2018 00:43:57 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:49 +0530 Message-Id: <1533501842-24503-23-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.44]); Wed, 08 Aug 2018 07:43:58 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 08 Aug 2018 07:43:58 +0000 (UTC) for IP:'209.85.160.66' DOMAIN:'mail-pl0-f66.google.com' HELO:'mail-pl0-f66.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.66 mail-pl0-f66.google.com 209.85.160.66 mail-pl0-f66.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.26 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 22/35] util: netdevopenvswitch: 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Wed, 08 Aug 2018 07:44:17 +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" 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 --- src/util/virnetdevopenvswitch.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/src/util/virnetdevopenvswitch.c b/src/util/virnetdevopenvswitc= h.c index d1c5cf4..eff6b0f 100644 --- a/src/util/virnetdevopenvswitch.c +++ b/src/util/virnetdevopenvswitch.c @@ -149,10 +149,10 @@ int virNetDevOpenvswitchAddPort(const char *brname, c= onst char *ifname, char macaddrstr[VIR_MAC_STRING_BUFLEN]; char ifuuidstr[VIR_UUID_STRING_BUFLEN]; char vmuuidstr[VIR_UUID_STRING_BUFLEN]; - char *attachedmac_ex_id =3D NULL; - char *ifaceid_ex_id =3D NULL; - char *profile_ex_id =3D NULL; - char *vmid_ex_id =3D NULL; + VIR_AUTOFREE(char *) attachedmac_ex_id =3D NULL; + VIR_AUTOFREE(char *) ifaceid_ex_id =3D NULL; + VIR_AUTOFREE(char *) profile_ex_id =3D NULL; + VIR_AUTOFREE(char *) vmid_ex_id =3D NULL; =20 virMacAddrFormat(macaddr, macaddrstr); virUUIDFormat(ovsport->interfaceID, ifuuidstr); @@ -209,10 +209,6 @@ int virNetDevOpenvswitchAddPort(const char *brname, co= nst char *ifname, =20 ret =3D 0; cleanup: - VIR_FREE(attachedmac_ex_id); - VIR_FREE(ifaceid_ex_id); - VIR_FREE(vmid_ex_id); - VIR_FREE(profile_ex_id); virCommandFree(cmd); return ret; } @@ -339,10 +335,10 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, virDomainInterfaceStatsPtr stats) { virCommandPtr cmd =3D NULL; - char *output; char *tmp; bool gotStats =3D false; int ret =3D -1; + VIR_AUTOFREE(char *) output =3D NULL; =20 /* Just ensure the interface exists in ovs */ cmd =3D virCommandNew(OVSVSCTL); @@ -399,7 +395,6 @@ virNetDevOpenvswitchInterfaceStats(const char *ifname, ret =3D 0; =20 cleanup: - VIR_FREE(output); virCommandFree(cmd); return ret; } @@ -481,7 +476,7 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, size_t ntokens =3D 0; int status; int ret =3D -1; - char *ovs_timeout =3D NULL; + VIR_AUTOFREE(char *) ovs_timeout =3D NULL; =20 /* Openvswitch vhostuser path are hardcoded to * //openvswitch/ @@ -513,7 +508,6 @@ virNetDevOpenvswitchGetVhostuserIfname(const char *path, cleanup: virStringListFreeCount(tokens, ntokens); virCommandFree(cmd); - VIR_FREE(ovs_timeout); return ret; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list