Remove unnecessary curly brackets in src/util/

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
Martin Kletzander 2014-11-13 15:28:18 +01:00
parent c651e08c94
commit 1b7f8ca6bd
25 changed files with 66 additions and 131 deletions

View File

@ -172,15 +172,13 @@ virAuthGetUsernamePath(const char *path,
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;
@ -189,9 +187,8 @@ virAuthGetUsernamePath(const char *path,
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;
}
@ -261,9 +258,8 @@ virAuthGetPasswordPath(const char *path,
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;
}

View File

@ -640,9 +640,8 @@ virBitmapNextSetBit(virBitmapPtr bitmap, ssize_t pos)
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;
@ -726,9 +725,8 @@ virBitmapNextClearBit(virBitmapPtr bitmap, ssize_t pos)
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. */

View File

@ -368,9 +368,8 @@ virBufferVasprintf(virBufferPtr buf, const char *format, va_list argptr)
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],

View File

@ -558,9 +558,8 @@ virExec(virCommandPtr cmd)
pid = virFork();
if (pid < 0) {
if (pid < 0)
goto cleanup;
}
if (pid) { /* parent */
VIR_FORCE_CLOSE(null);
@ -3021,9 +3020,8 @@ virCommandRunNul(virCommandPtr cmd,
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,
@ -3050,9 +3048,8 @@ virCommandRunNul(virCommandPtr cmd,
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]);
}
}
}

View File

@ -502,9 +502,8 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
}
NEXT;
SKIP_BLANKS_AND_EOL;
if (CUR == ']') {
if (CUR == ']')
break;
}
tmp = virConfParseValue(ctxt);
if (tmp == NULL) {
virConfFreeList(lst);
@ -529,9 +528,8 @@ virConfParseValue(virConfParserCtxtPtr ctxt)
_("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"));
@ -654,9 +652,8 @@ virConfParseStatement(virConfParserCtxtPtr ctxt)
char *comm = NULL;
SKIP_BLANKS_AND_EOL;
if (CUR == '#') {
if (CUR == '#')
return virConfParseComment(ctxt);
}
name = virConfParseName(ctxt);
if (name == NULL)
return -1;
@ -768,9 +765,8 @@ virConfReadFile(const char *filename, unsigned int flags)
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);
@ -888,9 +884,8 @@ virConfSetValue(virConfPtr conf,
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;
}

View File

@ -546,9 +546,8 @@ static void virDBusTypeStackFree(virDBusTypeStack **stack,
/* 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);
}

View File

@ -726,9 +726,8 @@ dnsmasqCapsRefreshInternal(dnsmasqCapsPtr caps, bool force)
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.

View File

@ -221,9 +221,8 @@ int virEventPollAddTimeout(int frequency,
unsigned long long now;
int ret;
if (virTimeMillisNow(&now) < 0) {
if (virTimeMillisNow(&now) < 0)
return -1;
}
virMutexLock(&eventLoop.lock);
if (eventLoop.timeoutsCount == eventLoop.timeoutsAlloc) {
@ -270,9 +269,8 @@ void virEventPollUpdateTimeout(int timer, int frequency)
return;
}
if (virTimeMillisNow(&now) < 0) {
if (virTimeMillisNow(&now) < 0)
return;
}
virMutexLock(&eventLoop.lock);
for (i = 0; i < eventLoop.timeoutsCount; i++) {
@ -643,9 +641,8 @@ int virEventPollRunOnce(void)
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;

View File

@ -1180,9 +1180,8 @@ virBuildPathInternal(char **path, ...)
va_end(ap);
*path = virBufferContentAndReset(&buf);
if (*path == NULL) {
if (*path == NULL)
ret = -1;
}
return ret;
}
@ -2047,9 +2046,8 @@ virFileOpenForked(const char *path, int openflags, mode_t mode,
/* 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);

View File

@ -1,7 +1,7 @@
/*
* 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
@ -382,9 +382,8 @@ virFirewallAddRuleFullV(virFirewallPtr firewall,
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,
@ -590,9 +589,8 @@ void virFirewallRuleAddArgList(virFirewallPtr firewall,
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);

View File

@ -157,9 +157,8 @@ virStorageBackendIQNFound(const char *initiatoriqn,
*newline = '\0';
iqn = strrchr(line, ',');
if (iqn == NULL) {
if (iqn == NULL)
continue;
}
iqn++;
if (STREQ(iqn, initiatoriqn)) {
@ -185,9 +184,8 @@ virStorageBackendIQNFound(const char *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);
@ -451,9 +449,8 @@ virISCSIScanTargets(const char *portal,
*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);
}

View File

@ -679,9 +679,8 @@ int virLockSpaceReleaseResource(virLockSpacePtr lockspace,
}
for (i = 0; i < res->nOwners; i++) {
if (res->owners[i] == owner) {
if (res->owners[i] == owner)
break;
}
}
if (i == res->nOwners) {
@ -723,9 +722,8 @@ virLockSpaceRemoveResourcesForOwner(const void *payload,
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)

View File

@ -578,9 +578,8 @@ virLogVMessage(virLogSourcePtr source,
/*
* 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)

View File

@ -1185,9 +1185,8 @@ virNetDevGetVirtualFunctions(const char *pfname,
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;
@ -1758,9 +1757,8 @@ virNetDevRestoreVfConfig(const char *pflinkdev, int vf,
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;

View File

@ -265,9 +265,8 @@ int virNetDevBridgeCreate(const char *brname)
goto cleanup;
}
if (virNetDevSetName(ifr.ifr_name, brname) == -1) {
if (virNetDevSetName(ifr.ifr_name, brname) == -1)
goto cleanup;
}
ret = 0;
cleanup:

View File

@ -682,9 +682,8 @@ virNetDevMacVLanVPortProfileCallback(struct nlmsghdr *hdr,
}
}
if (!indicate) {
if (!indicate)
return;
}
VIR_INFO("Re-send 802.1qbg associate request:");
VIR_INFO(" if: %s", calld->cr_ifname);
@ -851,9 +850,8 @@ int virNetDevMacVLanCreateWithVPortProfile(const char *tgifname,
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;
@ -983,9 +981,8 @@ int virNetDevMacVLanDeleteWithVPortProfile(const char *ifname,
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,

View File

@ -108,9 +108,8 @@ virNetDevTapGetRealDeviceName(char *ifname ATTRIBUTE_UNUSED)
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);
@ -444,9 +443,8 @@ int virNetDevTapCreate(char **ifname,
VIR_FREE(dev_path);
}
if (virNetDevSetName(ifr.ifr_name, *ifname) == -1) {
if (virNetDevSetName(ifr.ifr_name, *ifname) == -1)
goto cleanup;
}
ret = 0;

View File

@ -1127,9 +1127,8 @@ virPCIDeviceUnbindFromStub(virPCIDevicePtr dev)
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,
@ -1214,9 +1213,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
* 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,
@ -1242,9 +1240,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
*/
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,
@ -1255,9 +1252,8 @@ virPCIDeviceBindToStub(virPCIDevicePtr dev,
}
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,
@ -1505,9 +1501,8 @@ virPCIDeviceReadID(virPCIDevicePtr dev, const char *id_name)
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) {

View File

@ -65,9 +65,8 @@ sexpr_free(struct sexpr *sexpr)
{
int serrno = errno;
if (sexpr == NULL) {
if (sexpr == NULL)
return;
}
switch (sexpr->kind) {
case SEXPR_CONS:
@ -163,9 +162,8 @@ append(struct sexpr *lst, const struct sexpr *value)
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;
@ -300,9 +298,8 @@ _string2sexpr(const char *buffer, size_t * end)
ptr = trim(ptr + tmp_len);
}
if (*ptr == ')') {
if (*ptr == ')')
ptr++;
}
} else {
const char *start;
@ -394,13 +391,11 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
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;
@ -419,14 +414,12 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node)
}
}
if (i->kind == SEXPR_NIL) {
if (i->kind == SEXPR_NIL)
break;
}
}
if (token != NULL) {
if (token != NULL)
goto cleanup;
}
result = (struct sexpr *) sexpr;
@ -538,9 +531,8 @@ sexpr_fmt_node(const struct sexpr *sexpr, const char *fmt, ...)
result = virVasprintf(&node, fmt, ap);
va_end(ap);
if (result < 0) {
if (result < 0)
return NULL;
}
value = sexpr_node(sexpr, node);

View File

@ -193,9 +193,8 @@ virStorageEncryptionParseXML(xmlXPathContextPtr ctxt)
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;

View File

@ -1204,9 +1204,8 @@ int virStorageFileGetLVMKey(const char *path,
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);
@ -1919,9 +1918,8 @@ virStorageSourceInitChainElement(virStorageSourcePtr newelem,
{
int ret = -1;
if (force) {
if (force)
virStorageSourceSeclabelsClear(newelem);
}
if (!newelem->seclabels &&
virStorageSourceSeclabelsCopy(newelem, old) < 0)

View File

@ -179,9 +179,8 @@ virSysinfoParseProcessor(const char *base, virSysinfoDefPtr ret)
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);

View File

@ -122,9 +122,8 @@ static void virThreadPoolWorker(void *opaque)
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;

View File

@ -603,9 +603,8 @@ char *virIndexToDiskName(int idx, const char *prefix)
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;
}
@ -1539,9 +1538,8 @@ virValidateWWN(const char *wwn)
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]))
@ -2563,9 +2561,8 @@ virGetListenFDs(void)
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;

View File

@ -185,9 +185,8 @@ virXPathLongBase(const char *xpath,
} 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;
}
@ -291,9 +290,8 @@ virXPathULongBase(const char *xpath,
} 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;
}
@ -408,9 +406,8 @@ virXPathULongLong(const char *xpath,
} 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;
}
@ -455,9 +452,8 @@ virXPathLongLong(const char *xpath,
} 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;
}
@ -655,9 +651,8 @@ catchXMLError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
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'))
@ -669,9 +664,8 @@ catchXMLError(void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
/* 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);