Use virDirOpenQuiet

Remove all the remaining usage of opendir.
This commit is contained in:
Ján Tomko 2016-06-21 16:52:37 +02:00
parent 7a5df06e10
commit 994b024624
7 changed files with 8 additions and 11 deletions

View File

@ -1058,8 +1058,7 @@ static int openvzAssignUUIDs(void)
if (conf_dir == NULL)
return -1;
dp = opendir(conf_dir);
if (dp == NULL) {
if (virDirOpenQuiet(&dp, conf_dir) < 0) {
VIR_FREE(conf_dir);
return 0;
}

View File

@ -111,7 +111,7 @@ qemuHostdevHostSupportsPassthroughVFIO(void)
int direrr;
/* condition 1 - /sys/kernel/iommu_groups/ contains entries */
if (!(iommuDir = opendir("/sys/kernel/iommu_groups/")))
if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0)
goto cleanup;
while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0) {

View File

@ -1917,7 +1917,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
* get created.
*/
reopen:
if ((dh = opendir(pool->def->target.path)) == NULL) {
if (virDirOpenQuiet(&dh, pool->def->target.path) < 0) {
opentries++;
if (loop && errno == ENOENT && opentries < 50) {
usleep(100 * 1000);

View File

@ -3378,8 +3378,7 @@ virCgroupRemoveRecursively(char *grppath)
int rc = 0;
int direrr;
grpdir = opendir(grppath);
if (grpdir == NULL) {
if (virDirOpenQuiet(&grpdir, grppath) < 0) {
if (errno == ENOENT)
return 0;
rc = -errno;

View File

@ -641,7 +641,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
if (virAsprintf(&sysfs_nodedir, "%s/node", sysfs_system_path) < 0)
goto cleanup;
if (!(nodedir = opendir(sysfs_nodedir))) {
if (virDirOpenQuiet(&nodedir, sysfs_nodedir) < 0) {
/* the host isn't probably running a NUMA architecture */
goto fallback;
}

View File

@ -2011,7 +2011,7 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig,
orig->domain, orig->bus, orig->slot, orig->function) < 0)
goto cleanup;
if (!(groupDir = opendir(groupPath))) {
if (virDirOpenQuiet(&groupDir, groupPath) < 0) {
/* just process the original device, nothing more */
ret = (actor)(orig, opaque);
goto cleanup;
@ -2683,8 +2683,7 @@ virPCIGetNetName(char *device_link_sysfs_path, char **netname)
return -1;
}
dir = opendir(pcidev_sysfs_net_path);
if (dir == NULL)
if (virDirOpenQuiet(&dir, pcidev_sysfs_net_path) < 0)
goto out;
while (virDirRead(dir, &entry, pcidev_sysfs_net_path) > 0) {

View File

@ -125,7 +125,7 @@ findLease(const char *name,
}
if (!(dir = opendir(leaseDir))) {
if (virDirOpenQuiet(&dir, leaseDir) < 0) {
ERROR("Failed to open dir '%s'", leaseDir);
goto cleanup;
}