From nobody Mon Feb 9 21:24:23 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 1533714256043558.4953481624204; Wed, 8 Aug 2018 00:44:16 -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 5AB3B356F5; Wed, 8 Aug 2018 07:44:13 +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 271A417C52; Wed, 8 Aug 2018 07:44:12 +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 5731C1800FD9; Wed, 8 Aug 2018 07:44:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w787i4ZZ005830 for ; Wed, 8 Aug 2018 03:44:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id EE5591001938; Wed, 8 Aug 2018 07:44:04 +0000 (UTC) Received: from mx1.redhat.com (ext-mx05.extmail.prod.ext.phx2.redhat.com [10.5.110.29]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E7A8E1001F49 for ; Wed, 8 Aug 2018 07:44:04 +0000 (UTC) Received: from mail-pg1-f171.google.com (mail-pg1-f171.google.com [209.85.215.171]) (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 C758236A5C9 for ; Wed, 8 Aug 2018 07:44:03 +0000 (UTC) Received: by mail-pg1-f171.google.com with SMTP id n7-v6so694243pgq.4 for ; Wed, 08 Aug 2018 00:44:03 -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.01 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 08 Aug 2018 00:44:02 -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=rNBuyY2u2PaDJTxgRL7eyUcZSsBOjWcYmZLm+qqjGKU=; b=QEjdoeoVIsJ1ehSTQnKlXynAG4tHcLNQnyUOsV9mNsekJADNdRSsGnB1VMVN18IVNi VEkF+DJKf1IgMC/Ptf269CpyC/vuMAM+WYizh8wt5Y3e5zhozJ5o+bwzX8/ZRPmerHeu M9YBG4ByqlsqeJ5ftUQZmu69fayy4a4XC03bSv4A+OdbvIhqpHB2SiR3PM5+I3KHinn/ 0OGshDJZTY3uGr0+9jdQQQGOsv+JkEB9rzLzSJy+5o/J36fsQNKYp3tiuRXIXTmv93M+ bwQR6WQ1r73IYfxdrrTNyDVt3OSRYpV+OOFSy1l++9fqykvDo1yqmuUAUn14Na7t9tIA viGQ== 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=rNBuyY2u2PaDJTxgRL7eyUcZSsBOjWcYmZLm+qqjGKU=; b=hlClivwDtCfcj0ZCQGOtB7TAgV60TTpxN9LtoLI/2RfVnX1UykJsyWdVSptCbF0FNH SMPIzpyQrqzoFxr+HlMUj0uvdouYzExlHTrEz+hBPyEun5aLM6MNFe8fM4pn6+FuDAbG /rcNfLEICxyllNnmmhSTAZIt+zIJCzzZJccZcySX8xSKsVEseznte+O9X9mpxnTlm1vz JpfeUTBz/30A05XGbgYa4k5L52LjzASGsyebHXzs/dsUXexPyBUJjw2WH6D3nIUTBtia 1nne2hh0NgSokOvqLJpQ+wLFriPMRTbfSmz1GR4rYoyuAT7mMYKHoOv+7g5inZDP9u5Y +21w== X-Gm-Message-State: AOUpUlG6p+VNgBS7HICzRxIlnMoYNcWQCKo6sNKPEAJ7KTE9BnS/7K7L QAPWpSKvrg0TEdk7BAlVfxCi8MWR X-Google-Smtp-Source: AA+uWPwnqJV4HJu5dyK4RyI+OiOqpp5YFiUNgkkcwmTwcwiUk8lGbFE2bru7cwyVT62W+lxnwxhHgQ== X-Received: by 2002:a62:b20c:: with SMTP id x12-v6mr1752889pfe.64.1533714242885; Wed, 08 Aug 2018 00:44:02 -0700 (PDT) From: Sukrit Bhatnagar To: libvir-list@redhat.com Date: Mon, 6 Aug 2018 02:13:52 +0530 Message-Id: <1533501842-24503-26-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.29]); Wed, 08 Aug 2018 07:44:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Wed, 08 Aug 2018 07:44:03 +0000 (UTC) for IP:'209.85.215.171' DOMAIN:'mail-pg1-f171.google.com' HELO:'mail-pg1-f171.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.215.171 mail-pg1-f171.google.com 209.85.215.171 mail-pg1-f171.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.29 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2 25/35] util: netdevveth: 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.30]); Wed, 08 Aug 2018 07:44:14 +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/virnetdevveth.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/util/virnetdevveth.c b/src/util/virnetdevveth.c index 6905168..8c1a7f3 100644 --- a/src/util/virnetdevveth.c +++ b/src/util/virnetdevveth.c @@ -46,12 +46,11 @@ virMutex virNetDevVethCreateMutex =3D VIR_MUTEX_INITIAL= IZER; static int virNetDevVethExists(int devNum) { int ret; - char *path =3D NULL; + VIR_AUTOFREE(char *) path =3D NULL; if (virAsprintf(&path, SYSFS_NET_DIR "vnet%d/", devNum) < 0) return -1; ret =3D virFileExists(path) ? 1 : 0; VIR_DEBUG("Checked dev vnet%d usage: %d", devNum, ret); - VIR_FREE(path); return ret; } =20 @@ -111,8 +110,6 @@ static int virNetDevVethGetFreeNum(int startDev) int virNetDevVethCreate(char** veth1, char** veth2) { int ret =3D -1; - char *veth1auto =3D NULL; - char *veth2auto =3D NULL; int vethNum =3D 0; virCommandPtr cmd =3D NULL; size_t i; @@ -125,6 +122,9 @@ int virNetDevVethCreate(char** veth1, char** veth2) #define MAX_VETH_RETRIES 10 =20 for (i =3D 0; i < MAX_VETH_RETRIES; i++) { + VIR_AUTOFREE(char *) veth1auto =3D NULL; + VIR_AUTOFREE(char *) veth2auto =3D NULL; + int status; if (!*veth1) { int veth1num; @@ -173,8 +173,6 @@ int virNetDevVethCreate(char** veth1, char** veth2) *veth1 ? *veth1 : veth1auto, *veth2 ? *veth2 : veth2auto, status); - VIR_FREE(veth1auto); - VIR_FREE(veth2auto); virCommandFree(cmd); cmd =3D NULL; } @@ -186,8 +184,6 @@ int virNetDevVethCreate(char** veth1, char** veth2) cleanup: virMutexUnlock(&virNetDevVethCreateMutex); virCommandFree(cmd); - VIR_FREE(veth1auto); - VIR_FREE(veth2auto); return ret; } =20 --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list