From nobody Tue May 7 16:49:41 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536551320717335.37808317342933; Sun, 9 Sep 2018 20:48:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3F7E786679; Mon, 10 Sep 2018 03:48:39 +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 0E7FC20158A5; Mon, 10 Sep 2018 03:48:39 +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 BC6D818005D0; Mon, 10 Sep 2018 03:48:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8A3m6vQ021324 for ; Sun, 9 Sep 2018 23:48:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 3DC0B5D772; Mon, 10 Sep 2018 03:48:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx11.extmail.prod.ext.phx2.redhat.com [10.5.110.40]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 360B05D76E for ; Mon, 10 Sep 2018 03:48:03 +0000 (UTC) Received: from m50211.mail.qiye.163.com (m50211.mail.qiye.163.com [123.125.50.211]) by mx1.redhat.com (Postfix) with ESMTP id 11FF2308429E for ; Mon, 10 Sep 2018 03:48:02 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp3 (Coremail) with SMTP id PdOowEDZhkJu6ZVb8BUdAg--.502S3; Mon, 10 Sep 2018 11:47:59 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Mon, 10 Sep 2018 11:47:50 +0800 Message-Id: <20180910034755.31246-2-shi_lei@massclouds.com> In-Reply-To: <20180910034755.31246-1-shi_lei@massclouds.com> References: <20180910034755.31246-1-shi_lei@massclouds.com> X-CM-TRANSID: PdOowEDZhkJu6ZVb8BUdAg--.502S3 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRAEfoUUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbiAg+9T1iln5gqqgAAsF X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 10 Sep 2018 03:48:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 10 Sep 2018 03:48:03 +0000 (UTC) for IP:'123.125.50.211' DOMAIN:'m50211.mail.qiye.163.com' HELO:'m50211.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 123.125.50.211 m50211.mail.qiye.163.com 123.125.50.211 m50211.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.40 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/6] util: file: introduce VIR_AUTOCLOSE macro to close fd of the file automatically 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.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.26]); Mon, 10 Sep 2018 03:48:39 +0000 (UTC) X-ZohoMail: 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_AUTOCLOSE mac= ro, many of the VIR_FORCE_CLOSE calls can be dropped, which in turn leads to getting rid of many of our cleanup sections. =20 Signed-off-by: Shi Lei --- src/util/virfile.h | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/util/virfile.h b/src/util/virfile.h index b30a1d3..70e7203 100644 --- a/src/util/virfile.h +++ b/src/util/virfile.h @@ -54,6 +54,11 @@ int virFileClose(int *fdptr, virFileCloseFlags flags) int virFileFclose(FILE **file, bool preserve_errno) ATTRIBUTE_RETURN_CHECK; FILE *virFileFdopen(int *fdptr, const char *mode) ATTRIBUTE_RETURN_CHECK; =20 +static inline void virForceCloseHelper(int *_fd) +{ + ignore_value(virFileClose(_fd, VIR_FILE_CLOSE_PRESERVE_ERRNO)); +} + /* For use on normal paths; caller must check return value, and failure sets errno per close. */ # define VIR_CLOSE(FD) virFileClose(&(FD), 0) @@ -64,8 +69,7 @@ FILE *virFileFdopen(int *fdptr, const char *mode) ATTRIBU= TE_RETURN_CHECK; =20 /* For use on cleanup paths; errno is unaffected by close, and no return value to worry about. */ -# define VIR_FORCE_CLOSE(FD) \ - ignore_value(virFileClose(&(FD), VIR_FILE_CLOSE_PRESERVE_ERRNO)) +# define VIR_FORCE_CLOSE(FD) virForceCloseHelper(&(FD)) # define VIR_FORCE_FCLOSE(FILE) ignore_value(virFileFclose(&(FILE), true)) =20 /* Similar VIR_FORCE_CLOSE() but ignores EBADF errors since they are expec= ted @@ -80,6 +84,18 @@ FILE *virFileFdopen(int *fdptr, const char *mode) ATTRIB= UTE_RETURN_CHECK; VIR_FILE_CLOSE_PRESERVE_ERRNO | \ VIR_FILE_CLOSE_DONT_LOG)) =20 +/** + * VIR_AUTOCLOSE: + * @fd: fd of the file to be closed automatically + * + * Macro to automatically force close the fd by calling virForceCloseHelper + * when the fd goes out of scope. It's used to eliminate VIR_FORCE_CLOSE + * in cleanup sections. + */ +# define VIR_AUTOCLOSE(fd) \ + __attribute__((cleanup(virForceCloseHelper))) int fd =3D -1 + + /* Opaque type for managing a wrapper around a fd. */ struct _virFileWrapperFd; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 16:49:41 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536551296518561.2219453275595; Sun, 9 Sep 2018 20:48:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4B97CC05D3EE; Mon, 10 Sep 2018 03:48:14 +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 F315A5DD6B; Mon, 10 Sep 2018 03:48: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 B0F7D181A12F; Mon, 10 Sep 2018 03:48:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8A3m6M4021319 for ; Sun, 9 Sep 2018 23:48:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 157022B58E; Mon, 10 Sep 2018 03:48:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0C7F52B594 for ; Mon, 10 Sep 2018 03:48:04 +0000 (UTC) Received: from m50211.mail.qiye.163.com (m50211.mail.qiye.163.com [123.125.50.211]) by mx1.redhat.com (Postfix) with ESMTP id 326D781DEB for ; Mon, 10 Sep 2018 03:48:01 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp3 (Coremail) with SMTP id PdOowEDZhkJu6ZVb8BUdAg--.502S4; Mon, 10 Sep 2018 11:48:00 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Mon, 10 Sep 2018 11:47:51 +0800 Message-Id: <20180910034755.31246-3-shi_lei@massclouds.com> In-Reply-To: <20180910034755.31246-1-shi_lei@massclouds.com> References: <20180910034755.31246-1-shi_lei@massclouds.com> X-CM-TRANSID: PdOowEDZhkJu6ZVb8BUdAg--.502S4 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRAEfoUUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbidxC9T1n5eGHo9gAAsy X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Sep 2018 03:48:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 10 Sep 2018 03:48:02 +0000 (UTC) for IP:'123.125.50.211' DOMAIN:'m50211.mail.qiye.163.com' HELO:'m50211.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 123.125.50.211 m50211.mail.qiye.163.com 123.125.50.211 m50211.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/6] util: file: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 10 Sep 2018 03:48:14 +0000 (UTC) X-ZohoMail: 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_AUTOCLOSE mac= ro, many of the VIR_FORCE_CLOSE calls can be dropped, which in turn leads to getting rid of many of our cleanup sections. =20 Signed-off-by: Shi Lei --- src/util/virfile.c | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/util/virfile.c b/src/util/virfile.c index 01ebdb6..e63fada 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -1969,29 +1969,22 @@ int virFileIsCDROM(const char *path) { struct stat st; - int fd; - int ret =3D -1; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D open(path, O_RDONLY | O_NONBLOCK)) < 0) - goto cleanup; + return -1; =20 if (fstat(fd, &st) < 0) - goto cleanup; + return -1; =20 - if (!S_ISBLK(st.st_mode)) { - ret =3D 0; - goto cleanup; - } + if (!S_ISBLK(st.st_mode)) + return 0; =20 /* Attempt to detect via a CDROM specific ioctl */ if (ioctl(fd, CDROM_DRIVE_STATUS, CDSL_CURRENT) >=3D 0) - ret =3D 1; - else - ret =3D 0; + return 1; =20 - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } =20 #else --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 16:49:41 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536551324739281.9655513953194; Sun, 9 Sep 2018 20:48:44 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 073303D07; Mon, 10 Sep 2018 03:48:43 +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 BDAA6611C5; Mon, 10 Sep 2018 03:48:42 +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 7B80E181A139; Mon, 10 Sep 2018 03:48:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.27]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8A3m6N2021333 for ; Sun, 9 Sep 2018 23:48:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id ADE5CD239A; Mon, 10 Sep 2018 03:48:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A6A59AB689 for ; Mon, 10 Sep 2018 03:48:04 +0000 (UTC) Received: from m50211.mail.qiye.163.com (m50211.mail.qiye.163.com [123.125.50.211]) by mx1.redhat.com (Postfix) with ESMTP id 63EAF3082A26 for ; Mon, 10 Sep 2018 03:48:01 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp3 (Coremail) with SMTP id PdOowEDZhkJu6ZVb8BUdAg--.502S5; Mon, 10 Sep 2018 11:48:00 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Mon, 10 Sep 2018 11:47:52 +0800 Message-Id: <20180910034755.31246-4-shi_lei@massclouds.com> In-Reply-To: <20180910034755.31246-1-shi_lei@massclouds.com> References: <20180910034755.31246-1-shi_lei@massclouds.com> X-CM-TRANSID: PdOowEDZhkJu6ZVb8BUdAg--.502S5 X-Coremail-Antispam: 1Uf129KBjvJXoWxtryDCF1UCry8Cr15ZF4Utwb_yoW3WrWkpF 1FqFyDtwsYqF4rGFWUAr1UGFn0yrZrXr4rt3yUuwnrZ3yfuaySgF4xCF12gan3JFyrWF15 JF4Y9F95Xa4UGaDanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pR8hLnUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbifhC9T1rpNNMxqQAAsQ X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 10 Sep 2018 03:48:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Mon, 10 Sep 2018 03:48:03 +0000 (UTC) for IP:'123.125.50.211' DOMAIN:'m50211.mail.qiye.163.com' HELO:'m50211.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 123.125.50.211 m50211.mail.qiye.163.com 123.125.50.211 m50211.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.27 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/6] util: netdevbridge: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Mon, 10 Sep 2018 03:48:43 +0000 (UTC) X-ZohoMail: 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_AUTOCLOSE mac= ro, many of the VIR_FORCE_CLOSE calls can be dropped, which in turn leads to getting rid of many of our cleanup sections. =20 Signed-off-by: Shi Lei --- src/util/virnetdevbridge.c | 120 ++++++++++++------------------------- 1 file changed, 37 insertions(+), 83 deletions(-) diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index bc377b5..d8528e1 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -81,9 +81,8 @@ static int virNetDevBridgeCmd(const char *brname, void *arg, size_t argsize) { - int s; - int ret =3D -1; struct ifdrv ifd; + VIR_AUTOCLOSE(s); =20 memset(&ifd, 0, sizeof(ifd)); =20 @@ -97,19 +96,14 @@ static int virNetDevBridgeCmd(const char *brname, virReportSystemError(ERANGE, _("Network interface name '%s' is too long"), brname); - goto cleanup; + return -1; } =20 ifd.ifd_cmd =3D op; ifd.ifd_len =3D argsize; ifd.ifd_data =3D arg; =20 - ret =3D ioctl(s, SIOCSDRVSPEC, &ifd); - - cleanup: - VIR_FORCE_CLOSE(s); - - return ret; + return ioctl(s, SIOCSDRVSPEC, &ifd); } #endif =20 @@ -167,10 +161,9 @@ static int virNetDevBridgeGet(const char *brname, const char *paramname, /* sysfs param name = */ unsigned long *value) /* current value */ { - int ret =3D -1; - int fd =3D -1; struct ifreq ifr; VIR_AUTOFREE(char *) path =3D NULL; + VIR_AUTOCLOSE(fd); =20 if (virAsprintf(&path, SYSFS_NET_DIR "%s/bridge/%s", brname, paramname= ) < 0) return -1; @@ -180,26 +173,26 @@ static int virNetDevBridgeGet(const char *brname, =20 if (virFileReadAll(path, INT_BUFSIZE_BOUND(unsigned long), &valuestr) < 0) - goto cleanup; + return -1; =20 if (virStrToLong_ul(valuestr, NULL, 10, value) < 0) { virReportSystemError(EINVAL, _("Unable to get bridge %s %s"), brname, paramname); - goto cleanup; + return -1; } } else { struct __bridge_info info; unsigned long args[] =3D { BRCTL_GET_BRIDGE_INFO, (unsigned long)&= info, 0, 0 }; =20 if ((fd =3D virNetDevSetupControl(brname, &ifr)) < 0) - goto cleanup; + return -1; =20 ifr.ifr_data =3D (char*)&args; if (ioctl(fd, SIOCDEVPRIVATE, ifr) < 0) { virReportSystemError(errno, _("Unable to get bridge %s %s"), brname, = paramname); - goto cleanup; + return -1; } =20 if (STREQ(paramname, "stp_state")) { @@ -209,14 +202,11 @@ static int virNetDevBridgeGet(const char *brname, } else { virReportSystemError(EINVAL, _("Unable to get bridge %s %s"), brname, = paramname); - goto cleanup; + return -1; } } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #endif /* __linux__ */ =20 @@ -391,8 +381,7 @@ virNetDevBridgePortSetUnicastFlood(const char *brname A= TTRIBUTE_UNUSED, static int virNetDevBridgeCreateWithIoctl(const char *brname) { - int fd =3D -1; - int ret =3D -1; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(NULL, NULL)) < 0) return -1; @@ -400,14 +389,10 @@ virNetDevBridgeCreateWithIoctl(const char *brname) if (ioctl(fd, SIOCBRADDBR, brname) < 0) { virReportSystemError(errno, _("Unable to create bridge %s"), brname); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #endif =20 @@ -503,9 +488,8 @@ virNetDevBridgeCreate(const char *brname) int virNetDevBridgeCreate(const char *brname) { - int s; struct ifreq ifr; - int ret =3D - 1; + VIR_AUTOCLOSE(s); =20 if ((s =3D virNetDevSetupControl("bridge", &ifr)) < 0) return -1; @@ -513,16 +497,13 @@ virNetDevBridgeCreate(const char *brname) if (ioctl(s, SIOCIFCREATE2, &ifr) < 0) { virReportSystemError(errno, "%s", _("Unable to create bridge device")); - goto cleanup; + return -1; } =20 if (virNetDevSetName(ifr.ifr_name, brname) =3D=3D -1) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(s); - return ret; + return 0; } #else int virNetDevBridgeCreate(const char *brname) @@ -545,8 +526,7 @@ int virNetDevBridgeCreate(const char *brname) static int virNetDevBridgeDeleteWithIoctl(const char *brname) { - int fd =3D -1; - int ret =3D -1; + VIR_AUTOCLOSE(fd); =20 ignore_value(virNetDevSetOnline(brname, false)); =20 @@ -556,14 +536,10 @@ virNetDevBridgeDeleteWithIoctl(const char *brname) if (ioctl(fd, SIOCBRDELBR, brname) < 0) { virReportSystemError(errno, _("Unable to delete bridge %s"), brname); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #endif =20 @@ -596,9 +572,8 @@ virNetDevBridgeDelete(const char *brname) int virNetDevBridgeDelete(const char *brname) { - int s; struct ifreq ifr; - int ret =3D -1; + VIR_AUTOCLOSE(s); =20 if ((s =3D virNetDevSetupControl(brname, &ifr)) < 0) return -1; @@ -607,13 +582,10 @@ virNetDevBridgeDelete(const char *brname) virReportSystemError(errno, _("Unable to remove bridge %s"), brname); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(s); - return ret; + return 0; } #else int virNetDevBridgeDelete(const char *brname ATTRIBUTE_UNUSED) @@ -637,9 +609,8 @@ int virNetDevBridgeDelete(const char *brname ATTRIBUTE_= UNUSED) int virNetDevBridgeAddPort(const char *brname, const char *ifname) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(brname, &ifr)) < 0) return -1; @@ -647,19 +618,16 @@ int virNetDevBridgeAddPort(const char *brname, if (!(ifr.ifr_ifindex =3D if_nametoindex(ifname))) { virReportSystemError(ENODEV, _("Unable to get interface index for %s"), if= name); - goto cleanup; + return -1; } =20 if (ioctl(fd, SIOCBRADDIF, &ifr) < 0) { virReportSystemError(errno, _("Unable to add bridge %s port %s"), brname,= ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #elif defined(HAVE_BSD_BRIDGE_MGMT) int virNetDevBridgeAddPort(const char *brname, @@ -706,9 +674,8 @@ int virNetDevBridgeAddPort(const char *brname, int virNetDevBridgeRemovePort(const char *brname, const char *ifname) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(brname, &ifr)) < 0) return -1; @@ -717,19 +684,16 @@ int virNetDevBridgeRemovePort(const char *brname, virReportSystemError(ENODEV, _("Unable to get interface index for %s"), if= name); =20 - goto cleanup; + return -1; } =20 if (ioctl(fd, SIOCBRDELIF, &ifr) < 0) { virReportSystemError(errno, _("Unable to remove bridge %s port %s"), brna= me, ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #elif defined(HAVE_BSD_BRIDGE_MGMT) int virNetDevBridgeRemovePort(const char *brname, @@ -778,19 +742,14 @@ int virNetDevBridgeRemovePort(const char *brname, int virNetDevBridgeSetSTPDelay(const char *brname, int delay) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(brname, &ifr)) < 0) - goto cleanup; + return -1; =20 - ret =3D virNetDevBridgeSet(brname, "forward_delay", MS_TO_JIFFIES(dela= y), + return virNetDevBridgeSet(brname, "forward_delay", MS_TO_JIFFIES(delay= ), fd, &ifr); - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; } =20 =20 @@ -831,19 +790,14 @@ int virNetDevBridgeGetSTPDelay(const char *brname, int virNetDevBridgeSetSTP(const char *brname, bool enable) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(brname, &ifr)) < 0) - goto cleanup; + return -1; =20 - ret =3D virNetDevBridgeSet(brname, "stp_state", enable ? 1 : 0, + return virNetDevBridgeSet(brname, "stp_state", enable ? 1 : 0, fd, &ifr); - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; } =20 =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 16:49:41 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536551321892999.476622063667; Sun, 9 Sep 2018 20:48:41 -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 481963001534; Mon, 10 Sep 2018 03:48:40 +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 17874D239F; Mon, 10 Sep 2018 03:48:40 +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 BEA7F4A463; Mon, 10 Sep 2018 03:48:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8A3m7kK021338 for ; Sun, 9 Sep 2018 23:48:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6C8EF60BE8; Mon, 10 Sep 2018 03:48:07 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 64B7A60BE1 for ; Mon, 10 Sep 2018 03:48:07 +0000 (UTC) Received: from m50211.mail.qiye.163.com (m50211.mail.qiye.163.com [123.125.50.211]) by mx1.redhat.com (Postfix) with ESMTP id AA30830820D4 for ; Mon, 10 Sep 2018 03:48:04 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp3 (Coremail) with SMTP id PdOowEDZhkJu6ZVb8BUdAg--.502S6; Mon, 10 Sep 2018 11:48:00 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Mon, 10 Sep 2018 11:47:53 +0800 Message-Id: <20180910034755.31246-5-shi_lei@massclouds.com> In-Reply-To: <20180910034755.31246-1-shi_lei@massclouds.com> References: <20180910034755.31246-1-shi_lei@massclouds.com> X-CM-TRANSID: PdOowEDZhkJu6ZVb8BUdAg--.502S6 X-Coremail-Antispam: 1Uf129KBjvAXoW3CFWfKFWxGr4kZw43AF1xAFb_yoW8Gry7Ao WxJr13tFyvgw1xWFWUJFy7trsIga1Yy3y8Z3Z5JFZFyF4rWr95C3yxCanrZa9a9r1UurWD XF1xXa43WFWDArs7n29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73VFW2AGmfu7bjvjm3 AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRGeHqDUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbigRC9T1sfl4gGEAAAsu X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 10 Sep 2018 03:48:05 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Mon, 10 Sep 2018 03:48:05 +0000 (UTC) for IP:'123.125.50.211' DOMAIN:'m50211.mail.qiye.163.com' HELO:'m50211.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 123.125.50.211 m50211.mail.qiye.163.com 123.125.50.211 m50211.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/6] util: netdev: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE 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.47]); Mon, 10 Sep 2018 03:48:41 +0000 (UTC) X-ZohoMail: 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_AUTOCLOSE mac= ro, many of the VIR_FORCE_CLOSE calls can be dropped, which in turn leads to getting rid of many of our cleanup sections. =20 Signed-off-by: Shi Lei --- src/util/virnetdev.c | 253 +++++++++++++++---------------------------- 1 file changed, 87 insertions(+), 166 deletions(-) diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 5d4ad24..7f43f15 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -200,27 +200,22 @@ virNetDevSetupControl(const char *ifname ATTRIBUTE_UN= USED, */ int virNetDevExists(const char *ifname) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; =20 if (ioctl(fd, SIOCGIFFLAGS, &ifr)) { if (errno =3D=3D ENODEV || errno =3D=3D ENXIO) - ret =3D 0; - else - virReportSystemError(errno, - _("Unable to check interface flags for %s= "), ifname); - goto cleanup; - } + return 0; =20 - ret =3D 1; + virReportSystemError(errno, _("Unable to check interface flags for= %s"), + ifname); + return -1; + } =20 - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 1; } #else int virNetDevExists(const char *ifname) @@ -251,20 +246,20 @@ virNetDevSetMACInternal(const char *ifname, const virMacAddr *macaddr, bool quiet) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; char macstr[VIR_MAC_STRING_BUFLEN]; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; =20 /* To fill ifr.ifr_hdaddr.sa_family field */ if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { - virReportSystemError(errno, - _("Cannot get interface MAC on '%s'"), + virReportSystemError(errno, _("Cannot get interface MAC on '%s'"), ifname); - goto cleanup; + + VIR_DEBUG("SIOCSIFHWADDR %s get MAC - Fail", ifname); + return -1; } =20 virMacAddrGetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data); @@ -272,24 +267,22 @@ virNetDevSetMACInternal(const char *ifname, if (ioctl(fd, SIOCSIFHWADDR, &ifr) < 0) { =20 if (quiet && - (errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM)) - goto cleanup; + (errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM)) { + VIR_DEBUG("SIOCSIFHWADDR %s MAC=3D%s - Fail", + ifname, virMacAddrFormat(macaddr, macstr)); + return -1; + } =20 virReportSystemError(errno, _("Cannot set interface MAC to %s on '%s'"), virMacAddrFormat(macaddr, macstr), ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; + VIR_DEBUG("SIOCSIFHWADDR %s MAC=3D%s - Success", + ifname, virMacAddrFormat(macaddr, macstr)); =20 - cleanup: - VIR_DEBUG("SIOCSIFHWADDR %s MAC=3D%s - %s", - ifname, virMacAddrFormat(macaddr, macstr), - ret < 0 ? "Fail" : "Success"); - - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } =20 =20 @@ -305,8 +298,7 @@ virNetDevSetMACInternal(const char *ifname, struct ifreq ifr; struct sockaddr_dl sdl; char mac[VIR_MAC_STRING_BUFLEN + 1] =3D ":"; - int s; - int ret =3D -1; + VIR_AUTOCLOSE(s); =20 if ((s =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -320,23 +312,19 @@ virNetDevSetMACInternal(const char *ifname, =20 if (ioctl(s, SIOCSIFLLADDR, &ifr) < 0) { if (quiet && - (errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM)) - goto cleanup; + (errno =3D=3D EADDRNOTAVAIL || errno =3D=3D EPERM)) { + VIR_DEBUG("SIOCSIFLLADDR %s MAC=3D%s - Fail", ifname, mac = + 1); + return -1; + } =20 virReportSystemError(errno, _("Cannot set interface MAC to %s on '%s'= "), mac + 1, ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_DEBUG("SIOCSIFLLADDR %s MAC=3D%s - %s", ifname, mac + 1, - ret < 0 ? "Fail" : "Success"); - - VIR_FORCE_CLOSE(s); - - return ret; + VIR_DEBUG("SIOCSIFLLADDR %s MAC=3D%s - Success", ifname, mac + 1); + return 0; } =20 =20 @@ -379,9 +367,8 @@ virNetDevSetMAC(const char *ifname, int virNetDevGetMAC(const char *ifname, virMacAddrPtr macaddr) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -390,16 +377,12 @@ int virNetDevGetMAC(const char *ifname, virReportSystemError(errno, _("Cannot get interface MAC on '%s'"), ifname); - goto cleanup; + return -1; } =20 virMacAddrSetRaw(macaddr, (unsigned char *)ifr.ifr_hwaddr.sa_data); =20 - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else int virNetDevGetMAC(const char *ifname, @@ -424,9 +407,8 @@ int virNetDevGetMAC(const char *ifname, */ int virNetDevGetMTU(const char *ifname) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -435,14 +417,10 @@ int virNetDevGetMTU(const char *ifname) virReportSystemError(errno, _("Cannot get interface MTU on '%s'"), ifname); - goto cleanup; + return -1; } =20 - ret =3D ifr.ifr_mtu; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return ifr.ifr_mtu; } #else int virNetDevGetMTU(const char *ifname) @@ -468,9 +446,8 @@ int virNetDevGetMTU(const char *ifname) */ int virNetDevSetMTU(const char *ifname, int mtu) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -481,14 +458,10 @@ int virNetDevSetMTU(const char *ifname, int mtu) virReportSystemError(errno, _("Cannot set interface MTU on '%s'"), ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else int virNetDevSetMTU(const char *ifname, int mtu ATTRIBUTE_UNUSED) @@ -592,9 +565,8 @@ int virNetDevSetNamespace(const char *ifname, pid_t pid= InNs) */ int virNetDevSetName(const char* ifname, const char *newifname) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -604,7 +576,7 @@ int virNetDevSetName(const char* ifname, const char *ne= wifname) virReportSystemError(ERANGE, _("Network interface name '%s' is too long"), newifname); - goto cleanup; + return -1; } # else ifr.ifr_data =3D (caddr_t)newifname; @@ -614,14 +586,10 @@ int virNetDevSetName(const char* ifname, const char *= newifname) virReportSystemError(errno, _("Unable to rename '%s' to '%s'"), ifname, newifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else int virNetDevSetName(const char* ifname, const char *newifname) @@ -638,10 +606,9 @@ int virNetDevSetName(const char* ifname, const char *n= ewifname) static int virNetDevSetIFFlag(const char *ifname, int flag, bool val) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; int ifflags; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -650,7 +617,7 @@ virNetDevSetIFFlag(const char *ifname, int flag, bool v= al) virReportSystemError(errno, _("Cannot get interface flags on '%s'"), ifname); - goto cleanup; + return -1; } =20 if (val) @@ -664,15 +631,11 @@ virNetDevSetIFFlag(const char *ifname, int flag, bool= val) virReportSystemError(errno, _("Cannot set interface flags on '%s'"), ifname); - goto cleanup; + return -1; } } =20 - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else static int @@ -765,9 +728,8 @@ virNetDevSetRcvAllMulti(const char *ifname, static int virNetDevGetIFFlag(const char *ifname, int flag, bool *val) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -776,15 +738,11 @@ virNetDevGetIFFlag(const char *ifname, int flag, bool= *val) virReportSystemError(errno, _("Cannot get interface flags on '%s'"), ifname); - goto cleanup; + return -1; } =20 *val =3D (ifr.ifr_flags & flag) ? true : false; - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else static int @@ -909,9 +867,9 @@ char *virNetDevGetName(int ifindex) #if defined(SIOCGIFINDEX) && defined(HAVE_STRUCT_IFREQ) int virNetDevGetIndex(const char *ifname, int *ifindex) { - int ret =3D -1; struct ifreq ifreq; - int fd =3D socket(VIR_NETDEV_FAMILY, SOCK_DGRAM, 0); + VIR_AUTOCLOSE(fd); + socket(VIR_NETDEV_FAMILY, SOCK_DGRAM, 0); =20 if (fd < 0) { virReportSystemError(errno, "%s", @@ -925,13 +883,13 @@ int virNetDevGetIndex(const char *ifname, int *ifinde= x) virReportSystemError(ERANGE, _("invalid interface name %s"), ifname); - goto cleanup; + return -1; } =20 if (ioctl(fd, SIOCGIFINDEX, &ifreq) < 0) { virReportSystemError(errno, _("Unable to get index for interface %s"), if= name); - goto cleanup; + return -1; } =20 # ifdef HAVE_STRUCT_IFREQ_IFR_INDEX @@ -939,11 +897,7 @@ int virNetDevGetIndex(const char *ifname, int *ifindex) # else *ifindex =3D ifreq.ifr_ifindex; # endif - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else /* ! SIOCGIFINDEX */ int virNetDevGetIndex(const char *ifname ATTRIBUTE_UNUSED, @@ -1013,8 +967,8 @@ int virNetDevGetVLanID(const char *ifname, int *vlanid) struct vlan_ioctl_args vlanargs =3D { .cmd =3D GET_VLAN_VID_CMD, }; - int ret =3D -1; - int fd =3D socket(PF_PACKET, SOCK_DGRAM, 0); + VIR_AUTOCLOSE(fd); + socket(PF_PACKET, SOCK_DGRAM, 0); =20 if (fd < 0) { virReportSystemError(errno, "%s", @@ -1026,22 +980,17 @@ int virNetDevGetVLanID(const char *ifname, int *vlan= id) virReportSystemError(ERANGE, _("invalid interface name %s"), ifname); - goto cleanup; + return -1; } =20 if (ioctl(fd, SIOCGIFVLAN, &vlanargs) !=3D 0) { virReportSystemError(errno, _("Unable to get VLAN for interface %s"), ifn= ame); - goto cleanup; + return -1; } =20 *vlanid =3D vlanargs.u.VID; - ret =3D 0; - - cleanup: - VIR_FORCE_CLOSE(fd); - - return ret; + return 0; } #else /* ! SIOCGIFVLAN */ int virNetDevGetVLanID(const char *ifname ATTRIBUTE_UNUSED, @@ -1070,55 +1019,43 @@ int virNetDevGetVLanID(const char *ifname ATTRIBUTE= _UNUSED, int virNetDevValidateConfig(const char *ifname, const virMacAddr *macaddr, int ifindex) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; int idx; int rc; + VIR_AUTOCLOSE(fd); =20 if ((rc =3D virNetDevExists(ifname)) < 0) return -1; - if (rc =3D=3D 0) { - ret =3D 0; - goto cleanup; - } + if (rc =3D=3D 0) + return 0; =20 if (macaddr !=3D NULL) { if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; =20 if (ioctl(fd, SIOCGIFHWADDR, &ifr) < 0) { - if (errno =3D=3D ENODEV) { - ret =3D 0; - goto cleanup; - } + if (errno =3D=3D ENODEV) + return 0; + virReportSystemError(errno, _("could not get MAC address of interface= %s"), ifname); - goto cleanup; + return -1; } =20 if (virMacAddrCmpRaw(macaddr, - (unsigned char *)ifr.ifr_hwaddr.sa_data) !=3D= 0) { - ret =3D 0; - goto cleanup; - } + (unsigned char *)ifr.ifr_hwaddr.sa_data) !=3D= 0) + return 0; } =20 if (ifindex !=3D -1) { if (virNetDevGetIndex(ifname, &idx) < 0) - goto cleanup; - if (idx !=3D ifindex) { - ret =3D 0; - goto cleanup; - } + return -1; + if (idx !=3D ifindex) + return 0; } =20 - ret =3D 1; - - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 1; } #else int virNetDevValidateConfig(const char *ifname ATTRIBUTE_UNUSED, @@ -2649,9 +2586,8 @@ virNetDevGetLinkInfo(const char *ifname, int virNetDevAddMulti(const char *ifname, virMacAddrPtr macaddr) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -2664,13 +2600,10 @@ int virNetDevAddMulti(const char *ifname, virReportSystemError(errno, _("Cannot add multicast MAC %s on '%s' interf= ace"), virMacAddrFormat(macaddr, macstr), ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else int virNetDevAddMulti(const char *ifname ATTRIBUTE_UNUSED, @@ -2698,9 +2631,8 @@ int virNetDevAddMulti(const char *ifname ATTRIBUTE_UN= USED, int virNetDevDelMulti(const char *ifname, virMacAddrPtr macaddr) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) return -1; @@ -2713,13 +2645,10 @@ int virNetDevDelMulti(const char *ifname, virReportSystemError(errno, _("Cannot add multicast MAC %s on '%s' interf= ace"), virMacAddrFormat(macaddr, macstr), ifname); - goto cleanup; + return -1; } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else int virNetDevDelMulti(const char *ifname ATTRIBUTE_UNUSED, @@ -3388,10 +3317,9 @@ int virNetDevSetCoalesce(const char *ifname, virNetDevCoalescePtr coalesce, bool update) { - int fd =3D -1; - int ret =3D -1; struct ifreq ifr; struct ethtool_coalesce coal =3D {0}; + VIR_AUTOCLOSE(fd); =20 if (!coalesce && !update) return 0; @@ -3433,7 +3361,7 @@ int virNetDevSetCoalesce(const char *ifname, virReportSystemError(errno, _("Cannot set coalesce info on '%s'"), ifname); - goto cleanup; + return -1; } =20 if (coalesce) { @@ -3467,10 +3395,7 @@ int virNetDevSetCoalesce(const char *ifname, } } =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } # else int virNetDevSetCoalesce(const char *ifname, @@ -3503,30 +3428,26 @@ virNetDevGetFeatures(const char *ifname, virBitmapPtr *out) { struct ifreq ifr; - int ret =3D -1; - int fd =3D -1; + VIR_AUTOCLOSE(fd); =20 if (!(*out =3D virBitmapNew(VIR_NET_DEV_FEAT_LAST))) return -1; =20 if ((fd =3D virNetDevSetupControl(ifname, &ifr)) < 0) - goto cleanup; + return -1; =20 virNetDevGetEthtoolFeatures(*out, fd, &ifr); =20 if (virNetDevGetEthtoolGFeatures(*out, fd, &ifr) < 0) - goto cleanup; + return -1; =20 if (virNetDevRDMAFeature(ifname, out) < 0) - goto cleanup; + return -1; =20 if (virNetDevSwitchdevFeature(ifname, out) < 0) - goto cleanup; + return -1; =20 - ret =3D 0; - cleanup: - VIR_FORCE_CLOSE(fd); - return ret; + return 0; } #else int --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 16:49:41 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536551328817246.37764571369974; Sun, 9 Sep 2018 20:48:48 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9EB9BC050005; Mon, 10 Sep 2018 03:48:46 +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 5D15619487; Mon, 10 Sep 2018 03:48:46 +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 093C9181A13C; Mon, 10 Sep 2018 03:48:46 +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 w8A3m8va021353 for ; Sun, 9 Sep 2018 23:48:08 -0400 Received: by smtp.corp.redhat.com (Postfix) id 018185C1B5; Mon, 10 Sep 2018 03:48:08 +0000 (UTC) Received: from mx1.redhat.com (ext-mx09.extmail.prod.ext.phx2.redhat.com [10.5.110.38]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ED5FB5C1B4 for ; Mon, 10 Sep 2018 03:48:04 +0000 (UTC) Received: from m50211.mail.qiye.163.com (m50211.mail.qiye.163.com [123.125.50.211]) by mx1.redhat.com (Postfix) with ESMTP id CEB154E021 for ; Mon, 10 Sep 2018 03:48:01 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp3 (Coremail) with SMTP id PdOowEDZhkJu6ZVb8BUdAg--.502S7; Mon, 10 Sep 2018 11:48:00 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Mon, 10 Sep 2018 11:47:54 +0800 Message-Id: <20180910034755.31246-6-shi_lei@massclouds.com> In-Reply-To: <20180910034755.31246-1-shi_lei@massclouds.com> References: <20180910034755.31246-1-shi_lei@massclouds.com> X-CM-TRANSID: PdOowEDZhkJu6ZVb8BUdAg--.502S7 X-Coremail-Antispam: 1Uf129KBjvJXoWxJw1DXF4DKw45Cw18Xw1rtFb_yoW5GF1rpa 43GFyDtr9aqFyxArZ7Jw1fCF98Z3yqgF4jgryjg3Z8Zan8Cw1S9FW7KryS9F95Gry8Gr1f X3ZYgF95uFWvyrUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x0pE4lksUUUUU= X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbifhC9T1rpNNMxsgAAsL X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 10 Sep 2018 03:48:03 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Mon, 10 Sep 2018 03:48:03 +0000 (UTC) for IP:'123.125.50.211' DOMAIN:'m50211.mail.qiye.163.com' HELO:'m50211.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 123.125.50.211 m50211.mail.qiye.163.com 123.125.50.211 m50211.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.38 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/6] phyp: driver: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE 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.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 10 Sep 2018 03:48:47 +0000 (UTC) X-ZohoMail: 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_AUTOCLOSE mac= ro, many of the VIR_FORCE_CLOSE calls can be dropped, which in turn leads to getting rid of many of our cleanup sections. =20 Signed-off-by: Shi Lei --- src/phyp/phyp_driver.c | 29 ++++++++++------------------- 1 file changed, 10 insertions(+), 19 deletions(-) diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 28a1fa3..c813fac 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -463,37 +463,33 @@ phypUUIDTable_WriteFile(virConnectPtr conn) phyp_driverPtr phyp_driver =3D conn->privateData; uuid_tablePtr uuid_table =3D phyp_driver->uuid_table; size_t i =3D 0; - int fd =3D -1; char local_file[] =3D "./uuid_table"; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D creat(local_file, 0755)) =3D=3D -1) - goto err; + return -1; =20 for (i =3D 0; i < uuid_table->nlpars; i++) { if (safewrite(fd, &uuid_table->lpars[i]->id, sizeof(uuid_table->lpars[i]->id)) !=3D sizeof(uuid_table->lpars[i]->id)) { VIR_ERROR(_("Unable to write information to local file.")); - goto err; + return -1; } =20 if (safewrite(fd, uuid_table->lpars[i]->uuid, VIR_UUID_BUFLEN) != =3D VIR_UUID_BUFLEN) { VIR_ERROR(_("Unable to write information to local file.")); - goto err; + return -1; } } =20 if (VIR_CLOSE(fd) < 0) { virReportSystemError(errno, _("Could not close %s"), local_file); - goto err; + return -1; } return 0; - - err: - VIR_FORCE_CLOSE(fd); - return -1; } =20 static int @@ -641,14 +637,14 @@ phypUUIDTable_ReadFile(virConnectPtr conn) phyp_driverPtr phyp_driver =3D conn->privateData; uuid_tablePtr uuid_table =3D phyp_driver->uuid_table; size_t i =3D 0; - int fd =3D -1; char local_file[] =3D "./uuid_table"; int rc =3D 0; int id; + VIR_AUTOCLOSE(fd); =20 if ((fd =3D open(local_file, O_RDONLY)) =3D=3D -1) { VIR_WARN("Unable to read information from local file."); - goto err; + return -1; } =20 /* Creating a new data base and writing to local file */ @@ -658,28 +654,23 @@ phypUUIDTable_ReadFile(virConnectPtr conn) rc =3D read(fd, &id, sizeof(int)); if (rc =3D=3D sizeof(int)) { if (VIR_ALLOC(uuid_table->lpars[i]) < 0) - goto err; + return -1; uuid_table->lpars[i]->id =3D id; } else { VIR_WARN ("Unable to read from information from local file."); - goto err; + return -1; } =20 rc =3D read(fd, uuid_table->lpars[i]->uuid, VIR_UUID_BUFLEN); if (rc !=3D VIR_UUID_BUFLEN) { VIR_WARN("Unable to read information from local file."); - goto err; + return -1; } } } =20 - VIR_FORCE_CLOSE(fd); return 0; - - err: - VIR_FORCE_CLOSE(fd); - return -1; } =20 static int --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue May 7 16:49:41 2024 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1536551296119519.7501660187861; Sun, 9 Sep 2018 20:48:16 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 66F103082137; Mon, 10 Sep 2018 03:48: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 EC91560BE1; Mon, 10 Sep 2018 03:48: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 B0E53181A12E; Mon, 10 Sep 2018 03:48:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w8A3m513021318 for ; Sun, 9 Sep 2018 23:48:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id EFCE460BE8; Mon, 10 Sep 2018 03:48:05 +0000 (UTC) Received: from mx1.redhat.com (ext-mx19.extmail.prod.ext.phx2.redhat.com [10.5.110.48]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E63D060BE1 for ; Mon, 10 Sep 2018 03:48:03 +0000 (UTC) Received: from m50211.mail.qiye.163.com (m50211.mail.qiye.163.com [123.125.50.211]) by mx1.redhat.com (Postfix) with ESMTP id 0B401307D912 for ; Mon, 10 Sep 2018 03:48:02 +0000 (UTC) Received: from localhost.localdomain (unknown [58.56.27.130]) by smtp3 (Coremail) with SMTP id PdOowEDZhkJu6ZVb8BUdAg--.502S8; Mon, 10 Sep 2018 11:48:01 +0800 (CST) From: Shi Lei To: libvir-list@redhat.com Date: Mon, 10 Sep 2018 11:47:55 +0800 Message-Id: <20180910034755.31246-7-shi_lei@massclouds.com> In-Reply-To: <20180910034755.31246-1-shi_lei@massclouds.com> References: <20180910034755.31246-1-shi_lei@massclouds.com> X-CM-TRANSID: PdOowEDZhkJu6ZVb8BUdAg--.502S8 X-Coremail-Antispam: 1Uf129KBjDUn29KB7ZKAUJUUUUU529EdanIXcx71UUUUU7v73 VFW2AGmfu7bjvjm3AaLaJ3UbIYCTnIWIevJa73UjIFyTuYvjTRxMa0DUUUU X-Originating-IP: [58.56.27.130] X-CM-SenderInfo: pvklsz1hl6ztxvvfz0xxgvhudrp/1tbidxG9T1n5eGHpBAAAsA X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 212 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 10 Sep 2018 03:48:02 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 10 Sep 2018 03:48:02 +0000 (UTC) for IP:'123.125.50.211' DOMAIN:'m50211.mail.qiye.163.com' HELO:'m50211.mail.qiye.163.com' FROM:'shi_lei@massclouds.com' RCPT:'' X-RedHat-Spam-Score: -0.01 (RCVD_IN_DNSWL_NONE) 123.125.50.211 m50211.mail.qiye.163.com 123.125.50.211 m50211.mail.qiye.163.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.48 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/6] uml: conf: use VIR_AUTOCLOSE instead of VIR_FORCE_CLOSE 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.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Mon, 10 Sep 2018 03:48:14 +0000 (UTC) X-ZohoMail: 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_AUTOCLOSE mac= ro, many of the VIR_FORCE_CLOSE calls can be dropped, which in turn leads to getting rid of many of our cleanup sections. =20 Signed-off-by: Shi Lei --- src/uml/uml_conf.c | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index f116e61..da0dc69 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -112,14 +112,14 @@ umlConnectTapDevice(virDomainDefPtr vm, const char *bridge) { bool template_ifname =3D false; - int tapfd =3D -1; + VIR_AUTOCLOSE(tapfd); =20 if (!net->ifname || STRPREFIX(net->ifname, VIR_NET_GENERATED_TAP_PREFIX) || strchr(net->ifname, '%')) { VIR_FREE(net->ifname); if (VIR_STRDUP(net->ifname, VIR_NET_GENERATED_TAP_PREFIX "%d") < 0) - goto error; + return -1; /* avoid exposing vnet%d in getXMLDesc or error outputs */ template_ifname =3D true; } @@ -133,23 +133,18 @@ umlConnectTapDevice(virDomainDefPtr vm, VIR_NETDEV_TAP_CREATE_PERSIST) < 0)= { if (template_ifname) VIR_FREE(net->ifname); - goto error; + return -1; } =20 if (net->filter) { if (virDomainConfNWFilterInstantiate(vm->name, vm->uuid, net, fals= e) < 0) { if (template_ifname) VIR_FREE(net->ifname); - goto error; + return -1; } } =20 - VIR_FORCE_CLOSE(tapfd); return 0; - - error: - VIR_FORCE_CLOSE(tapfd); - return -1; } =20 static char * --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list