mirror of https://gitee.com/openkylin/libvirt.git
util: remove unneeded cleanup labels
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
5b05d99dab
commit
93af79fba3
|
@ -696,7 +696,6 @@ virCgroupV1AddTask(virCgroupPtr group,
|
|||
pid_t pid,
|
||||
unsigned int flags)
|
||||
{
|
||||
int ret = -1;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < VIR_CGROUP_CONTROLLER_LAST; i++) {
|
||||
|
@ -712,12 +711,10 @@ virCgroupV1AddTask(virCgroupPtr group,
|
|||
continue;
|
||||
|
||||
if (virCgroupSetValueI64(group, i, "tasks", pid) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1818,18 +1815,13 @@ static int
|
|||
virCgroupV1AllowAllDevices(virCgroupPtr group,
|
||||
int perms)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (virCgroupV1AllowDevice(group, 'b', -1, -1, perms) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virCgroupV1AllowDevice(group, 'c', -1, -1, perms) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -417,8 +417,6 @@ virCommandHandshakeChild(virCommandPtr cmd)
|
|||
static int
|
||||
virExecCommon(virCommandPtr cmd, gid_t *groups, int ngroups)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (cmd->uid != (uid_t)-1 || cmd->gid != (gid_t)-1 ||
|
||||
cmd->capabilities || (cmd->flags & VIR_EXEC_CLEAR_CAPS)) {
|
||||
VIR_DEBUG("Setting child uid:gid to %d:%d with caps %llx",
|
||||
|
@ -426,7 +424,7 @@ virExecCommon(virCommandPtr cmd, gid_t *groups, int ngroups)
|
|||
if (virSetUIDGIDWithCaps(cmd->uid, cmd->gid, groups, ngroups,
|
||||
cmd->capabilities,
|
||||
!!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cmd->pwd) {
|
||||
|
@ -434,13 +432,10 @@ virExecCommon(virCommandPtr cmd, gid_t *groups, int ngroups)
|
|||
if (chdir(cmd->pwd) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Unable to change to %s"), cmd->pwd);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
# ifdef __linux__
|
||||
|
|
|
@ -1191,7 +1191,6 @@ int virDBusMessageDecodeArgs(DBusMessage* msg,
|
|||
va_list args)
|
||||
{
|
||||
DBusMessageIter iter;
|
||||
int ret = -1;
|
||||
|
||||
if (!dbus_message_iter_init(msg, &iter)) {
|
||||
if (*types != '\0') {
|
||||
|
@ -1199,15 +1198,12 @@ int virDBusMessageDecodeArgs(DBusMessage* msg,
|
|||
_("No args present for signature %s"),
|
||||
types);
|
||||
} else {
|
||||
ret = 0;
|
||||
return 0;
|
||||
}
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = virDBusMessageIterDecode(&iter, types, args);
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return virDBusMessageIterDecode(&iter, types, args);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1396,25 +1392,21 @@ int virDBusCreateMethodV(DBusMessage **call,
|
|||
const char *types,
|
||||
va_list args)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!(*call = dbus_message_new_method_call(destination,
|
||||
path,
|
||||
iface,
|
||||
member))) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDBusMessageEncodeArgs(*call, types, args) < 0) {
|
||||
virDBusMessageUnref(*call);
|
||||
*call = NULL;
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1468,22 +1460,18 @@ int virDBusCreateReplyV(DBusMessage **reply,
|
|||
const char *types,
|
||||
va_list args)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (!(*reply = dbus_message_new(DBUS_MESSAGE_TYPE_METHOD_RETURN))) {
|
||||
virReportOOMError();
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (virDBusMessageEncodeArgs(*reply, types, args) < 0) {
|
||||
virDBusMessageUnref(*reply);
|
||||
*reply = NULL;
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -3598,27 +3598,25 @@ int
|
|||
virFileGetHugepageSize(const char *path,
|
||||
unsigned long long *size)
|
||||
{
|
||||
int ret = -1;
|
||||
struct statfs fs;
|
||||
|
||||
if (statfs(path, &fs) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("cannot determine filesystem for '%s'"),
|
||||
path);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (fs.f_type != HUGETLBFS_MAGIC) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("not a hugetlbfs mount: '%s'"),
|
||||
path);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*size = fs.f_bsize / 1024; /* we are storing size in KiB */
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
# define PROC_MEMINFO "/proc/meminfo"
|
||||
|
@ -3790,12 +3788,11 @@ virFileSetupDev(const char *path,
|
|||
{
|
||||
const unsigned long mount_flags = MS_NOSUID;
|
||||
const char *mount_fs = "tmpfs";
|
||||
int ret = -1;
|
||||
|
||||
if (virFileMakePath(path) < 0) {
|
||||
virReportSystemError(errno,
|
||||
_("Failed to make path %s"), path);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
VIR_DEBUG("Mount devfs on %s type=tmpfs flags=0x%lx, opts=%s",
|
||||
|
@ -3804,12 +3801,10 @@ virFileSetupDev(const char *path,
|
|||
virReportSystemError(errno,
|
||||
_("Failed to mount devfs on %s type %s (%s)"),
|
||||
path, mount_fs, mount_options);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -646,15 +646,13 @@ virHashForEach(virHashTablePtr table, virHashIterator iter, void *data)
|
|||
ret = iter(entry->payload, entry->name, data);
|
||||
|
||||
if (ret < 0)
|
||||
goto cleanup;
|
||||
return ret;
|
||||
|
||||
entry = next;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -773,7 +773,6 @@ virHostCPUGetStatsLinux(FILE *procstat,
|
|||
virNodeCPUStatsPtr params,
|
||||
int *nparams)
|
||||
{
|
||||
int ret = -1;
|
||||
char line[1024];
|
||||
unsigned long long usr, ni, sys, idle, iowait;
|
||||
unsigned long long irq, softirq, steal, guest, guest_nice;
|
||||
|
@ -782,15 +781,14 @@ virHostCPUGetStatsLinux(FILE *procstat,
|
|||
if ((*nparams) == 0) {
|
||||
/* Current number of cpu stats supported by linux */
|
||||
*nparams = LINUX_NB_CPU_STATS;
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((*nparams) != LINUX_NB_CPU_STATS) {
|
||||
virReportInvalidArg(*nparams,
|
||||
_("nparams in %s must be equal to %d"),
|
||||
__FUNCTION__, LINUX_NB_CPU_STATS);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (cpuNum == VIR_NODE_CPU_STATS_ALL_CPUS) {
|
||||
|
@ -813,22 +811,21 @@ virHostCPUGetStatsLinux(FILE *procstat,
|
|||
|
||||
if (virHostCPUStatsAssign(¶ms[0], VIR_NODE_CPU_STATS_KERNEL,
|
||||
(sys + irq + softirq) * TICK_TO_NSEC) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virHostCPUStatsAssign(¶ms[1], VIR_NODE_CPU_STATS_USER,
|
||||
(usr + ni) * TICK_TO_NSEC) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virHostCPUStatsAssign(¶ms[2], VIR_NODE_CPU_STATS_IDLE,
|
||||
idle * TICK_TO_NSEC) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (virHostCPUStatsAssign(¶ms[3], VIR_NODE_CPU_STATS_IOWAIT,
|
||||
iowait * TICK_TO_NSEC) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -836,8 +833,7 @@ virHostCPUGetStatsLinux(FILE *procstat,
|
|||
_("Invalid cpuNum in %s"),
|
||||
__FUNCTION__);
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -80,7 +80,6 @@ struct virHostdevIsPCINodeDeviceUsedData {
|
|||
static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddressPtr devAddr, void *opaque)
|
||||
{
|
||||
virPCIDevicePtr actual;
|
||||
int ret = -1;
|
||||
struct virHostdevIsPCINodeDeviceUsedData *helperData = opaque;
|
||||
|
||||
actual = virPCIDeviceListFindByIDs(helperData->mgr->activePCIHostdevs,
|
||||
|
@ -106,12 +105,10 @@ static int virHostdevIsPCINodeDeviceUsed(virPCIDeviceAddressPtr devAddr, void *o
|
|||
virReportError(VIR_ERR_OPERATION_INVALID,
|
||||
_("PCI device %s is in use"),
|
||||
virPCIDeviceGetName(actual));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
iommu_owner:
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int virHostdevManagerOnceInit(void)
|
||||
|
|
|
@ -142,7 +142,6 @@ virHostMemGetStatsLinux(FILE *meminfo,
|
|||
virNodeMemoryStatsPtr params,
|
||||
int *nparams)
|
||||
{
|
||||
int ret = -1;
|
||||
size_t i = 0, j = 0, k = 0;
|
||||
int found = 0;
|
||||
int nr_param;
|
||||
|
@ -169,15 +168,14 @@ virHostMemGetStatsLinux(FILE *meminfo,
|
|||
if ((*nparams) == 0) {
|
||||
/* Current number of memory stats supported by linux */
|
||||
*nparams = nr_param;
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((*nparams) != nr_param) {
|
||||
virReportInvalidArg(nparams,
|
||||
_("nparams in %s must be %d"),
|
||||
__FUNCTION__, nr_param);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (fgets(line, sizeof(line), meminfo) != NULL) {
|
||||
|
@ -200,7 +198,7 @@ virHostMemGetStatsLinux(FILE *meminfo,
|
|||
if (p == NULL) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("no prefix found"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
|
@ -219,7 +217,7 @@ virHostMemGetStatsLinux(FILE *meminfo,
|
|||
if (virStrcpyStatic(param->field, convp->field) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("Field kernel memory too long for destination"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
param->value = val;
|
||||
found++;
|
||||
|
@ -233,13 +231,10 @@ virHostMemGetStatsLinux(FILE *meminfo,
|
|||
if (found == 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("no available memory line found"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -611,14 +606,12 @@ static int
|
|||
virHostMemGetInfoFake(unsigned long long *mem,
|
||||
unsigned long long *freeMem)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (mem) {
|
||||
double total = physmem_total();
|
||||
if (!total) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot determine free memory"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*mem = (unsigned long long) total;
|
||||
|
@ -630,15 +623,13 @@ virHostMemGetInfoFake(unsigned long long *mem,
|
|||
if (!avail) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("Cannot determine free memory"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*freeMem = (unsigned long long) avail;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -649,7 +640,6 @@ virHostMemGetCellsFree(unsigned long long *freeMems,
|
|||
{
|
||||
unsigned long long mem;
|
||||
int n, lastCell, numCells;
|
||||
int ret = -1;
|
||||
int maxCell;
|
||||
|
||||
if (!virNumaIsAvailable())
|
||||
|
@ -663,7 +653,7 @@ virHostMemGetCellsFree(unsigned long long *freeMems,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("start cell %d out of range (0-%d)"),
|
||||
startCell, maxCell);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
lastCell = startCell + maxCells - 1;
|
||||
if (lastCell > maxCell)
|
||||
|
@ -674,10 +664,7 @@ virHostMemGetCellsFree(unsigned long long *freeMems,
|
|||
|
||||
freeMems[numCells++] = mem;
|
||||
}
|
||||
ret = numCells;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return numCells;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -725,7 +712,6 @@ virHostMemGetFreePages(unsigned int npages,
|
|||
unsigned int cellCount,
|
||||
unsigned long long *counts)
|
||||
{
|
||||
int ret = -1;
|
||||
int cell, lastCell;
|
||||
size_t i, ncounts = 0;
|
||||
|
||||
|
@ -736,7 +722,7 @@ virHostMemGetFreePages(unsigned int npages,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("start cell %d out of range (0-%d)"),
|
||||
startCell, lastCell);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
lastCell = MIN(lastCell, startCell + (int) cellCount - 1);
|
||||
|
@ -747,7 +733,7 @@ virHostMemGetFreePages(unsigned int npages,
|
|||
unsigned long long page_free;
|
||||
|
||||
if (virNumaGetPageInfo(cell, page_size, 0, NULL, &page_free) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
counts[ncounts++] = page_free;
|
||||
}
|
||||
|
@ -756,12 +742,10 @@ virHostMemGetFreePages(unsigned int npages,
|
|||
if (!ncounts) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||
_("no suitable info found"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = ncounts;
|
||||
cleanup:
|
||||
return ret;
|
||||
return ncounts;
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -772,7 +756,6 @@ virHostMemAllocPages(unsigned int npages,
|
|||
unsigned int cellCount,
|
||||
bool add)
|
||||
{
|
||||
int ret = -1;
|
||||
int cell, lastCell;
|
||||
size_t i, ncounts = 0;
|
||||
|
||||
|
@ -783,7 +766,7 @@ virHostMemAllocPages(unsigned int npages,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("start cell %d out of range (0-%d)"),
|
||||
startCell, lastCell);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
lastCell = MIN(lastCell, startCell + (int) cellCount - 1);
|
||||
|
@ -794,13 +777,11 @@ virHostMemAllocPages(unsigned int npages,
|
|||
unsigned long long page_count = pageCounts[i];
|
||||
|
||||
if (virNumaSetPagePoolSize(cell, page_size, page_count, add) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ncounts++;
|
||||
}
|
||||
}
|
||||
|
||||
ret = ncounts;
|
||||
cleanup:
|
||||
return ret;
|
||||
return ncounts;
|
||||
}
|
||||
|
|
|
@ -160,7 +160,6 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
{
|
||||
char type;
|
||||
char *key;
|
||||
int ret = -1;
|
||||
int rc;
|
||||
|
||||
while ((key = va_arg(args, char *)) != NULL) {
|
||||
|
@ -169,7 +168,7 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' is too short, missing type prefix"),
|
||||
key);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
type = key[0];
|
||||
|
@ -187,7 +186,7 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' must not have null value"),
|
||||
key);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
rc = virJSONValueObjectAppendString(obj, key, val);
|
||||
} break;
|
||||
|
@ -202,7 +201,7 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' must not be negative"),
|
||||
key);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!val && (type == 'z' || type == 'y'))
|
||||
|
@ -231,7 +230,7 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' must not be negative"),
|
||||
key);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!val && (type == 'Z' || type == 'Y'))
|
||||
|
@ -296,7 +295,7 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' must not have null value"),
|
||||
key);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((rc = virJSONValueObjectAppend(obj, key, *val)) == 0)
|
||||
|
@ -315,11 +314,11 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("argument key '%s' must not have null value"),
|
||||
key);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(jsonMap = virJSONValueNewArrayFromBitmap(map)))
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if ((rc = virJSONValueObjectAppend(obj, key, jsonMap)) < 0)
|
||||
virJSONValueFree(jsonMap);
|
||||
|
@ -328,23 +327,18 @@ virJSONValueObjectAddVArgs(virJSONValuePtr obj,
|
|||
default:
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("unsupported data type '%c' for arg '%s'"), type, key - 2);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (rc < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* verify that we added at least one key-value pair */
|
||||
if (virJSONValueObjectKeysNumber(obj) == 0) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
}
|
||||
if (virJSONValueObjectKeysNumber(obj) == 0)
|
||||
return 0;
|
||||
|
||||
ret = 1;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -85,22 +85,18 @@ virMacMapAddLocked(virMacMapPtr mgr,
|
|||
const char *domain,
|
||||
const char *mac)
|
||||
{
|
||||
int ret = -1;
|
||||
char **macsList = NULL;
|
||||
|
||||
if ((macsList = virHashLookup(mgr->macs, domain)) &&
|
||||
virStringListHasString((const char**) macsList, mac)) {
|
||||
ret = 0;
|
||||
goto cleanup;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (virStringListAdd(&macsList, mac) < 0 ||
|
||||
virHashUpdateEntry(mgr->macs, domain, macsList) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -270,16 +270,13 @@ virNetDevBridgePortGetLearning(const char *brname,
|
|||
const char *ifname,
|
||||
bool *enable)
|
||||
{
|
||||
int ret = -1;
|
||||
unsigned long value;
|
||||
|
||||
if (virNetDevBridgePortGet(brname, ifname, "learning", &value) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
*enable = !!value;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -297,16 +294,13 @@ virNetDevBridgePortGetUnicastFlood(const char *brname,
|
|||
const char *ifname,
|
||||
bool *enable)
|
||||
{
|
||||
int ret = -1;
|
||||
unsigned long value;
|
||||
|
||||
if (virNetDevBridgePortGet(brname, ifname, "unicast_flood", &value) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
*enable = !!value;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -887,16 +881,13 @@ int
|
|||
virNetDevBridgeGetVlanFiltering(const char *brname,
|
||||
bool *enable)
|
||||
{
|
||||
int ret = -1;
|
||||
unsigned long value;
|
||||
|
||||
if (virNetDevBridgeGet(brname, "vlan_filtering", &value) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
*enable = !!value;
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode,
|
|||
{
|
||||
nodemask_t mask;
|
||||
int node = -1;
|
||||
int ret = -1;
|
||||
int bit = 0;
|
||||
size_t i;
|
||||
int maxnode = 0;
|
||||
|
@ -140,7 +139,7 @@ virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode,
|
|||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
"%s", _("NUMA memory tuning in 'preferred' mode "
|
||||
"only supports single node"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
numa_set_bind_policy(0);
|
||||
|
@ -155,10 +154,8 @@ virNumaSetupMemoryPolicy(virDomainNumatuneMemMode mode,
|
|||
case VIR_DOMAIN_NUMATUNE_MEM_LAST:
|
||||
break;
|
||||
}
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -466,7 +463,6 @@ virNumaGetDistances(int node,
|
|||
int **distances,
|
||||
int *ndistances)
|
||||
{
|
||||
int ret = -1;
|
||||
int max_node;
|
||||
size_t i;
|
||||
|
||||
|
@ -478,10 +474,10 @@ virNumaGetDistances(int node,
|
|||
}
|
||||
|
||||
if ((max_node = virNumaGetMaxNode()) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
if (VIR_ALLOC_N(*distances, max_node + 1) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
*ndistances = max_node + 1;
|
||||
|
||||
|
@ -492,9 +488,7 @@ virNumaGetDistances(int node,
|
|||
(*distances)[i] = numa_distance(node, i);
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !(WITH_NUMACTL && HAVE_NUMA_BITMASK_ISBITSET) */
|
||||
|
@ -685,7 +679,6 @@ virNumaGetPageInfo(int node,
|
|||
unsigned long long *page_avail,
|
||||
unsigned long long *page_free)
|
||||
{
|
||||
int ret = -1;
|
||||
long system_page_size = virGetSystemPageSize();
|
||||
|
||||
/* sysconf() returns page size in bytes,
|
||||
|
@ -697,10 +690,10 @@ virNumaGetPageInfo(int node,
|
|||
* account. The problem is huge pages cut off regular memory. */
|
||||
if (node == -1) {
|
||||
if (virHostMemGetInfo(&memsize, &memfree) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
} else {
|
||||
if (virNumaGetNodeMemory(node, &memsize, &memfree) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* see description above */
|
||||
|
@ -713,12 +706,10 @@ virNumaGetPageInfo(int node,
|
|||
*page_free = memfree / system_page_size;
|
||||
} else {
|
||||
if (virNumaGetHugePageInfo(node, page_size, page_avail, page_free) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1890,18 +1890,15 @@ virPCIDeviceAddressGetIOMMUGroupAddresses(virPCIDeviceAddressPtr devAddr,
|
|||
virPCIDeviceAddressPtr **iommuGroupDevices,
|
||||
size_t *nIommuGroupDevices)
|
||||
{
|
||||
int ret = -1;
|
||||
virPCIDeviceAddressList addrList = { iommuGroupDevices,
|
||||
nIommuGroupDevices };
|
||||
|
||||
if (virPCIDeviceAddressIOMMUGroupIterate(devAddr,
|
||||
virPCIGetIOMMUGroupAddressesAddOne,
|
||||
&addrList) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -349,7 +349,6 @@ int
|
|||
virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay)
|
||||
{
|
||||
size_t i;
|
||||
int ret = -1;
|
||||
/* This is in 1/5th seconds since polling is on a 0.2s interval */
|
||||
unsigned int polldelay = (force ? 200 : 75) + (extradelay*5);
|
||||
const char *signame = "TERM";
|
||||
|
@ -393,10 +392,9 @@ virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay)
|
|||
virReportSystemError(errno,
|
||||
_("Failed to terminate process %lld with SIG%s"),
|
||||
(long long)pid, signame);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
ret = signum == SIGTERM ? 0 : 1;
|
||||
goto cleanup; /* process is dead */
|
||||
return signum == SIGTERM ? 0 : 1;
|
||||
}
|
||||
|
||||
g_usleep(200 * 1000);
|
||||
|
@ -406,8 +404,7 @@ virProcessKillPainfullyDelay(pid_t pid, bool force, unsigned int extradelay)
|
|||
_("Failed to terminate process %lld with SIG%s"),
|
||||
(long long)pid, signame);
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1177,23 +1174,19 @@ virProcessRunInFork(virProcessForkCallback cb,
|
|||
int
|
||||
virProcessSetupPrivateMountNS(void)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (unshare(CLONE_NEWNS) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("Cannot unshare mount namespace"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (mount("", "/", "none", MS_SLAVE|MS_REC, NULL) < 0) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("Failed to switch root mount into slave mode"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else /* !defined(HAVE_SYS_MOUNT_H) || !defined(HAVE_UNSHARE) */
|
||||
|
|
|
@ -871,7 +871,6 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
|
|||
virResctrlInfoPerLevelPtr i_level = NULL;
|
||||
virResctrlInfoPerTypePtr i_type = NULL;
|
||||
size_t i = 0;
|
||||
int ret = -1;
|
||||
|
||||
if (virResctrlInfoIsEmpty(resctrl))
|
||||
return 0;
|
||||
|
@ -928,14 +927,12 @@ virResctrlInfoGetCache(virResctrlInfoPtr resctrl,
|
|||
memcpy((*controls)[*ncontrols - 1], &i_type->control, sizeof(i_type->control));
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
error:
|
||||
while (*ncontrols)
|
||||
VIR_FREE((*controls)[--*ncontrols]);
|
||||
VIR_FREE(*controls);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -601,11 +601,10 @@ vmdk4GetBackingStore(char **res,
|
|||
static const char prefix[] = "parentFileNameHint=\"";
|
||||
char *start, *end;
|
||||
size_t len;
|
||||
int ret = BACKING_STORE_ERROR;
|
||||
g_autofree char *desc = NULL;
|
||||
|
||||
if (VIR_ALLOC_N(desc, VIR_STORAGE_MAX_HEADER) < 0)
|
||||
goto cleanup;
|
||||
return BACKING_STORE_ERROR;
|
||||
|
||||
*res = NULL;
|
||||
/*
|
||||
|
@ -617,10 +616,9 @@ vmdk4GetBackingStore(char **res,
|
|||
*/
|
||||
*format = VIR_STORAGE_FILE_AUTO;
|
||||
|
||||
if (buf_size <= 0x200) {
|
||||
ret = BACKING_STORE_INVALID;
|
||||
goto cleanup;
|
||||
}
|
||||
if (buf_size <= 0x200)
|
||||
return BACKING_STORE_INVALID;
|
||||
|
||||
len = buf_size - 0x200;
|
||||
if (len > VIR_STORAGE_MAX_HEADER)
|
||||
len = VIR_STORAGE_MAX_HEADER;
|
||||
|
@ -629,27 +627,21 @@ vmdk4GetBackingStore(char **res,
|
|||
start = strstr(desc, prefix);
|
||||
if (start == NULL) {
|
||||
*format = VIR_STORAGE_FILE_NONE;
|
||||
ret = BACKING_STORE_OK;
|
||||
goto cleanup;
|
||||
return BACKING_STORE_OK;
|
||||
}
|
||||
start += strlen(prefix);
|
||||
end = strchr(start, '"');
|
||||
if (end == NULL) {
|
||||
ret = BACKING_STORE_INVALID;
|
||||
goto cleanup;
|
||||
}
|
||||
if (end == NULL)
|
||||
return BACKING_STORE_INVALID;
|
||||
|
||||
if (end == start) {
|
||||
*format = VIR_STORAGE_FILE_NONE;
|
||||
ret = BACKING_STORE_OK;
|
||||
goto cleanup;
|
||||
return BACKING_STORE_OK;
|
||||
}
|
||||
*end = '\0';
|
||||
*res = g_strdup(start);
|
||||
|
||||
ret = BACKING_STORE_OK;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return BACKING_STORE_OK;
|
||||
}
|
||||
|
||||
static int
|
||||
|
@ -2382,20 +2374,15 @@ virStorageSourceInitChainElement(virStorageSourcePtr newelem,
|
|||
virStorageSourcePtr old,
|
||||
bool transferLabels)
|
||||
{
|
||||
int ret = -1;
|
||||
|
||||
if (transferLabels &&
|
||||
!newelem->seclabels &&
|
||||
virStorageSourceSeclabelsCopy(newelem, old) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
newelem->shared = old->shared;
|
||||
newelem->readonly = old->readonly;
|
||||
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
@ -3426,7 +3413,6 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
|
|||
virJSONValuePtr servers = virJSONValueObjectGetArray(json, "server");
|
||||
size_t nservers;
|
||||
size_t i;
|
||||
int ret = -1;
|
||||
|
||||
src->type = VIR_STORAGE_TYPE_NETWORK;
|
||||
src->protocol = VIR_STORAGE_NET_PROTOCOL_RBD;
|
||||
|
@ -3451,20 +3437,18 @@ virStorageSourceParseBackingJSONRBD(virStorageSourcePtr src,
|
|||
nservers = virJSONValueArraySize(servers);
|
||||
|
||||
if (VIR_ALLOC_N(src->hosts, nservers) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
src->nhosts = nservers;
|
||||
|
||||
for (i = 0; i < nservers; i++) {
|
||||
if (virStorageSourceParseBackingJSONInetSocketAddress(src->hosts + i,
|
||||
virJSONValueArrayGet(servers, i)) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
|
|
|
@ -1331,7 +1331,7 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
|
|||
unsigned long long capBits, bool clearExistingCaps)
|
||||
{
|
||||
size_t i;
|
||||
int capng_ret, ret = -1;
|
||||
int capng_ret;
|
||||
bool need_setgid = false;
|
||||
bool need_setuid = false;
|
||||
bool need_setpcap = false;
|
||||
|
@ -1383,7 +1383,7 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
|
|||
if (prctl(PR_SET_KEEPCAPS, 1, 0, 0, 0)) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("prctl failed to set KEEPCAPS"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Change to the temp capabilities */
|
||||
|
@ -1401,18 +1401,18 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
|
|||
} else {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot apply process capabilities %d"), capng_ret);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
if (virSetUIDGID(uid, gid, groups, ngroups) < 0)
|
||||
goto cleanup;
|
||||
return -1;
|
||||
|
||||
/* Tell it we are done keeping capabilities */
|
||||
if (prctl(PR_SET_KEEPCAPS, 0, 0, 0, 0)) {
|
||||
virReportSystemError(errno, "%s",
|
||||
_("prctl failed to reset KEEPCAPS"));
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
# ifdef PR_CAP_AMBIENT
|
||||
|
@ -1430,7 +1430,7 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
|
|||
_("prctl failed to enable '%s' in the "
|
||||
"AMBIENT set"),
|
||||
capstr);
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1454,13 +1454,10 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups,
|
|||
if (((capng_ret = capng_apply(CAPNG_SELECT_CAPS)) < 0)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("cannot apply process capabilities %d"), capng_ret);
|
||||
ret = -1;
|
||||
goto cleanup;
|
||||
return -1;
|
||||
}
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
#else
|
||||
|
|
Loading…
Reference in New Issue