From nobody Mon Feb 9 10:28:53 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 1533714265237156.6724716457678; Wed, 8 Aug 2018 00:44:25 -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 DCDFB81E07; Wed, 8 Aug 2018 07:44:22 +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 A5F1DCBD92; Wed, 8 Aug 2018 07:44:22 +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 54DA11800B6B; Wed, 8 Aug 2018 07:44:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787iLj7005964 for ; Wed, 8 Aug 2018 03:44:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 755463819C; Wed, 8 Aug 2018 07:44:21 +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 57ECB381A5 for ; Wed, 8 Aug 2018 07:44:06 +0000 (UTC) Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (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 7ABE530832F3 for ; Wed, 8 Aug 2018 07:44:05 +0000 (UTC) Received: by mail-pf1-f177.google.com with SMTP id j8-v6so719505pff.6 for ; Wed, 08 Aug 2018 00:44:05 -0700 (PDT) Received: from centos.localdomain ([42.106.0.165]) by smtp.gmail.com with ESMTPSA id 9-v6sm9617719pfv.53.2018.08.08.00.44.03 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:44:04 -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=Jcm69QRl4cp/TfEOliVF6BQckWdfLkgcgnd/GUipF3Y=; b=dzz4vmg5cJCUrWaI0OHEqKE5MqDZCsSEq6CnCwvoPG5iXb5J+RlOt+LOTOYWj6q3xC yK9BhSZHEjxPEhlWlBAQa3mwqcsJGtm91lhCw6LYDhbJgd6djSmUI1ihiqbOluYYYLtR 7CqdvTEe7D/rbcpQyA0j3SGGaHW1bLnHMuj8BbXKVKKwkSfZ49j1kAnauVp8/WN5p0ni nzfjpp5fl/sq5XTmTb37Fnjh014Gk8oPtJ6dj7qLs7cbVBQFC1aCLXaxgjp3VbauGYg2 xRP0RncuWRT7/nzlkx9RntXUi4642irnuJscglGTG1m0QbKrBGV2v90c99l/RgDr6XmM D0Vg== 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=Jcm69QRl4cp/TfEOliVF6BQckWdfLkgcgnd/GUipF3Y=; b=iPn9JRq9DH4qqVminks9IoFX2BzHryrHKTVDsd41mEuK5WQukqEz1zDZslX2XHzKmK amxr4jNVmX9jR0Yf/jgNSuGl1Lilia9wE8nOecf2eIH6DnnS1ZK4yHCKOzTMCtodL+GM vFGhE6iOnd3NaFO9YEYIUrTlUpL+ADsBZSaRKTPEEwxHHRNyh8vASmGBTMC6O1pSI3EB qg+5F2x2curgM6d+i/DlEoVK/AqDYg0CYye1j4zQhu3q7wwGqUAdc/k8T8hrvUofvFsR v/3RmoeYCOpnnWZUqX5N0N50o5nqZkRmkUX9vNvUAzesnkHZf5PIavfa/rTPJgdXbatF 4NGQ== X-Gm-Message-State: AOUpUlHQA97tLSW0Ki7+1PN5Ua5jip13wicq5te7l6AllLequ4rvuXw6 KCatgQ51UbGJLT9GpHFh9p7ncEr7 X-Google-Smtp-Source: AA+uWPwdfGBURkXQZVx/d4wtMSuEgWg5LV0yIsL8l6SP7RNhBTfK/66OVsRpJ2N//H6OKXbK87hhHA== X-Received: by 2002:a63:5542:: with SMTP id f2-v6mr1490265pgm.37.1533714244779; Wed, 08 Aug 2018 00:44:04 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:53 +0530 Message-Id: <1533501842-24503-27-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:44:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Wed, 08 Aug 2018 07:44:05 +0000 (UTC) for IP:'209.85.210.177' DOMAIN:'mail-pf1-f177.google.com' HELO:'mail-pf1-f177.google.com' FROM:'skrtbhtngr@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.11 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, SPF_PASS) 209.85.210.177 mail-pf1-f177.google.com 209.85.210.177 mail-pf1-f177.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.44 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 26/35] util: netdevveth: use VIR_AUTOPTR for aggregate 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.25]); Wed, 08 Aug 2018 07:44:23 +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_AUTOPTR macro for declaring aggregate pointer variables, majority of the calls to *Free functions 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/virnetdevveth.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 8c1a7f3..d2232ac 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -111,7 +111,6 @@ int virNetDevVethCreate(char** veth1, char** veth2) { int ret =3D -1; int vethNum =3D 0; - virCommandPtr cmd =3D NULL; size_t i; =20 /* @@ -124,6 +123,7 @@ int virNetDevVethCreate(char** veth1, char** veth2) for (i =3D 0; i < MAX_VETH_RETRIES; i++) { VIR_AUTOFREE(char *) veth1auto =3D NULL; VIR_AUTOFREE(char *) veth2auto =3D NULL; + VIR_AUTOPTR(virCommand) cmd =3D NULL; =20 int status; if (!*veth1) { @@ -173,8 +173,6 @@ int virNetDevVethCreate(char** veth1, char** veth2) *veth1 ? *veth1 : veth1auto, *veth2 ? *veth2 : veth2auto, status); - virCommandFree(cmd); - cmd =3D NULL; } =20 virReportError(VIR_ERR_INTERNAL_ERROR, @@ -183,7 +181,6 @@ int virNetDevVethCreate(char** veth1, char** veth2) =20 cleanup: virMutexUnlock(&virNetDevVethCreateMutex); - virCommandFree(cmd); return ret; } =20 @@ -200,26 +197,21 @@ int virNetDevVethCreate(char** veth1, char** veth2) */ int virNetDevVethDelete(const char *veth) { - virCommandPtr cmd =3D virCommandNewArgList("ip", "link", "del", veth, = NULL); int status; - int ret =3D -1; + VIR_AUTOPTR(virCommand) cmd =3D virCommandNewArgList("ip", "link", "de= l", veth, NULL); =20 if (virCommandRun(cmd, &status) < 0) - goto cleanup; + return -1; =20 if (status !=3D 0) { if (!virNetDevExists(veth)) { VIR_DEBUG("Device %s already deleted (by kernel namespace clea= nup)", veth); - ret =3D 0; - goto cleanup; + return 0; } virReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to delete veth device %s"), veth); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - virCommandFree(cmd); - return ret; + return 0; } --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list