From nobody Thu Apr 25 02:02:53 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1572690390; cv=none; d=zoho.com; s=zohoarc; b=eogOHT6oWNRcbuKggMLT/F3UdHAuKUzLL5i93Sv4rM3A9cD3aZ2dhbN4O0K+cfxfxRIrPHbOMCh9wBQSkhW/iNDx7p6riJU9uMjowH1es7TPScdHzG6UPsw0H9ysqw3+/PhW6fl8n51zIKe8iUj9QyKZj2GSg2PmRdMX0sZm91I= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1572690390; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=P7L0b5Up+nBSMdITfRYsolaV7Jf0LT/iPcN0+1cykcE=; b=hT7vHHu6uyYkg53EEAK9VVR44ZLCUWs1Gu3UKeuTd/+Jzvtnf+xiOuP8Nn/aJsfAEZQ7akr0v//x1m+171rOeFlovfvMCsenNJI2o+d/Dw2f9YXLO5WdegV+Sl/pbTIgzaILnmTn6ZoAg49kq0m886vNOdeIFPiFq8dOYUQwCVU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1572690390035186.64150894612794; Sat, 2 Nov 2019 03:26:30 -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-324-k6cZc8T7Mf2Vn2OMUZIXxg-1; Sat, 02 Nov 2019 06:26:18 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 23C12107ACC3; Sat, 2 Nov 2019 10:26:14 +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 E768560127; 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 765344E567; Sat, 2 Nov 2019 10:26:13 +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 xA17YZXZ017667 for ; Fri, 1 Nov 2019 03:34:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2CCD95D9D6; Fri, 1 Nov 2019 07:34:35 +0000 (UTC) Received: from mx1.redhat.com (ext-mx03.extmail.prod.ext.phx2.redhat.com [10.5.110.27]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 272175D9CA for ; Fri, 1 Nov 2019 07:34:32 +0000 (UTC) Received: from mail-yb1-f195.google.com (mail-yb1-f195.google.com [209.85.219.195]) (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 43FD583F4C for ; Fri, 1 Nov 2019 07:34:32 +0000 (UTC) Received: by mail-yb1-f195.google.com with SMTP id c13so3557177ybq.3 for ; Fri, 01 Nov 2019 00:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1572690389; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=P7L0b5Up+nBSMdITfRYsolaV7Jf0LT/iPcN0+1cykcE=; b=EcIgA5eknH7V0PgBAK94DdGYreDEwVnimxeGFC/rDgSsNExIJ8LLUx6Th8GAVnyCQy5wKo BNhubixezVVd3pJ6qkHl1ixQsxz3KbLYEytqVcL6uOdoRRcwtoEQhJCkFrP8Fq5uNdNm0o HNHSazmMON4XS+/3Nfga+7d5MCcfwec= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=ZpVcf84Di/CbubN1zSFmuPdmkh2KoWy8CHJOF4E4Rnc=; b=MdMSrCDUqHItCOQq9N6j5TUtxXKARQ3THepK/I1HSwQHaTjbg+/RRXU4ppApVItBFi qAxlu5PxSj4Dk0SkAjLJ30C4T3p28gxzkuOjvMacD8OfPaXv5V+I47FbdhfRhsR15ksJ WJMExDT4K6M84a9QPFR11BO6gDD/SxiLwpbsQiJ6SgHDLxZ+9F/5MjDamW/Sj75jB1HF L/PY5O6vzSgAXzt6bn2OmxbAqP/abh0TwB4eCHp72QUnJL6zo0B7+cMOoCrVouP19Goc WCTVh4HVyBWdl+apDDkoMtUMKxyAE9Ndx5carw7jjr0AHZHrgYgSHalMcFdB24W/9eM4 Szzg== X-Gm-Message-State: APjAAAWbu7OLRSLk03ySJUdQWIOhHo2Q3q61M8Nssy0F+je1gYpaYaWL t3FgNL3LgXTjL4srU0rnWIM05+6qGe0O21/o6NYsuLPFPdA= X-Google-Smtp-Source: APXvYqxYXNaoU0DHqqV8bnLXarDv+XdiZHSp0fh8/vvppRGae9fk0v+0k/0j5hnJUXfALZBa9GdPS4I53C6EWzy3fws= X-Received: by 2002:a25:6ec5:: with SMTP id j188mr8386656ybc.207.1572593671056; Fri, 01 Nov 2019 00:34:31 -0700 (PDT) MIME-Version: 1.0 From: =?UTF-8?B?5p2O5LmJ?= Date: Fri, 1 Nov 2019 15:34:25 +0800 Message-ID: To: libvir-list@redhat.com X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 01 Nov 2019 07:34:32 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Fri, 01 Nov 2019 07:34:32 +0000 (UTC) for IP:'209.85.219.195' DOMAIN:'mail-yb1-f195.google.com' HELO:'mail-yb1-f195.google.com' FROM:'yilikernel@gmail.com' RCPT:'' X-RedHat-Spam-Score: -0.1 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.219.195 mail-yb1-f195.google.com 209.85.219.195 mail-yb1-f195.google.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.27 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Sat, 02 Nov 2019 06:25:47 -0400 Subject: [libvirt] [PATCH] storage: Don't get src in each loop since src is not changed 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.79 on 10.5.11.11 X-MC-Unique: k6cZc8T7Mf2Vn2OMUZIXxg-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" The src of pool is not changed in each loop, so don't VIR_FREE(src) and get when next iteration. Signed-off-by: Yi Li Reviewed-by: J=C3=A1n Tomko --- src/storage/storage_backend_fs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend= _fs.c index 02b8248..27c1098 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -258,10 +258,10 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool) goto cleanup; } - 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; + 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 */ @@ -273,8 +273,6 @@ virStorageBackendFileSystemIsMounted(virStoragePoolObjPtr pool) ret =3D 1; goto cleanup; } - - VIR_FREE(src); } ret =3D 0; -- 2.7.5 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list