From nobody Sun Feb 8 07:07:42 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 1532806892322592.4273795011369; Sat, 28 Jul 2018 12:41:32 -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 B851A308625E; Sat, 28 Jul 2018 19:41:30 +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 78BA410694F0; Sat, 28 Jul 2018 19:41:30 +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 2816F264D3; Sat, 28 Jul 2018 19:41:30 +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 w6SJfILb020879 for ; Sat, 28 Jul 2018 15:41:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43E3C67CFD; Sat, 28 Jul 2018 19:41:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx02.extmail.prod.ext.phx2.redhat.com [10.5.110.26]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3AE4867CFB for ; Sat, 28 Jul 2018 19:41:14 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) (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 5A88512C27 for ; Sat, 28 Jul 2018 19:41:13 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id s17-v6so3735007plp.7 for ; Sat, 28 Jul 2018 12:41:13 -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.10 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 28 Jul 2018 12:41:12 -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=CWAM/Pnj526zqBP6hwY4MM+4AGzAF6RjIOdgite8aA8=; b=PRJql48wymF21+JZzE2avk5Sol4SOB5kESC3zhrUF97nlXp75HJcENqjFwxh/dsVv/ P5xdZnZHPFGFe9gjWWHWB936Hu2c1qauYiAgVQImGdCAlB/eAyeGAzo60RrYBaeymw94 g4+8Z/HBWLT8YfgPBpDDK/i6PyldYpEBwk02WooQUJrcVeOkpWfMw5FfXgE68xp2isDy zBEIGhFAGTWJxmf2j4YqI0uLXwIiVUR1K21GQ86tVoHf56QOX/WqOcuMnvM02FNKlBFq 6hbbgWWkw7gc9qoPMakPQQtwNkB2qd8tY6c1QatpotX3cDr45WdsOeGknjIHlvm6pzTR obJg== 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=CWAM/Pnj526zqBP6hwY4MM+4AGzAF6RjIOdgite8aA8=; b=V51dOcEF8W9PkjxCKIQbo7AcJ+16wzeWMwvDoouytcAKldLVwaqumVgYv3AWcDTbV8 ZKCKmB4t+Y3ioIeUvYf8rtv5lKNQy9VZHS76mwW3mLs1I46BqycsQM+yBR0c/23tsOHz VxRNTuJK5hAW27MsYL6BYCBuKq1BEt0meX/7LXdgIK45tUgAR8hBdls/hiShxUt0WMub V+IDaczLkyVhbk6pMMQQWc1FIvh4MSXqcRNoJZtIpQRb4Au+fK8i/Cxsw75CY7pM31Ui 4fx4YpILYxU2KTNE32b5G8ghulTnosj/ryi3ofl74wmYfYheWrPDbAuUguIk1VWosXPe nZ5g== X-Gm-Message-State: AOUpUlECYuMtEf470bpqE+e8yF3gesw0qScEqvxD1kKn+DpDDtSOioVF 0fRLSGlQl6h8YmqdxaNCctfVJ3Rk X-Google-Smtp-Source: AAOMgpcsnI/KxlrWNGL/1888gdFFj5BIdBZCPn2eJkRHCifawEnu+O7Gb/HMZKiyBrhP6PQbjt4eJQ== X-Received: by 2002:a17:902:46e:: with SMTP id 101-v6mr10848698ple.39.1532806872629; Sat, 28 Jul 2018 12:41:12 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Sat, 28 Jul 2018 23:31:34 +0530 Message-Id: <1532800907-29115-20-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.26]); Sat, 28 Jul 2018 19:41:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Sat, 28 Jul 2018 19:41:13 +0000 (UTC) for IP:'209.85.160.67' DOMAIN:'mail-pl0-f67.google.com' HELO:'mail-pl0-f67.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.67 mail-pl0-f67.google.com 209.85.160.67 mail-pl0-f67.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.26 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v1 19/32] util: netdevtap: 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.49]); Sat, 28 Jul 2018 19:41:31 +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/virnetdevtap.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index d432577..c2c2e73 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -400,16 +400,14 @@ int virNetDevTapCreate(char **ifname, if (strstr(*ifname, "%d") !=3D NULL) { size_t i; for (i =3D 0; i <=3D IF_MAXUNIT; i++) { - char *newname; + VIR_AUTOFREE(char *) newname =3D NULL; if (virAsprintf(&newname, *ifname, i) < 0) goto cleanup; =20 if (virNetDevExists(newname) =3D=3D 0) { - newifname =3D newname; + VIR_STEAL_PTR(newifname, newname); break; } - - VIR_FREE(newname); } if (newifname) { VIR_FREE(*ifname); @@ -423,7 +421,7 @@ int virNetDevTapCreate(char **ifname, } =20 if (tapfd) { - char *dev_path =3D NULL; + VIR_AUTOFREE(char *) dev_path =3D NULL; if (virAsprintf(&dev_path, "/dev/%s", ifr.ifr_name) < 0) goto cleanup; =20 @@ -431,11 +429,8 @@ int virNetDevTapCreate(char **ifname, virReportSystemError(errno, _("Unable to open %s"), dev_path); - VIR_FREE(dev_path); goto cleanup; } - - VIR_FREE(dev_path); } =20 if (virNetDevSetName(ifr.ifr_name, *ifname) =3D=3D -1) --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list