1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-22 17:34:18 +03:00

remove unnecessary cleanup labels and unused return variables

After converting all DIR* to g_autoptr(DIR), many cleanup: labels
ended up just having "return ret", and every place that set ret would
just immediately goto cleanup. Remove the cleanup label and its
return, and just return the set value immediately, thus eliminating
the need for the return variable itself.

Signed-off-by: Laine Stump <laine@redhat.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
This commit is contained in:
Laine Stump 2020-10-27 17:49:11 -04:00
parent 77401d549c
commit 85c8c29214
15 changed files with 119 additions and 214 deletions

View File

@ -1091,12 +1091,11 @@ virNetworkObjLoadAllState(virNetworkObjListPtr nets,
if (obj &&
virNetworkObjLoadAllPorts(obj, stateDir) < 0) {
virNetworkObjEndAPI(&obj);
goto cleanup;
return -1;
}
virNetworkObjEndAPI(&obj);
}
cleanup:
return ret;
}
@ -1708,15 +1707,12 @@ virNetworkObjDeleteAllPorts(virNetworkObjPtr net,
g_autoptr(DIR) dh = NULL;
struct dirent *de;
int rc;
int ret = -1;
if (!(dir = virNetworkObjGetPortStatusDir(net, stateDir)))
goto cleanup;
return -1;
if ((rc = virDirOpenIfExists(&dh, dir)) <= 0) {
ret = rc;
goto cleanup;
}
if ((rc = virDirOpenIfExists(&dh, dir)) <= 0)
return rc;
while ((rc = virDirRead(dh, &de, dir)) > 0) {
char *file = NULL;
@ -1733,10 +1729,7 @@ virNetworkObjDeleteAllPorts(virNetworkObjPtr net,
}
virHashRemoveAll(net->ports);
ret = 0;
cleanup:
return ret;
return 0;
}
@ -1862,18 +1855,15 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net,
g_autofree char *dir = NULL;
g_autoptr(DIR) dh = NULL;
struct dirent *de;
int ret = -1;
int rc;
char uuidstr[VIR_UUID_STRING_BUFLEN];
g_autoptr(virNetworkPortDef) portdef = NULL;
if (!(dir = virNetworkObjGetPortStatusDir(net, stateDir)))
goto cleanup;
return -1;
if ((rc = virDirOpenIfExists(&dh, dir)) <= 0) {
ret = rc;
goto cleanup;
}
if ((rc = virDirOpenIfExists(&dh, dir)) <= 0)
return rc;
while ((rc = virDirRead(dh, &de, dir)) > 0) {
g_autofree char *file = NULL;
@ -1891,12 +1881,10 @@ virNetworkObjLoadAllPorts(virNetworkObjPtr net,
virUUIDFormat(portdef->uuid, uuidstr);
if (virHashAddEntry(net->ports, uuidstr, portdef) < 0)
goto cleanup;
return -1;
portdef = NULL;
}
ret = 0;
cleanup:
return ret;
return 0;
}

View File

@ -40,7 +40,6 @@ qemuBuildFileList(virHashTablePtr files, const char *dir)
g_autoptr(DIR) dirp = NULL;
struct dirent *ent = NULL;
int rc;
int ret = -1;
if ((rc = virDirOpenIfExists(&dirp, dir)) < 0)
return -1;
@ -62,24 +61,22 @@ qemuBuildFileList(virHashTablePtr files, const char *dir)
if (stat(path, &sb) < 0) {
virReportSystemError(errno, _("Unable to access %s"), path);
goto cleanup;
return -1;
}
if (!S_ISREG(sb.st_mode) && !S_ISLNK(sb.st_mode))
continue;
if (virHashUpdateEntry(files, filename, path) < 0)
goto cleanup;
return -1;
path = NULL;
}
if (rc < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}
static int

View File

@ -3507,13 +3507,12 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
struct statvfs sb;
struct stat statbuf;
int direrr;
int ret = -1;
g_autoptr(virStorageVolDef) vol = NULL;
VIR_AUTOCLOSE fd = -1;
g_autoptr(virStorageSource) target = NULL;
if (virDirOpen(&dir, def->target.path) < 0)
goto cleanup;
return -1;
while ((direrr = virDirRead(dir, &ent, def->target.path)) > 0) {
int err;
@ -3541,15 +3540,15 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
vol = NULL;
continue;
}
goto cleanup;
return -1;
}
if (virStoragePoolObjAddVol(pool, vol) < 0)
goto cleanup;
return -1;
vol = NULL;
}
if (direrr < 0)
goto cleanup;
return -1;
target = virStorageSourceNew();
@ -3557,25 +3556,25 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
virReportSystemError(errno,
_("cannot open path '%s'"),
def->target.path);
goto cleanup;
return -1;
}
if (fstat(fd, &statbuf) < 0) {
virReportSystemError(errno,
_("cannot stat path '%s'"),
def->target.path);
goto cleanup;
return -1;
}
if (virStorageBackendUpdateVolTargetInfoFD(target, fd, &statbuf) < 0)
goto cleanup;
return -1;
/* VolTargetInfoFD doesn't update capacity correctly for the pool case */
if (statvfs(def->target.path, &sb) < 0) {
virReportSystemError(errno,
_("cannot statvfs path '%s'"),
def->target.path);
goto cleanup;
return -1;
}
def->capacity = ((unsigned long long)sb.f_frsize *
@ -3590,9 +3589,7 @@ virStorageBackendRefreshLocal(virStoragePoolObjPtr pool)
VIR_FREE(def->target.perms.label);
def->target.perms.label = g_strdup(target->perms->label);
ret = 0;
cleanup:
return ret;
return 0;
}
@ -3724,7 +3721,6 @@ getNewStyleBlockDevice(const char *lun_path,
{
g_autoptr(DIR) block_dir = NULL;
struct dirent *block_dirent = NULL;
int retval = -1;
int direrr;
g_autofree char *block_path = NULL;
@ -3733,7 +3729,7 @@ getNewStyleBlockDevice(const char *lun_path,
VIR_DEBUG("Looking for block device in '%s'", block_path);
if (virDirOpen(&block_dir, block_path) < 0)
goto cleanup;
return -1;
while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) {
*block_device = g_strdup(block_dirent->d_name);
@ -3744,12 +3740,9 @@ getNewStyleBlockDevice(const char *lun_path,
}
if (direrr < 0)
goto cleanup;
return -1;
retval = 0;
cleanup:
return retval;
return 0;
}
@ -3796,7 +3789,6 @@ getBlockDevice(uint32_t host,
{
g_autoptr(DIR) lun_dir = NULL;
struct dirent *lun_dirent = NULL;
int retval = -1;
int direrr;
g_autofree char *lun_path = NULL;
@ -3806,7 +3798,7 @@ getBlockDevice(uint32_t host,
target, lun);
if (virDirOpen(&lun_dir, lun_path) < 0)
goto cleanup;
return -1;
while ((direrr = virDirRead(lun_dir, &lun_dirent, lun_path)) > 0) {
if (STRPREFIX(lun_dirent->d_name, "block")) {
@ -3814,27 +3806,23 @@ getBlockDevice(uint32_t host,
if (getNewStyleBlockDevice(lun_path,
lun_dirent->d_name,
block_device) < 0)
goto cleanup;
return -1;
} else {
if (getOldStyleBlockDevice(lun_path,
lun_dirent->d_name,
block_device) < 0)
goto cleanup;
return -1;
}
break;
}
}
if (direrr < 0)
goto cleanup;
if (!*block_device) {
retval = -2;
goto cleanup;
}
return -1;
retval = 0;
if (!*block_device)
return -2;
cleanup:
return retval;
return 0;
}

View File

@ -2465,7 +2465,6 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
const char *taskFile,
bool dormdir)
{
int ret = -1;
int rc;
bool killedAny = false;
g_autofree char *keypath = NULL;
@ -2480,14 +2479,14 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
if ((rc = virCgroupKillInternal(group, signum, pids,
controller, taskFile)) < 0) {
goto cleanup;
return -1;
}
if (rc == 1)
killedAny = true;
VIR_DEBUG("Iterate over children of %s (killedAny=%d)", keypath, killedAny);
if ((rc = virDirOpenIfExists(&dp, keypath)) < 0)
goto cleanup;
return -1;
if (rc == 0) {
VIR_DEBUG("Path %s does not exist, assuming done", keypath);
@ -2504,11 +2503,11 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
VIR_DEBUG("Process subdir %s", ent->d_name);
if (virCgroupNew(-1, ent->d_name, group, -1, &subgroup) < 0)
goto cleanup;
return -1;
if ((rc = virCgroupKillRecursiveInternal(subgroup, signum, pids,
controller, taskFile, true)) < 0)
goto cleanup;
return -1;
if (rc == 1)
killedAny = true;
@ -2516,13 +2515,10 @@ virCgroupKillRecursiveInternal(virCgroupPtr group,
virCgroupRemove(subgroup);
}
if (direrr < 0)
goto cleanup;
return -1;
done:
ret = killedAny ? 1 : 0;
cleanup:
return ret;
return killedAny ? 1 : 0;
}

View File

@ -456,7 +456,6 @@ virCommandMassCloseGetFDsLinux(virCommandPtr cmd G_GNUC_UNUSED,
struct dirent *entry;
const char *dirName = "/proc/self/fd";
int rc;
int ret = -1;
if (virDirOpen(&dp, dirName) < 0)
return -1;
@ -468,18 +467,16 @@ virCommandMassCloseGetFDsLinux(virCommandPtr cmd G_GNUC_UNUSED,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to parse FD: %s"),
entry->d_name);
goto cleanup;
return -1;
}
ignore_value(virBitmapSetBit(fds, fd));
}
if (rc < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}
# else /* !__linux__ */

View File

@ -171,7 +171,6 @@ virDMSanitizepath(const char *path)
struct stat sb[2];
g_autoptr(DIR) dh = NULL;
const char *p;
char *ret = NULL;
/* If a path is NOT provided then assume it's DM name */
p = strrchr(path, '/');
@ -206,12 +205,11 @@ virDMSanitizepath(const char *path)
if (stat(tmp, &sb[1]) == 0 &&
sb[0].st_rdev == sb[0].st_rdev) {
ret = g_steal_pointer(&tmp);
break;
return g_steal_pointer(&tmp);
}
}
return ret;
return NULL;
}

View File

@ -836,7 +836,6 @@ static char *
virFileNBDDeviceFindUnused(void)
{
g_autoptr(DIR) dh = NULL;
char *ret = NULL;
struct dirent *de;
int direrr;
@ -846,21 +845,19 @@ virFileNBDDeviceFindUnused(void)
while ((direrr = virDirRead(dh, &de, SYSFS_BLOCK_DIR)) > 0) {
if (STRPREFIX(de->d_name, "nbd")) {
int rv = virFileNBDDeviceIsBusy(de->d_name);
if (rv < 0)
goto cleanup;
if (rv == 0) {
ret = g_strdup_printf("/dev/%s", de->d_name);
goto cleanup;
}
return NULL;
if (rv == 0)
return g_strdup_printf("/dev/%s", de->d_name);
}
}
if (direrr < 0)
goto cleanup;
virReportSystemError(EBUSY, "%s",
_("No free NBD devices"));
return NULL;
cleanup:
return ret;
virReportSystemError(EBUSY, "%s", _("No free NBD devices"));
return NULL;
}
static bool
@ -979,7 +976,6 @@ int virFileDeleteTree(const char *dir)
{
g_autoptr(DIR) dh = NULL;
struct dirent *de;
int ret = -1;
int direrr;
/* Silently return 0 if passed NULL or directory doesn't exist */
@ -998,35 +994,32 @@ int virFileDeleteTree(const char *dir)
if (g_lstat(filepath, &sb) < 0) {
virReportSystemError(errno, _("Cannot access '%s'"),
filepath);
goto cleanup;
return -1;
}
if (S_ISDIR(sb.st_mode)) {
if (virFileDeleteTree(filepath) < 0)
goto cleanup;
return -1;
} else {
if (unlink(filepath) < 0 && errno != ENOENT) {
virReportSystemError(errno,
_("Cannot delete file '%s'"),
filepath);
goto cleanup;
return -1;
}
}
}
if (direrr < 0)
goto cleanup;
return -1;
if (rmdir(dir) < 0 && errno != ENOENT) {
virReportSystemError(errno,
_("Cannot delete directory '%s'"),
dir);
goto cleanup;
return -1;
}
ret = 0;
cleanup:
return ret;
return 0;
}
/* Like read(), but restarts after EINTR. Doesn't play
@ -2949,7 +2942,6 @@ int virFileChownFiles(const char *name,
gid_t gid)
{
struct dirent *ent;
int ret = -1;
int direrr;
g_autoptr(DIR) dir = NULL;
@ -2969,17 +2961,14 @@ int virFileChownFiles(const char *name,
_("cannot chown '%s' to (%u, %u)"),
ent->d_name, (unsigned int) uid,
(unsigned int) gid);
goto cleanup;
return -1;
}
}
if (direrr < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}
#else /* WIN32 */

View File

@ -2900,7 +2900,6 @@ virNetDevRDMAFeature(const char *ifname,
g_autofree char *eth_res_buf = NULL;
g_autoptr(DIR) dirp = NULL;
struct dirent *dp;
int ret = -1;
if (!virFileExists(SYSFS_INFINIBAND_DIR))
return 0;
@ -2913,12 +2912,11 @@ virNetDevRDMAFeature(const char *ifname,
/* If /sys/class/net/<ifname>/device/resource doesn't exist it is not a PCI
* device and therefore it will not have RDMA. */
if (!virFileExists(eth_devpath)) {
ret = 0;
goto cleanup;
return 0;
}
if (virFileReadAll(eth_devpath, RESOURCE_FILE_LEN, &eth_res_buf) < 0)
goto cleanup;
return -1;
while (virDirRead(dirp, &dp, SYSFS_INFINIBAND_DIR) > 0) {
g_autofree char *ib_res_buf = NULL;
@ -2931,10 +2929,8 @@ virNetDevRDMAFeature(const char *ifname,
break;
}
}
ret = 0;
cleanup:
return ret;
return 0;
}

View File

@ -739,7 +739,6 @@ virNumaGetPages(int node,
unsigned long long **pages_free,
size_t *npages)
{
int ret = -1;
g_autoptr(DIR) dir = NULL;
int direrr = 0;
struct dirent *entry;
@ -763,12 +762,12 @@ virNumaGetPages(int node,
* slightly different information. So we take the total memory on a node
* and subtract memory taken by the huge pages. */
if (virNumaGetHugePageInfoDir(&path, node) < 0)
goto cleanup;
return -1;
/* It's okay if the @path doesn't exist. Maybe we are running on
* system without huge pages support where the path may not exist. */
if (virDirOpenIfExists(&dir, path) < 0)
goto cleanup;
return -1;
while (dir && (direrr = virDirRead(dir, &entry, path)) > 0) {
const char *page_name = entry->d_name;
@ -789,17 +788,17 @@ virNumaGetPages(int node,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("unable to parse %s"),
entry->d_name);
goto cleanup;
return -1;
}
if (virNumaGetHugePageInfo(node, page_size,
&page_avail, &page_free) < 0)
goto cleanup;
return -1;
if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 ||
VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 ||
VIR_REALLOC_N(tmp_free, ntmp + 1) < 0)
goto cleanup;
return -1;
tmp_size[ntmp] = page_size;
tmp_avail[ntmp] = page_avail;
@ -812,17 +811,17 @@ virNumaGetPages(int node,
}
if (direrr < 0)
goto cleanup;
return -1;
/* Now append the ordinary system pages */
if (VIR_REALLOC_N(tmp_size, ntmp + 1) < 0 ||
VIR_REALLOC_N(tmp_avail, ntmp + 1) < 0 ||
VIR_REALLOC_N(tmp_free, ntmp + 1) < 0)
goto cleanup;
return -1;
if (virNumaGetPageInfo(node, system_page_size, huge_page_sum,
&tmp_avail[ntmp], &tmp_free[ntmp]) < 0)
goto cleanup;
return -1;
tmp_size[ntmp] = system_page_size;
ntmp++;
@ -852,9 +851,7 @@ virNumaGetPages(int node,
tmp_free = NULL;
}
*npages = ntmp;
ret = 0;
cleanup:
return ret;
return 0;
}

View File

@ -1706,7 +1706,6 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev,
{
g_autofree char *pcidir = NULL;
g_autoptr(DIR) dir = NULL;
int ret = -1;
struct dirent *ent;
int direrr;
@ -1715,7 +1714,7 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev,
dev->address.function);
if (virDirOpen(&dir, pcidir) < 0)
goto cleanup;
return -1;
while ((direrr = virDirRead(dir, &ent, pcidir)) > 0) {
g_autofree char *file = NULL;
@ -1731,16 +1730,13 @@ int virPCIDeviceFileIterate(virPCIDevicePtr dev,
STREQ(ent->d_name, "reset")) {
file = g_strdup_printf("%s/%s", pcidir, ent->d_name);
if ((actor)(dev, file, opaque) < 0)
goto cleanup;
return -1;
}
}
if (direrr < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}
@ -1756,7 +1752,6 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig,
{
g_autofree char *groupPath = NULL;
g_autoptr(DIR) groupDir = NULL;
int ret = -1;
struct dirent *ent;
int direrr;
@ -1765,8 +1760,7 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig,
if (virDirOpenQuiet(&groupDir, groupPath) < 0) {
/* just process the original device, nothing more */
ret = (actor)(orig, opaque);
goto cleanup;
return (actor)(orig, opaque);
}
while ((direrr = virDirRead(groupDir, &ent, groupPath)) > 0) {
@ -1776,19 +1770,16 @@ virPCIDeviceAddressIOMMUGroupIterate(virPCIDeviceAddressPtr orig,
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Found invalid device link '%s' in '%s'"),
ent->d_name, groupPath);
goto cleanup;
return -1;
}
if ((actor)(&newDev, opaque) < 0)
goto cleanup;
return -1;
}
if (direrr < 0)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}

View File

@ -786,23 +786,18 @@ virResctrlGetInfo(virResctrlInfoPtr resctrl)
ret = virDirOpenIfExists(&dirp, SYSFS_RESCTRL_PATH "/info");
if (ret <= 0)
goto cleanup;
return ret;
ret = virResctrlGetMemoryBandwidthInfo(resctrl);
if (ret < 0)
goto cleanup;
if ((ret = virResctrlGetMemoryBandwidthInfo(resctrl)) < 0)
return -1;
ret = virResctrlGetCacheInfo(resctrl, dirp);
if (ret < 0)
goto cleanup;
if ((ret = virResctrlGetCacheInfo(resctrl, dirp)) < 0)
return -1;
ret = virResctrlGetMonitorInfo(resctrl);
if (ret < 0)
goto cleanup;
if ((ret = virResctrlGetMonitorInfo(resctrl)) < 0)
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}

View File

@ -109,7 +109,6 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
g_autoptr(DIR) dir = NULL;
struct dirent *entry;
g_autofree char *path = NULL;
char *sg = NULL;
unsigned int adapter_id;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
@ -120,16 +119,13 @@ virSCSIDeviceGetSgName(const char *sysfs_prefix,
bus, target, unit);
if (virDirOpen(&dir, path) < 0)
goto cleanup;
return NULL;
while (virDirRead(dir, &entry, path) > 0) {
/* Assume a single directory entry */
sg = g_strdup(entry->d_name);
break;
}
/* Assume a single directory entry */
if (virDirRead(dir, &entry, path) > 0)
return g_strdup(entry->d_name);
cleanup:
return sg;
return NULL;
}
/* Returns device name (e.g. "sdc") on success, or NULL
@ -145,7 +141,6 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
g_autoptr(DIR) dir = NULL;
struct dirent *entry;
g_autofree char *path = NULL;
char *name = NULL;
unsigned int adapter_id;
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_SCSI_DEVICES;
@ -156,15 +151,12 @@ virSCSIDeviceGetDevName(const char *sysfs_prefix,
target, unit);
if (virDirOpen(&dir, path) < 0)
goto cleanup;
return NULL;
while (virDirRead(dir, &entry, path) > 0) {
name = g_strdup(entry->d_name);
break;
}
if (virDirRead(dir, &entry, path) > 0)
return g_strdup(entry->d_name);
cleanup:
return name;
return NULL;
}
virSCSIDevicePtr

View File

@ -1623,22 +1623,18 @@ virHostHasIOMMU(void)
{
g_autoptr(DIR) iommuDir = NULL;
struct dirent *iommuGroup = NULL;
bool ret = false;
int direrr;
if (virDirOpenQuiet(&iommuDir, "/sys/kernel/iommu_groups/") < 0)
goto cleanup;
return false;
while ((direrr = virDirRead(iommuDir, &iommuGroup, NULL)) > 0)
break;
if (direrr < 0 || !iommuGroup)
goto cleanup;
return false;
ret = true;
cleanup:
return ret;
return true;
}
@ -1656,7 +1652,6 @@ virHostHasIOMMU(void)
char *
virHostGetDRMRenderNode(void)
{
char *ret = NULL;
g_autoptr(DIR) driDir = NULL;
const char *driPath = "/dev/dri";
struct dirent *ent = NULL;
@ -1674,19 +1669,16 @@ virHostGetDRMRenderNode(void)
}
if (dirErr < 0)
goto cleanup;
return NULL;
/* even if /dev/dri exists, there might be no renderDX nodes available */
if (!have_rendernode) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("No DRM render nodes available"));
goto cleanup;
return NULL;
}
ret = g_strdup_printf("%s/%s", driPath, ent->d_name);
cleanup:
return ret;
return g_strdup_printf("%s/%s", driPath, ent->d_name);
}

View File

@ -365,7 +365,6 @@ virVHBAGetHostByWWN(const char *sysfs_prefix,
const char *prefix = sysfs_prefix ? sysfs_prefix : SYSFS_FC_HOST_PATH;
struct dirent *entry = NULL;
g_autoptr(DIR) dir = NULL;
char *ret = NULL;
if (virDirOpen(&dir, prefix) < 0)
return NULL;
@ -375,24 +374,22 @@ virVHBAGetHostByWWN(const char *sysfs_prefix,
if ((rc = vhbaReadCompareWWN(prefix, entry->d_name,
"node_name", wwnn)) < 0)
goto cleanup;
return NULL;
if (rc == 0)
continue;
if ((rc = vhbaReadCompareWWN(prefix, entry->d_name,
"port_name", wwpn)) < 0)
goto cleanup;
return NULL;
if (rc == 0)
continue;
ret = g_strdup(entry->d_name);
break;
return g_strdup(entry->d_name);
}
cleanup:
return ret;
return NULL;
}
/* virVHBAGetHostByFabricWWN:

View File

@ -516,12 +516,11 @@ testQemuGetLatestCapsForArch(const char *arch,
unsigned long maxver = 0;
unsigned long ver;
g_autofree char *maxname = NULL;
char *ret = NULL;
fullsuffix = g_strdup_printf("%s.%s", arch, suffix);
if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
goto cleanup;
return NULL;
while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
g_autofree char *tmp = NULL;
@ -547,18 +546,15 @@ testQemuGetLatestCapsForArch(const char *arch,
}
if (rc < 0)
goto cleanup;
return NULL;
if (!maxname) {
VIR_TEST_VERBOSE("failed to find capabilities for '%s' in '%s'",
arch, TEST_QEMU_CAPS_PATH);
goto cleanup;
return NULL;
}
ret = g_strdup_printf("%s/%s", TEST_QEMU_CAPS_PATH, maxname);
cleanup:
return ret;
return g_strdup_printf("%s/%s", TEST_QEMU_CAPS_PATH, maxname);
}
@ -607,7 +603,6 @@ testQemuCapsIterate(const char *suffix,
struct dirent *ent;
g_autoptr(DIR) dir = NULL;
int rc;
int ret = -1;
bool fail = false;
if (!callback)
@ -616,11 +611,11 @@ testQemuCapsIterate(const char *suffix,
/* Validate suffix */
if (!STRPREFIX(suffix, ".")) {
VIR_TEST_VERBOSE("malformed suffix '%s'", suffix);
goto cleanup;
return -1;
}
if (virDirOpen(&dir, TEST_QEMU_CAPS_PATH) < 0)
goto cleanup;
return -1;
while ((rc = virDirRead(dir, &ent, TEST_QEMU_CAPS_PATH)) > 0) {
g_autofree char *tmp = g_strdup(ent->d_name);
@ -634,13 +629,13 @@ testQemuCapsIterate(const char *suffix,
/* Strip the leading prefix */
if (!(version = STRSKIP(tmp, "caps_"))) {
VIR_TEST_VERBOSE("malformed file name '%s'", ent->d_name);
goto cleanup;
return -1;
}
/* Find the last dot */
if (!(archName = strrchr(tmp, '.'))) {
VIR_TEST_VERBOSE("malformed file name '%s'", ent->d_name);
goto cleanup;
return -1;
}
/* The version number and the architecture name are separated by
@ -661,12 +656,9 @@ testQemuCapsIterate(const char *suffix,
}
if (rc < 0 || fail)
goto cleanup;
return -1;
ret = 0;
cleanup:
return ret;
return 0;
}