From nobody Thu Apr 25 15:30:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1572690382; cv=none; d=zoho.com; s=zohoarc; b=JY1m2JQAYpFJ0ow/0zV1akrAbMuSpb5gH0ignLDIHwM9iOMkWRldY1xydPKADQjyCnwMxa0+VvqLr9fWZCcHEi2/oXb4LIYx90A8L5oRpWP72xqgXFP/6BfXK3UQsZI64n3XaPrbwlqFu6Lzq17ltrddiLgdutlPRi6pK0TMLxg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572690382; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ODClMVzE1elo5MKyrRYIAMlHsr3tjEkYxHokcgIdun4=; b=i9TzPf6v36FxnnPv2fmLtYzCSx1c4w1D2RLj4XyJsez7tEgBaZ/2qGeTdz+8iNQXDAV2KK0jwIHbuOCmUqsAJrjYut6+pXaLM1gYBJL7i2Y8proc+kNBK1p39yuO2ka+eee3bUrxNyF51simKKqYlKqsL7oYamZyiTrNmzvgAdw= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1572690382061628.6126494909373; Sat, 2 Nov 2019 03:26:22 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-340-qWzPUS6zOm6uQYEZlQ8r_g-1; Sat, 02 Nov 2019 06:26:18 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23D09800EBA; Sat, 2 Nov 2019 10:26: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 E427F1001B34; Sat, 2 Nov 2019 10:26:13 +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 7426718089CF; Sat, 2 Nov 2019 10:26:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9V4PPMI020365 for ; Thu, 31 Oct 2019 00:25:28 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8E8B960870; Thu, 31 Oct 2019 04:25:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx17.extmail.prod.ext.phx2.redhat.com [10.5.110.46]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 891E260852 for ; Thu, 31 Oct 2019 04:25:23 +0000 (UTC) Received: from regular1.263xmail.com (regular1.263xmail.com [211.150.70.203]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 673E53082D60 for ; Thu, 31 Oct 2019 04:25:19 +0000 (UTC) Received: from localhost (unknown [192.168.167.13]) by regular1.263xmail.com (Postfix) with ESMTP id 23AE2368 for ; Thu, 31 Oct 2019 12:25:13 +0800 (CST) Received: from localhost.localdomain (unknown [14.18.236.69]) by smtp.263.net (postfix) whith ESMTP id P14239T139772539672320S1572495908400366_; Thu, 31 Oct 2019 12:25:13 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572690380; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ODClMVzE1elo5MKyrRYIAMlHsr3tjEkYxHokcgIdun4=; b=X3xQsZ3CtyyW8nEYGyQHC7zkJqmsz8MRgpHtQO39ocgNR3WgDojB1Dq7Q7CG4FqvFQGSBi 20FhLnlkN4wX5PNLJbYEJYBKySo593TItkPvUedHVdbHL9hrjiO9cp8U1FVxoVu/PvApiZ K4c21/XsFcAxug6mZpm8JTRATKrb6Nc= X-MAIL-GRAY: 0 X-MAIL-DELIVERY: 1 X-ADDR-CHECKED4: 1 X-ANTISPAM-LEVEL: 2 X-SKE-CHECKED: 1 X-ABS-CHECKED: 1 X-IP-DOMAINF: 1 X-UNIQUE-TAG: <1cfbd63341681dbf13798574c30866d0> X-RL-SENDER: yili@winhong.com X-SENDER: yili@winhong.com X-LOGIN-NAME: yili@winhong.com X-FST-TO: libvir-list@redhat.com X-SENDER-IP: 14.18.236.69 X-ATTACHMENT-NUM: 0 X-DNS-TYPE: 0 From: Yi Li To: libvir-list@redhat.com Date: Thu, 31 Oct 2019 12:25:00 +0800 Message-Id: <1572495900-31014-1-git-send-email-yili@winhong.com> MIME-Version: 1.0 X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 31 Oct 2019 04:25:20 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.46]); Thu, 31 Oct 2019 04:25:20 +0000 (UTC) for IP:'211.150.70.203' DOMAIN:'regular1.263xmail.com' HELO:'regular1.263xmail.com' FROM:'yili@winhong.com' RCPT:'' X-RedHat-Spam-Score: 0 (RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS) 211.150.70.203 regular1.263xmail.com 211.150.70.203 regular1.263xmail.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.46 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Sat, 02 Nov 2019 06:25:47 -0400 Cc: jtomko@redhat.com, yili@winhong.com Subject: [libvirt] [PATCH v2] storage: improve the while loop virStorageBackendFileSystemIsMounted 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: , 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-MC-Unique: qWzPUS6zOm6uQYEZlQ8r_g-1 X-Mimecast-Spam-Score: 0 Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move virStorageBackendFileSystemGetPoolSource outside of the while loop Signed-off-by: Yi Li --- src/storage/storage_backend_fs.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 02b8248..92516c8 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -258,10 +258,10 @@ virStorageBackendFileSystemIsMounted(virStoragePoolOb= jPtr pool) goto cleanup; } =20 - while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) !=3D NULL) { - if (!(src =3D virStorageBackendFileSystemGetPoolSource(pool))) - goto cleanup; + if ((src =3D virStorageBackendFileSystemGetPoolSource(pool)) =3D=3D NU= LL) + goto cleanup; =20 + while ((getmntent_r(mtab, &ent, buf, sizeof(buf))) !=3D NULL) { /* compare both mount destinations and sources to be sure the moun= ted * FS pool is really the one we're looking for */ @@ -274,12 +274,13 @@ virStorageBackendFileSystemIsMounted(virStoragePoolOb= jPtr pool) goto cleanup; } =20 - VIR_FREE(src); } =20 ret =3D 0; =20 cleanup: + if (src) + VIR_FREE(src); VIR_FORCE_FCLOSE(mtab); return ret; } --=20 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list