From nobody Sun Feb 8 16:49:56 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1564671683; cv=none; d=zoho.com; s=zohoarc; b=DgF/83Wge37HhFYEsn4ENHCA8nMBnQyAUNrabWvMmEjOcVH1A36vs/jEqg3FVc8k9/2qG8cKuSSsqxG3S4o4Tf9HkxMpo80N4WuV1b94N7tDkXuxrB76pXnaPxggQuIlV4PxOyQ4TXB9d/6LLiTVPzqTyxIXv2Q3GnNRxQDOaus= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1564671683; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=Do7+vNGLdf9paXfFhpyf8rIOnBzxnjOVlUOQ7qBPh20=; b=fGKDawIgpLmvRxZpz/pP8hETDAnq20/FTrzTfHdA2jKoDa/Bz90/k3Y2vd45w5BRgQ1z+osyWtpLP/Punw7ZedQ/EAT3u2HpbN7y6oyYZUXdsQ1TdgjDj7yxybkeYvTTsDxt7OCwulXAKuPk6RAo+JzpYbsYggEclYZsq50eNyY= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1564671683971209.52253465370325; Thu, 1 Aug 2019 08:01:23 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 2235D369CC; Thu, 1 Aug 2019 15:01:22 +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 E186610002BA; Thu, 1 Aug 2019 15:01:21 +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 80DDA180BAA1; Thu, 1 Aug 2019 15:01:21 +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 x71F1Hq1032209 for ; Thu, 1 Aug 2019 11:01:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id CE65B19696; Thu, 1 Aug 2019 15:01:17 +0000 (UTC) Received: from domokun.gsslab.fab.redhat.com (dhcp-94.gsslab.fab.redhat.com [10.33.9.94]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3C556196FF; Thu, 1 Aug 2019 15:01:00 +0000 (UTC) From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Date: Thu, 1 Aug 2019 16:00:11 +0100 Message-Id: <20190801150019.10519-10-berrange@redhat.com> In-Reply-To: <20190801150019.10519-1-berrange@redhat.com> References: <20190801150019.10519-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/17] nss: remove use for virDir helper APIs 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: , Content-Type: text/plain; charset="utf-8" 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.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Thu, 01 Aug 2019 15:01:22 +0000 (UTC) Use the plain libc APIs to avoid a dependancy on the main libvirt code from the nss module. Signed-off-by: Daniel P. Berrang=C3=A9 --- cfg.mk | 2 +- tools/nss/libvirt_nss.c | 13 +++++++++---- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/cfg.mk b/cfg.mk index ec09550b49..f2b326ec94 100644 --- a/cfg.mk +++ b/cfg.mk @@ -1338,7 +1338,7 @@ exclude_file_name_regexp--sc_prohibit_always-defined_= macros =3D \ ^tests/virtestmock.c$$ =20 exclude_file_name_regexp--sc_prohibit_readdir =3D \ - ^tests/(.*mock|virfilewrapper)\.c$$ + ^(tests/(.*mock|virfilewrapper)\.c|tools/nss/libvirt_nss\.c)$$ =20 exclude_file_name_regexp--sc_prohibit_cross_inclusion =3D \ ^(src/util/virclosecallbacks\.h|src/util/virhostdev\.h)$$ diff --git a/tools/nss/libvirt_nss.c b/tools/nss/libvirt_nss.c index 519046a4e0..f50dec48ba 100644 --- a/tools/nss/libvirt_nss.c +++ b/tools/nss/libvirt_nss.c @@ -281,7 +281,8 @@ findLease(const char *name, goto cleanup; } =20 - if (virDirOpenQuiet(&dir, leaseDir) < 0) { + dir =3D opendir(leaseDir); + if (!dir) { ERROR("Failed to open dir '%s'", leaseDir); goto cleanup; } @@ -292,7 +293,7 @@ findLease(const char *name, } =20 DEBUG("Dir: %s", leaseDir); - while ((ret =3D virDirRead(dir, &entry, leaseDir)) > 0) { + while ((entry =3D readdir(dir)) !=3D NULL) { char *path; =20 if (virStringHasSuffix(entry->d_name, ".status")) { @@ -324,8 +325,11 @@ findLease(const char *name, nMacmaps++; VIR_FREE(path); } + + errno =3D 0; } - VIR_DIR_CLOSE(dir); + closedir(dir); + dir =3D NULL; =20 nleases =3D virJSONValueArraySize(leases_array); DEBUG("Read %zd leases", nleases); @@ -363,7 +367,8 @@ findLease(const char *name, =20 cleanup: *errnop =3D errno; - VIR_DIR_CLOSE(dir); + if (dir) + closedir(dir); while (nMacmaps) virObjectUnref(macmaps[--nMacmaps]); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list