提交 a4e6f1eb 编写于 作者: J Ján Tomko

Introduce VIR_DIR_CLOSE

Introduce a helper that only calls closedir if DIR* is non-NULL
and sets it to NULL afterwards.
上级 44f5b3f8
...@@ -421,9 +421,9 @@ sc_prohibit_gethostname: ...@@ -421,9 +421,9 @@ sc_prohibit_gethostname:
$(_sc_search_regexp) $(_sc_search_regexp)
sc_prohibit_readdir: sc_prohibit_readdir:
@prohibit='\breaddir *\(' \ @prohibit='\b(read|close)dir *\(' \
exclude='exempt from syntax-check' \ exclude='exempt from syntax-check' \
halt='use virDirRead, not readdir' \ halt='use virDirRead and VIR_DIR_CLOSE' \
$(_sc_search_regexp) $(_sc_search_regexp)
sc_prohibit_gettext_noop: sc_prohibit_gettext_noop:
......
...@@ -3258,7 +3258,7 @@ virNetworkLoadAllState(virNetworkObjListPtr nets, ...@@ -3258,7 +3258,7 @@ virNetworkLoadAllState(virNetworkObjListPtr nets,
virNetworkObjEndAPI(&net); virNetworkObjEndAPI(&net);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
...@@ -3298,7 +3298,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets, ...@@ -3298,7 +3298,7 @@ int virNetworkLoadAllConfigs(virNetworkObjListPtr nets,
virNetworkObjEndAPI(&net); virNetworkObjEndAPI(&net);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
......
...@@ -3227,7 +3227,7 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters, ...@@ -3227,7 +3227,7 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters,
virNWFilterObjUnlock(nwfilter); virNWFilterObjUnlock(nwfilter);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
......
...@@ -1964,7 +1964,7 @@ virStoragePoolLoadAllState(virStoragePoolObjListPtr pools, ...@@ -1964,7 +1964,7 @@ virStoragePoolLoadAllState(virStoragePoolObjListPtr pools,
virStoragePoolObjUnlock(pool); virStoragePoolObjUnlock(pool);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
...@@ -2015,7 +2015,7 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools, ...@@ -2015,7 +2015,7 @@ virStoragePoolLoadAllConfigs(virStoragePoolObjListPtr pools,
VIR_FREE(autostartLink); VIR_FREE(autostartLink);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
......
...@@ -616,7 +616,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms, ...@@ -616,7 +616,7 @@ virDomainObjListLoadAllConfigs(virDomainObjListPtr doms,
} }
} }
closedir(dir); VIR_DIR_CLOSE(dir);
virObjectUnlock(doms); virObjectUnlock(doms);
return ret; return ret;
} }
......
...@@ -1000,6 +1000,6 @@ virSecretLoadAllConfigs(virSecretObjListPtr secrets, ...@@ -1000,6 +1000,6 @@ virSecretLoadAllConfigs(virSecretObjListPtr secrets,
virSecretObjEndAPI(&secret); virSecretObjEndAPI(&secret);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return 0; return 0;
} }
...@@ -1493,6 +1493,7 @@ saferead; ...@@ -1493,6 +1493,7 @@ saferead;
safewrite; safewrite;
safezero; safezero;
virBuildPathInternal; virBuildPathInternal;
virDirClose;
virDirCreate; virDirCreate;
virDirRead; virDirRead;
virFileAbsPath; virFileAbsPath;
......
...@@ -577,7 +577,7 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver) ...@@ -577,7 +577,7 @@ networkMigrateStateFiles(virNetworkDriverStatePtr driver)
ret = 0; ret = 0;
cleanup: cleanup:
closedir(dir); VIR_DIR_CLOSE(dir);
VIR_FREE(oldPath); VIR_FREE(oldPath);
VIR_FREE(newPath); VIR_FREE(newPath);
VIR_FREE(contents); VIR_FREE(contents);
......
...@@ -1072,7 +1072,7 @@ static int openvzAssignUUIDs(void) ...@@ -1072,7 +1072,7 @@ static int openvzAssignUUIDs(void)
openvzSetUUID(vpsid); openvzSetUUID(vpsid);
} }
closedir(dp); VIR_DIR_CLOSE(dp);
VIR_FREE(conf_dir); VIR_FREE(conf_dir);
return ret; return ret;
} }
......
...@@ -587,8 +587,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm, ...@@ -587,8 +587,7 @@ qemuDomainSnapshotLoad(virDomainObjPtr vm,
ret = 0; ret = 0;
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FREE(snapDir); VIR_FREE(snapDir);
virObjectUnref(caps); virObjectUnref(caps);
virObjectUnlock(vm); virObjectUnlock(vm);
......
...@@ -134,9 +134,7 @@ qemuHostdevHostSupportsPassthroughVFIO(void) ...@@ -134,9 +134,7 @@ qemuHostdevHostSupportsPassthroughVFIO(void)
ret = true; ret = true;
cleanup: cleanup:
if (iommuDir) VIR_DIR_CLOSE(iommuDir);
closedir(iommuDir);
return ret; return ret;
} }
......
...@@ -1946,12 +1946,12 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, ...@@ -1946,12 +1946,12 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
if (virAsprintf(&stablepath, "%s/%s", if (virAsprintf(&stablepath, "%s/%s",
pool->def->target.path, pool->def->target.path,
dent->d_name) == -1) { dent->d_name) == -1) {
closedir(dh); VIR_DIR_CLOSE(dh);
return NULL; return NULL;
} }
if (virFileLinkPointsTo(stablepath, devpath)) { if (virFileLinkPointsTo(stablepath, devpath)) {
closedir(dh); VIR_DIR_CLOSE(dh);
return stablepath; return stablepath;
} }
...@@ -1963,7 +1963,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool, ...@@ -1963,7 +1963,7 @@ virStorageBackendStablePath(virStoragePoolObjPtr pool,
goto retry; goto retry;
} }
closedir(dh); VIR_DIR_CLOSE(dh);
ret_strdup: ret_strdup:
/* Couldn't find any matching stable link so give back /* Couldn't find any matching stable link so give back
......
...@@ -972,8 +972,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -972,8 +972,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
} }
if (direrr < 0) if (direrr < 0)
goto cleanup; goto cleanup;
closedir(dir); VIR_DIR_CLOSE(dir);
dir = NULL;
vol = NULL; vol = NULL;
if (VIR_ALLOC(target)) if (VIR_ALLOC(target))
...@@ -1019,8 +1018,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED, ...@@ -1019,8 +1018,7 @@ virStorageBackendFileSystemRefresh(virConnectPtr conn ATTRIBUTE_UNUSED,
ret = 0; ret = 0;
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
virStorageVolDefFree(vol); virStorageVolDefFree(vol);
virStorageSourceFree(target); virStorageSourceFree(target);
......
...@@ -122,7 +122,7 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path, ...@@ -122,7 +122,7 @@ virStorageBackendISCSIGetHostNumber(const char *sysfs_path,
if (direrr < 0) if (direrr < 0)
retval = -1; retval = -1;
closedir(sysdir); VIR_DIR_CLOSE(sysdir);
out: out:
return retval; return retval;
} }
......
...@@ -290,8 +290,7 @@ getNewStyleBlockDevice(const char *lun_path, ...@@ -290,8 +290,7 @@ getNewStyleBlockDevice(const char *lun_path,
retval = 0; retval = 0;
cleanup: cleanup:
if (block_dir) VIR_DIR_CLOSE(block_dir);
closedir(block_dir);
VIR_FREE(block_path); VIR_FREE(block_path);
return retval; return retval;
} }
...@@ -387,8 +386,7 @@ getBlockDevice(uint32_t host, ...@@ -387,8 +386,7 @@ getBlockDevice(uint32_t host,
retval = 0; retval = 0;
cleanup: cleanup:
if (lun_dir) VIR_DIR_CLOSE(lun_dir);
closedir(lun_dir);
VIR_FREE(lun_path); VIR_FREE(lun_path);
return retval; return retval;
} }
...@@ -501,7 +499,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, ...@@ -501,7 +499,7 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool,
found++; found++;
} }
closedir(devicedir); VIR_DIR_CLOSE(devicedir);
if (retval < 0) if (retval < 0)
return -1; return -1;
......
...@@ -3409,7 +3409,7 @@ virCgroupRemoveRecursively(char *grppath) ...@@ -3409,7 +3409,7 @@ virCgroupRemoveRecursively(char *grppath)
VIR_ERROR(_("Failed to readdir for %s (%d)"), grppath, errno); VIR_ERROR(_("Failed to readdir for %s (%d)"), grppath, errno);
} }
closedir(grpdir); VIR_DIR_CLOSE(grpdir);
VIR_DEBUG("Removing cgroup %s", grppath); VIR_DEBUG("Removing cgroup %s", grppath);
if (rmdir(grppath) != 0 && errno != ENOENT) { if (rmdir(grppath) != 0 && errno != ENOENT) {
...@@ -3669,9 +3669,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group, ...@@ -3669,9 +3669,7 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
cleanup: cleanup:
virCgroupFree(&subgroup); virCgroupFree(&subgroup);
VIR_FREE(keypath); VIR_FREE(keypath);
if (dp) VIR_DIR_CLOSE(dp);
closedir(dp);
return ret; return ret;
} }
...@@ -3993,15 +3991,13 @@ int virCgroupSetOwner(virCgroupPtr cgroup, ...@@ -3993,15 +3991,13 @@ int virCgroupSetOwner(virCgroupPtr cgroup,
} }
VIR_FREE(base); VIR_FREE(base);
closedir(dh); VIR_DIR_CLOSE(dh);
dh = NULL;
} }
ret = 0; ret = 0;
cleanup: cleanup:
if (dh) VIR_DIR_CLOSE(dh);
closedir(dh);
VIR_FREE(entry); VIR_FREE(entry);
VIR_FREE(base); VIR_FREE(base);
return ret; return ret;
......
...@@ -667,8 +667,7 @@ static int virFileLoopDeviceOpenSearch(char **dev_name) ...@@ -667,8 +667,7 @@ static int virFileLoopDeviceOpenSearch(char **dev_name)
VIR_DEBUG("No free loop devices available"); VIR_DEBUG("No free loop devices available");
VIR_FREE(looppath); VIR_FREE(looppath);
} }
if (dh) VIR_DIR_CLOSE(dh);
closedir(dh);
return fd; return fd;
} }
...@@ -807,7 +806,7 @@ virFileNBDDeviceFindUnused(void) ...@@ -807,7 +806,7 @@ virFileNBDDeviceFindUnused(void)
_("No free NBD devices")); _("No free NBD devices"));
cleanup: cleanup:
closedir(dh); VIR_DIR_CLOSE(dh);
return ret; return ret;
} }
...@@ -994,7 +993,7 @@ int virFileDeleteTree(const char *dir) ...@@ -994,7 +993,7 @@ int virFileDeleteTree(const char *dir)
cleanup: cleanup:
VIR_FREE(filepath); VIR_FREE(filepath);
closedir(dh); VIR_DIR_CLOSE(dh);
return ret; return ret;
} }
...@@ -2770,6 +2769,15 @@ int virDirRead(DIR *dirp, struct dirent **ent, const char *name) ...@@ -2770,6 +2769,15 @@ int virDirRead(DIR *dirp, struct dirent **ent, const char *name)
return !!*ent; return !!*ent;
} }
void virDirClose(DIR **dirp)
{
if (!*dirp)
return;
closedir(*dirp); /* exempt from syntax-check */
*dirp = NULL;
}
static int static int
virFileMakePathHelper(char *path, mode_t mode) virFileMakePathHelper(char *path, mode_t mode)
{ {
......
...@@ -232,6 +232,9 @@ int virDirCreate(const char *path, mode_t mode, uid_t uid, gid_t gid, ...@@ -232,6 +232,9 @@ int virDirCreate(const char *path, mode_t mode, uid_t uid, gid_t gid,
unsigned int flags) ATTRIBUTE_RETURN_CHECK; unsigned int flags) ATTRIBUTE_RETURN_CHECK;
int virDirRead(DIR *dirp, struct dirent **ent, const char *dirname) int virDirRead(DIR *dirp, struct dirent **ent, const char *dirname)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK; ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_RETURN_CHECK;
void virDirClose(DIR **dirp)
ATTRIBUTE_NONNULL(1);
# define VIR_DIR_CLOSE(dir) virDirClose(&(dir))
int virFileMakePath(const char *path) ATTRIBUTE_RETURN_CHECK; int virFileMakePath(const char *path) ATTRIBUTE_RETURN_CHECK;
int virFileMakePathWithMode(const char *path, int virFileMakePathWithMode(const char *path,
......
...@@ -477,8 +477,7 @@ virHostCPUParseNode(const char *node, ...@@ -477,8 +477,7 @@ virHostCPUParseNode(const char *node,
ret = processors; ret = processors;
cleanup: cleanup:
if (cpudir) VIR_DIR_CLOSE(cpudir);
closedir(cpudir);
if (cores_maps) if (cores_maps)
for (i = 0; i < sock_max; i++) for (i = 0; i < sock_max; i++)
virBitmapFree(cores_maps[i]); virBitmapFree(cores_maps[i]);
...@@ -774,8 +773,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo, ...@@ -774,8 +773,7 @@ virHostCPUGetInfoPopulateLinux(FILE *cpuinfo,
ret = 0; ret = 0;
cleanup: cleanup:
if (nodedir) VIR_DIR_CLOSE(nodedir);
closedir(nodedir);
virBitmapFree(present_cpus_map); virBitmapFree(present_cpus_map);
virBitmapFree(online_cpus_map); virBitmapFree(online_cpus_map);
VIR_FREE(sysfs_nodedir); VIR_FREE(sysfs_nodedir);
......
...@@ -3188,7 +3188,7 @@ virNetDevRDMAFeature(const char *ifname, ...@@ -3188,7 +3188,7 @@ virNetDevRDMAFeature(const char *ifname,
ret = 0; ret = 0;
cleanup: cleanup:
closedir(dirp); VIR_DIR_CLOSE(dirp);
VIR_FREE(eth_devpath); VIR_FREE(eth_devpath);
VIR_FREE(ib_devpath); VIR_FREE(ib_devpath);
VIR_FREE(eth_res_buf); VIR_FREE(eth_res_buf);
......
...@@ -144,7 +144,7 @@ virNetDevTapGetRealDeviceName(char *ifname ATTRIBUTE_UNUSED) ...@@ -144,7 +144,7 @@ virNetDevTapGetRealDeviceName(char *ifname ATTRIBUTE_UNUSED)
cleanup: cleanup:
VIR_FREE(devpath); VIR_FREE(devpath);
VIR_FORCE_CLOSE(fd); VIR_FORCE_CLOSE(fd);
closedir(dirp); VIR_DIR_CLOSE(dirp);
return ret; return ret;
#else #else
return NULL; return NULL;
......
...@@ -833,8 +833,7 @@ virNumaGetPages(int node, ...@@ -833,8 +833,7 @@ virNumaGetPages(int node,
VIR_FREE(tmp_free); VIR_FREE(tmp_free);
VIR_FREE(tmp_avail); VIR_FREE(tmp_avail);
VIR_FREE(tmp_size); VIR_FREE(tmp_size);
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FREE(path); VIR_FREE(path);
return ret; return ret;
} }
......
...@@ -509,7 +509,7 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate, ...@@ -509,7 +509,7 @@ virPCIDeviceIterDevices(virPCIDeviceIterPredicate predicate,
virPCIDeviceFree(check); virPCIDeviceFree(check);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
...@@ -1993,8 +1993,7 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev, ...@@ -1993,8 +1993,7 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev,
ret = 0; ret = 0;
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FREE(file); VIR_FREE(file);
VIR_FREE(pcidir); VIR_FREE(pcidir);
return ret; return ret;
...@@ -2051,8 +2050,7 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig, ...@@ -2051,8 +2050,7 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig,
cleanup: cleanup:
VIR_FREE(groupPath); VIR_FREE(groupPath);
if (groupDir) VIR_DIR_CLOSE(groupDir);
closedir(groupDir);
return ret; return ret;
} }
...@@ -2713,7 +2711,7 @@ virPCIGetNetName(char *device_link_sysfs_path, char **netname) ...@@ -2713,7 +2711,7 @@ virPCIGetNetName(char *device_link_sysfs_path, char **netname)
break; break;
} }
closedir(dir); VIR_DIR_CLOSE(dir);
out: out:
VIR_FREE(pcidev_sysfs_net_path); VIR_FREE(pcidev_sysfs_net_path);
......
...@@ -637,8 +637,7 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) ...@@ -637,8 +637,7 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids)
ret = 0; ret = 0;
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FREE(taskPath); VIR_FREE(taskPath);
if (ret < 0) if (ret < 0)
VIR_FREE(*pids); VIR_FREE(*pids);
......
...@@ -143,8 +143,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix, ...@@ -143,8 +143,7 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
} }
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FREE(path); VIR_FREE(path);
return sg; return sg;
} }
...@@ -189,8 +188,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix, ...@@ -189,8 +188,7 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
} }
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
VIR_FREE(path); VIR_FREE(path);
return name; return name;
} }
......
...@@ -202,9 +202,7 @@ virUSBDeviceSearch(unsigned int vendor, ...@@ -202,9 +202,7 @@ virUSBDeviceSearch(unsigned int vendor,
ret = list; ret = list;
cleanup: cleanup:
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
if (!ret) if (!ret)
virObjectUnref(list); virObjectUnref(list);
return ret; return ret;
......
...@@ -1915,7 +1915,7 @@ virFindSCSIHostByPCI(const char *sysfs_prefix, ...@@ -1915,7 +1915,7 @@ virFindSCSIHostByPCI(const char *sysfs_prefix,
} }
cleanup: cleanup:
closedir(dir); VIR_DIR_CLOSE(dir);
VIR_FREE(unique_path); VIR_FREE(unique_path);
VIR_FREE(host_link); VIR_FREE(host_link);
VIR_FREE(host_path); VIR_FREE(host_path);
...@@ -2265,7 +2265,7 @@ virGetFCHostNameByWWN(const char *sysfs_prefix, ...@@ -2265,7 +2265,7 @@ virGetFCHostNameByWWN(const char *sysfs_prefix,
cleanup: cleanup:
# undef READ_WWN # undef READ_WWN
closedir(dir); VIR_DIR_CLOSE(dir);
VIR_FREE(wwnn_path); VIR_FREE(wwnn_path);
VIR_FREE(wwpn_path); VIR_FREE(wwpn_path);
VIR_FREE(wwnn_buf); VIR_FREE(wwnn_buf);
...@@ -2354,7 +2354,7 @@ virFindFCHostCapableVport(const char *sysfs_prefix) ...@@ -2354,7 +2354,7 @@ virFindFCHostCapableVport(const char *sysfs_prefix)
} }
cleanup: cleanup:
closedir(dir); VIR_DIR_CLOSE(dir);
VIR_FREE(max_vports); VIR_FREE(max_vports);
VIR_FREE(vports); VIR_FREE(vports);
return ret; return ret;
......
...@@ -372,21 +372,21 @@ xenInotifyOpen(virConnectPtr conn, ...@@ -372,21 +372,21 @@ xenInotifyOpen(virConnectPtr conn,
/* Build the full file path */ /* Build the full file path */
if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) { if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) {
closedir(dh); VIR_DIR_CLOSE(dh);
return -1; return -1;
} }
if (xenInotifyAddDomainConfigInfo(conn, path, now) < 0) { if (xenInotifyAddDomainConfigInfo(conn, path, now) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Error adding file to config list")); "%s", _("Error adding file to config list"));
closedir(dh); VIR_DIR_CLOSE(dh);
VIR_FREE(path); VIR_FREE(path);
return -1; return -1;
} }
VIR_FREE(path); VIR_FREE(path);
} }
closedir(dh); VIR_DIR_CLOSE(dh);
if (direrr < 0) if (direrr < 0)
return -1; return -1;
} }
......
...@@ -358,7 +358,7 @@ xenXMConfigCacheRefresh(virConnectPtr conn) ...@@ -358,7 +358,7 @@ xenXMConfigCacheRefresh(virConnectPtr conn)
/* Build the full file path */ /* Build the full file path */
if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) { if (!(path = virFileBuildPath(priv->configDir, ent->d_name, NULL))) {
closedir(dh); VIR_DIR_CLOSE(dh);
return -1; return -1;
} }
...@@ -386,7 +386,7 @@ xenXMConfigCacheRefresh(virConnectPtr conn) ...@@ -386,7 +386,7 @@ xenXMConfigCacheRefresh(virConnectPtr conn)
args.priv = priv; args.priv = priv;
virHashRemoveSet(priv->configCache, xenXMConfigReaper, &args); virHashRemoveSet(priv->configCache, xenXMConfigReaper, &args);
closedir(dh); VIR_DIR_CLOSE(dh);
return ret; return ret;
} }
......
...@@ -112,7 +112,7 @@ testSchemaDir(const char *schema, ...@@ -112,7 +112,7 @@ testSchemaDir(const char *schema,
cleanup: cleanup:
VIR_FREE(test_name); VIR_FREE(test_name);
VIR_FREE(xml_path); VIR_FREE(xml_path);
closedir(dir); VIR_DIR_CLOSE(dir);
return ret; return ret;
} }
......
...@@ -159,8 +159,7 @@ findLease(const char *name, ...@@ -159,8 +159,7 @@ findLease(const char *name,
VIR_FREE(path); VIR_FREE(path);
} }
closedir(dir); VIR_DIR_CLOSE(dir);
dir = NULL;
nleases = virJSONValueArraySize(leases_array); nleases = virJSONValueArraySize(leases_array);
DEBUG("Read %zd leases", nleases); DEBUG("Read %zd leases", nleases);
...@@ -231,8 +230,7 @@ findLease(const char *name, ...@@ -231,8 +230,7 @@ findLease(const char *name,
*errnop = errno; *errnop = errno;
VIR_FREE(tmpAddress); VIR_FREE(tmpAddress);
virJSONValueFree(leases_array); virJSONValueFree(leases_array);
if (dir) VIR_DIR_CLOSE(dir);
closedir(dir);
return ret; return ret;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册