return NULL;
}
} else {
- if (virAsprintf(&prompt, _("Enter username for %s"), hostname) < 0) {
+ if (virAsprintf(&prompt, _("Enter username for %s"), hostname) < 0)
return NULL;
- }
}
for (ncred = 0; ncred < auth->ncredtype; ncred++) {
- if (auth->credtype[ncred] != VIR_CRED_AUTHNAME) {
+ if (auth->credtype[ncred] != VIR_CRED_AUTHNAME)
continue;
- }
cred.type = VIR_CRED_AUTHNAME;
cred.prompt = prompt;
cred.result = NULL;
cred.resultlen = 0;
- if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+ if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
VIR_FREE(cred.result);
- }
break;
}
cred.result = NULL;
cred.resultlen = 0;
- if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0) {
+ if ((*(auth->cb))(&cred, 1, auth->cbdata) < 0)
VIR_FREE(cred.result);
- }
break;
}
bits = bitmap->map[nl] & ~((1UL << nb) - 1);
- while (bits == 0 && ++nl < bitmap->map_len) {
+ while (bits == 0 && ++nl < bitmap->map_len)
bits = bitmap->map[nl];
- }
if (bits == 0)
return -1;
bits = ~bitmap->map[nl] & ~((1UL << nb) - 1);
- while (bits == 0 && ++nl < bitmap->map_len) {
+ while (bits == 0 && ++nl < bitmap->map_len)
bits = ~bitmap->map[nl];
- }
if (nl == bitmap->map_len - 1) {
/* Ensure tail bits are ignored. */
buf->content[buf->use] = 0;
grow_size = (count + 1 > 1000) ? count + 1 : 1000;
- if (virBufferGrow(buf, grow_size) < 0) {
+ if (virBufferGrow(buf, grow_size) < 0)
return;
- }
size = buf->size - buf->use;
if ((count = vsnprintf(&buf->content[buf->use],
pid = virFork();
- if (pid < 0) {
+ if (pid < 0)
goto cleanup;
- }
if (pid) { /* parent */
VIR_FORCE_CLOSE(null);
v[i] = NULL;
virCommandSetOutputFD(cmd, &fd);
- if (virCommandRunAsync(cmd, NULL) < 0) {
+ if (virCommandRunAsync(cmd, NULL) < 0)
goto cleanup;
- }
if ((fp = VIR_FDOPEN(fd, "r")) == NULL) {
virReportError(VIR_ERR_INTERNAL_ERROR,
if (func(n_tok, v, data) < 0)
goto cleanup;
n_tok = 0;
- for (i = 0; i < n_columns; i++) {
+ for (i = 0; i < n_columns; i++)
VIR_FREE(v[i]);
- }
}
}
}
NEXT;
SKIP_BLANKS_AND_EOL;
- if (CUR == ']') {
+ if (CUR == ']')
break;
- }
tmp = virConfParseValue(ctxt);
if (tmp == NULL) {
virConfFreeList(lst);
_("numbers not allowed in VMX format"));
return NULL;
}
- if (virConfParseLong(ctxt, &l) < 0) {
+ if (virConfParseLong(ctxt, &l) < 0)
return NULL;
- }
type = VIR_CONF_LONG;
} else {
virConfError(ctxt, VIR_ERR_CONF_SYNTAX, _("expecting a value"));
char *comm = NULL;
SKIP_BLANKS_AND_EOL;
- if (CUR == '#') {
+ if (CUR == '#')
return virConfParseComment(ctxt);
- }
name = virConfParseName(ctxt);
if (name == NULL)
return -1;
return NULL;
}
- if ((len = virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content)) < 0) {
+ if ((len = virFileReadAll(filename, MAX_CONFIG_FILE_SIZE, &content)) < 0)
return NULL;
- }
conf = virConfParse(filename, content, len, flags);
cur = conf->entries;
while (cur != NULL) {
- if ((cur->name != NULL) && (STREQ(cur->name, setting))) {
+ if ((cur->name != NULL) && (STREQ(cur->name, setting)))
break;
- }
prev = cur;
cur = cur->next;
}
/* The iter in the first level of the stack is the
* root iter which must not be freed
*/
- for (i = 1; i < *nstack; i++) {
+ for (i = 1; i < *nstack; i++)
VIR_FREE((*stack)[i].iter);
- }
VIR_FREE(*stack);
}
caps->binaryPath);
return -1;
}
- if (!force && caps->mtime == sb.st_mtime) {
+ if (!force && caps->mtime == sb.st_mtime)
return 0;
- }
caps->mtime = sb.st_mtime;
/* Make sure the binary we are about to try exec'ing exists.
unsigned long long now;
int ret;
- if (virTimeMillisNow(&now) < 0) {
+ if (virTimeMillisNow(&now) < 0)
return -1;
- }
virMutexLock(&eventLoop.lock);
if (eventLoop.timeoutsCount == eventLoop.timeoutsAlloc) {
return;
}
- if (virTimeMillisNow(&now) < 0) {
+ if (virTimeMillisNow(&now) < 0)
return;
- }
virMutexLock(&eventLoop.lock);
for (i = 0; i < eventLoop.timeoutsCount; i++) {
ret = poll(fds, nfds, timeout);
if (ret < 0) {
EVENT_DEBUG("Poll got error event %d", errno);
- if (errno == EINTR || errno == EAGAIN) {
+ if (errno == EINTR || errno == EAGAIN)
goto retry;
- }
virReportSystemError(errno, "%s",
_("Unable to poll on file handles"));
goto error_unlocked;
va_end(ap);
*path = virBufferContentAndReset(&buf);
- if (*path == NULL) {
+ if (*path == NULL)
ret = -1;
- }
return ret;
}
/* XXX This makes assumptions about errno being < 255, which is
* not true on Hurd. */
VIR_FORCE_CLOSE(pair[1]);
- if (ret < 0) {
+ if (ret < 0)
VIR_FORCE_CLOSE(fd);
- }
ret = -ret;
if ((ret & 0xff) != ret) {
VIR_WARN("unable to pass desired return value %d", ret);
/*
* virfirewall.c: integration with firewalls
*
- * Copyright (C) 2013 Red Hat, Inc.
+ * Copyright (C) 2013, 2014 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
break;
}
- while ((str = va_arg(args, char *)) != NULL) {
+ while ((str = va_arg(args, char *)) != NULL)
ADD_ARG(rule, str);
- }
if (group->addingRollback) {
if (VIR_APPEND_ELEMENT_COPY(group->rollback,
va_start(list, rule);
- while ((str = va_arg(list, char *)) != NULL) {
+ while ((str = va_arg(list, char *)) != NULL)
ADD_ARG(rule, str);
- }
va_end(list);
*newline = '\0';
iqn = strrchr(line, ',');
- if (iqn == NULL) {
+ if (iqn == NULL)
continue;
- }
iqn++;
if (STREQ(iqn, initiatoriqn)) {
ret = IQN_ERROR;
out:
- if (ret == IQN_MISSING) {
+ if (ret == IQN_MISSING)
VIR_DEBUG("Could not find interface with IQN '%s'", iqn);
- }
VIR_FREE(line);
VIR_FORCE_FCLOSE(fp);
*ntargetsret = list.ntargets;
*targetsret = list.targets;
} else {
- for (i = 0; i < list.ntargets; i++) {
+ for (i = 0; i < list.ntargets; i++)
VIR_FREE(list.targets[i]);
- }
VIR_FREE(list.targets);
}
}
for (i = 0; i < res->nOwners; i++) {
- if (res->owners[i] == owner) {
+ if (res->owners[i] == owner)
break;
- }
}
if (i == res->nOwners) {
VIR_DEBUG("res %s owner %lld", res->name, (unsigned long long)data->owner);
for (i = 0; i < res->nOwners; i++) {
- if (res->owners[i] == data->owner) {
+ if (res->owners[i] == data->owner)
break;
- }
}
if (i == res->nOwners)
/*
* serialize the error message, add level and timestamp
*/
- if (virVasprintfQuiet(&str, fmt, vargs) < 0) {
+ if (virVasprintfQuiet(&str, fmt, vargs) < 0)
goto cleanup;
- }
ret = virLogFormatString(&msg, linenr, funcname, priority, str);
if (ret < 0)
goto cleanup;
}
- if (virPCIGetNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0) {
+ if (virPCIGetNetName(pci_sysfs_device_link, &((*vfname)[i])) < 0)
VIR_INFO("VF does not have an interface name");
- }
}
ret = 0;
stateDir, pflinkdev, vf) < 0)
return rc;
- if (virFileReadAll(path, 128, &fileData) < 0) {
+ if (virFileReadAll(path, 128, &fileData) < 0)
goto cleanup;
- }
if ((vlan = strchr(fileData, '\n'))) {
char *endptr;
goto cleanup;
}
- if (virNetDevSetName(ifr.ifr_name, brname) == -1) {
+ if (virNetDevSetName(ifr.ifr_name, brname) == -1)
goto cleanup;
- }
ret = 0;
cleanup:
}
}
- if (!indicate) {
+ if (!indicate)
return;
- }
VIR_INFO("Re-send 802.1qbg associate request:");
VIR_INFO(" if: %s", calld->cr_ifname);
return -1;
if (ret) {
- if (STRPREFIX(tgifname, prefix)) {
+ if (STRPREFIX(tgifname, prefix))
goto create_name;
- }
virReportSystemError(EEXIST,
_("Unable to create macvlan device %s"), tgifname);
return -1;
int ret = 0;
int vf = -1;
- if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU) {
+ if (mode == VIR_NETDEV_MACVLAN_MODE_PASSTHRU)
ignore_value(virNetDevRestoreMacAddress(linkdev, stateDir));
- }
if (ifname) {
if (virNetDevVPortProfileDisassociate(ifname,
while (virDirRead(dirp, &dp, "/dev") > 0) {
if (STRPREFIX(dp->d_name, "tap")) {
struct ifreq ifr;
- if (virAsprintf(&devpath, "/dev/%s", dp->d_name) < 0) {
+ if (virAsprintf(&devpath, "/dev/%s", dp->d_name) < 0)
goto cleanup;
- }
if ((fd = open(devpath, O_RDWR)) < 0) {
if (errno == EBUSY) {
VIR_FREE(devpath);
VIR_FREE(dev_path);
}
- if (virNetDevSetName(ifr.ifr_name, *ifname) == -1) {
+ if (virNetDevSetName(ifr.ifr_name, *ifname) == -1)
goto cleanup;
- }
ret = 0;
goto reprobe;
/* Xen's pciback.ko wants you to use remove_slot on the specific device */
- if (virPCIDriverFile(&path, driver, "remove_slot") < 0) {
+ if (virPCIDriverFile(&path, driver, "remove_slot") < 0)
goto cleanup;
- }
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
* is triggered for such a device, it will also be immediately
* bound by the stub.
*/
- if (virPCIDriverFile(&path, stubDriverName, "new_id") < 0) {
+ if (virPCIDriverFile(&path, stubDriverName, "new_id") < 0)
goto cleanup;
- }
if (virFileWriteStr(path, dev->id, 0) < 0) {
virReportSystemError(errno,
*/
if (!virFileLinkPointsTo(driverLink, stubDriverPath)) {
/* Xen's pciback.ko wants you to use new_slot first */
- if (virPCIDriverFile(&path, stubDriverName, "new_slot") < 0) {
+ if (virPCIDriverFile(&path, stubDriverName, "new_slot") < 0)
goto remove_id;
- }
if (virFileExists(path) && virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
}
dev->remove_slot = true;
- if (virPCIDriverFile(&path, stubDriverName, "bind") < 0) {
+ if (virPCIDriverFile(&path, stubDriverName, "bind") < 0)
goto remove_id;
- }
if (virFileWriteStr(path, dev->name, 0) < 0) {
virReportSystemError(errno,
char *path = NULL;
char *id_str;
- if (virPCIFile(&path, dev->name, id_name) < 0) {
+ if (virPCIFile(&path, dev->name, id_name) < 0)
return NULL;
- }
/* ID string is '0xNNNN\n' ... i.e. 7 bytes */
if (virFileReadAll(path, 7, &id_str) < 0) {
{
int serrno = errno;
- if (sexpr == NULL) {
+ if (sexpr == NULL)
return;
- }
switch (sexpr->kind) {
case SEXPR_CONS:
if (nil == NULL)
return -1;
- while (lst->kind != SEXPR_NIL) {
+ while (lst->kind != SEXPR_NIL)
lst = lst->u.s.cdr;
- }
lst->kind = SEXPR_CONS;
lst->u.s.car = (struct sexpr *) value;
ptr = trim(ptr + tmp_len);
}
- if (*ptr == ')') {
+ if (*ptr == ')')
ptr++;
- }
} else {
const char *start;
ptr = buffer;
token = strsep(&ptr, "/");
- if (sexpr->kind != SEXPR_CONS || sexpr->u.s.car->kind != SEXPR_VALUE) {
+ if (sexpr->kind != SEXPR_CONS || sexpr->u.s.car->kind != SEXPR_VALUE)
goto cleanup;
- }
- if (STRNEQ(sexpr->u.s.car->u.value, token)) {
+ if (STRNEQ(sexpr->u.s.car->u.value, token))
goto cleanup;
- }
for (token = strsep(&ptr, "/"); token; token = strsep(&ptr, "/")) {
const struct sexpr *i;
}
}
- if (i->kind == SEXPR_NIL) {
+ if (i->kind == SEXPR_NIL)
break;
- }
}
- if (token != NULL) {
+ if (token != NULL)
goto cleanup;
- }
result = (struct sexpr *) sexpr;
result = virVasprintf(&node, fmt, ap);
va_end(ap);
- if (result < 0) {
+ if (result < 0)
return NULL;
- }
value = sexpr_node(sexpr, node);
ret->format = format;
n = virXPathNodeSet("./secret", ctxt, &nodes);
- if (n < 0) {
+ if (n < 0)
goto cleanup;
- }
if (n != 0 && VIR_ALLOC_N(ret->secrets, n) < 0)
goto cleanup;
ret->nsecrets = n;
char *tmp = *key;
/* Find first non-space character */
- while (*tmp && c_isspace(*tmp)) {
+ while (*tmp && c_isspace(*tmp))
tmp++;
- }
/* Kill leading spaces */
if (tmp != *key)
memmove(*key, tmp, strlen(tmp)+1);
{
int ret = -1;
- if (force) {
+ if (force)
virStorageSourceSeclabelsClear(newelem);
- }
if (!newelem->seclabels &&
virStorageSourceSeclabelsCopy(newelem, old) < 0)
eol = strchr(base, '\n');
cur = strchr(base, ':') + 1;
- if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0) {
+ if (VIR_EXPAND_N(ret->processor, ret->nprocessor, 1) < 0)
return -1;
- }
processor = &ret->processor[ret->nprocessor - 1];
virSkipSpaces(&cur);
if (job == pool->jobList.firstPrio) {
virThreadPoolJobPtr tmp = job->next;
while (tmp) {
- if (tmp->priority) {
+ if (tmp->priority)
break;
- }
tmp = tmp->next;
}
pool->jobList.firstPrio = tmp;
strcpy(name, prefix);
name[offset + i] = '\0';
- for (i = i - 1, ctr = idx; ctr >= 0; --i, ctr = ctr / 26 - 1) {
+ for (i = i - 1, ctr = idx; ctr >= 0; --i, ctr = ctr / 26 - 1)
name[offset + i] = 'a' + (ctr % 26);
- }
return name;
}
size_t i;
const char *p = wwn;
- if (STRPREFIX(wwn, "0x")) {
+ if (STRPREFIX(wwn, "0x"))
p += 2;
- }
for (i = 0; p[i]; i++) {
if (!c_isxdigit(p[i]))
VIR_DEBUG("Disabling inheritance of passed FD %d", fd);
- if (virSetInherit(fd, false) < 0) {
+ if (virSetInherit(fd, false) < 0)
VIR_WARN("Couldn't disable inheritance of passed FD %d", fd);
- }
}
return nfds;
} else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
(!(isnan(obj->floatval)))) {
*value = (long) obj->floatval;
- if (*value != obj->floatval) {
+ if (*value != obj->floatval)
ret = -2;
- }
} else {
ret = -1;
}
} else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
(!(isnan(obj->floatval)))) {
*value = (unsigned long) obj->floatval;
- if (*value != obj->floatval) {
+ if (*value != obj->floatval)
ret = -2;
- }
} else {
ret = -1;
}
} else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
(!(isnan(obj->floatval)))) {
*value = (unsigned long long) obj->floatval;
- if (*value != obj->floatval) {
+ if (*value != obj->floatval)
ret = -2;
- }
} else {
ret = -1;
}
} else if ((obj != NULL) && (obj->type == XPATH_NUMBER) &&
(!(isnan(obj->floatval)))) {
*value = (long long) obj->floatval;
- if (*value != obj->floatval) {
+ if (*value != obj->floatval)
ret = -2;
- }
} else {
ret = -1;
}
base = ctxt->input->base;
/* skip backwards over any end-of-lines */
- while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r'))) {
+ while ((cur > base) && ((*(cur) == '\n') || (*(cur) == '\r')))
cur--;
- }
/* search backwards for beginning-of-line (to max buff size) */
while ((cur > base) && (*(cur) != '\n') && (*(cur) != '\r'))
/* search forward for end-of-line (to max buff size) */
/* copy selected text to our buffer */
- while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r')) {
+ while ((*cur != 0) && (*(cur) != '\n') && (*(cur) != '\r'))
virBufferAddChar(&buf, *cur++);
- }
/* create blank line with problem pointer */
contextstr = virBufferContentAndReset(&buf);