From nobody Mon Feb 9 10:28: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 1533714287020398.676968365221; Wed, 8 Aug 2018 00:44:47 -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 A4E2A81E04; Wed, 8 Aug 2018 07:44:44 +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 6D37D2C32A; Wed, 8 Aug 2018 07:44:44 +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 236541800B80; Wed, 8 Aug 2018 07:44:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787iYw0006124 for ; Wed, 8 Aug 2018 03:44:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id B06786C513; Wed, 8 Aug 2018 07:44:34 +0000 (UTC) Received: from mx1.redhat.com (ext-mx10.extmail.prod.ext.phx2.redhat.com [10.5.110.39]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9DDA218EFA for ; Wed, 8 Aug 2018 07:44:02 +0000 (UTC) Received: from mail-pg1-f178.google.com (mail-pg1-f178.google.com [209.85.215.178]) (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 B43505F733 for ; Wed, 8 Aug 2018 07:44:01 +0000 (UTC) Received: by mail-pg1-f178.google.com with SMTP id x5-v6so686413pgp.7 for ; Wed, 08 Aug 2018 00:44:01 -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.59 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:44:00 -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=WEDowZtGFO2Ukdj8jeOh44aqkDDb4DoWN7+mC+71JL0=; b=f0Bumapk31lYQPyM5vHDSSE7kET/BA/8pgru6nJhqqBC054sBV9MgtowO0+w8WIkIQ sA30UT11aT5age+BU8G020B24S5Wp5KS4FC3x+4iQDag4BTUGV0QxZRvgeJrr26EJfB7 4DEg2bhcxEAv38IQlzsGBn+UdMUbvxUTTiEPgNBSsCs0fZZ1x6ygatbB1BvcNE+UcNd6 H2s8HdXdJ43N7jhH05CHvhlpE2ywmrETj9ur9WFwoctEQ5Jq75bs1zM3YpmJZmlH7Dfs y8NIHiZyTSA2iTjRaZCqwcXAa4UQTNjPOaJi0nRWF8z9RSnTsIBuVRIrWW/HL56HpaoN Mo9w== 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=WEDowZtGFO2Ukdj8jeOh44aqkDDb4DoWN7+mC+71JL0=; b=ets3dO4YxBttInc1B/pssKY6LgupvHMdzyyVPYgj6OqjQ20kvhnCDIwzk1Emht0coF OHp4j2oATljRBpro+PDLhSPqlAIaW0CWA05zvPfLKA7T9W3/wYQCsk0JpikOXm/mpqxC Zgv+EHLLs81rWiii8eyEgsbbkTkk12D19URM0lJ5ruzUY6mK8UZ0XVkFW1TQZPHEynKe uNztJqFnp01EKw3YT1TjGvZX6q20PVOQe3y5tIbMUJ0yGoTEUnR4J/grFcZZfCxU7Mck gsJl/98unqns151z4/6b7VlRt2q39qSDPrMOLZwbUrOXtI4f6Qc8k7uugJXkQ3IJE7ws UIZA== X-Gm-Message-State: AOUpUlHkxXC1yW2WJiSMFpzncUkeVAIKmQGBR30+4tsf4oyAZnSxaBQd /oZXYI/kkwxEahuUf9OziS1PZPJt X-Google-Smtp-Source: AA+uWPz24sbQzB84ItI/Ql+f8GWUgAvJVdFg4bvSEJAfPxf3/XY2ozC0pNTJL/ZN3PAXVg3rR/wFGw== X-Received: by 2002:a63:9d47:: with SMTP id i68-v6mr1463264pgd.172.1533714240974; Wed, 08 Aug 2018 00:44:00 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:51 +0530 Message-Id: <1533501842-24503-25-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.39]); Wed, 08 Aug 2018 07:44:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 08 Aug 2018 07:44:01 +0000 (UTC) for IP:'209.85.215.178' DOMAIN:'mail-pg1-f178.google.com' HELO:'mail-pg1-f178.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.215.178 mail-pg1-f178.google.com 209.85.215.178 mail-pg1-f178.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.39 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 24/35] 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.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.25]); Wed, 08 Aug 2018 07:44:45 +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 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