I'm about to add a syntax check that enforces our documented
HACKING style of always using matching {} on if-else statements.
This patch focuses on code related to xen.
* src/libxl/libxl_conf.c (libxlCapsInitGuests)
(libxlMakeDomBuildInfo): Correct use of {}.
* src/xen/xen_hypervisor.c (virXen_getvcpusinfo)
(xenHypervisorMakeCapabilitiesInternal): Likewise.
* src/xen/xend_internal.c (xenDaemonOpen)
(xenDaemonDomainMigratePerform, xend_detect_config_version)
(xenDaemonDetachDeviceFlags, xenDaemonDomainMigratePerform)
(xenDaemonDomainBlockPeek): Likewise.
* src/xenapi/xenapi_driver.c (xenapiConnectListDomains)
(xenapiDomainLookupByUUID, xenapiDomainGetOSType): Likewise.
* src/xenconfig/xen_common.c (xenParseCPUFeatures, xenFormatNet):
Likewise.
* src/xenconfig/xen_sxpr.c (xenParseSxpr, xenFormatSxprNet)
(xenFormatSxpr): Likewise.
Signed-off-by: Eric Blake <eblake(a)redhat.com>
---
src/libxl/libxl_conf.c | 12 ++++--------
src/xen/xen_hypervisor.c | 18 +++++++++---------
src/xen/xend_internal.c | 20 ++++++++------------
src/xenapi/xenapi_driver.c | 13 ++++++++-----
src/xenconfig/xen_common.c | 8 +++-----
src/xenconfig/xen_sxpr.c | 18 +++++++++---------
6 files changed, 41 insertions(+), 48 deletions(-)
diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c
index 1dbdd9c..ea8b5c7 100644
--- a/src/libxl/libxl_conf.c
+++ b/src/libxl/libxl_conf.c
@@ -312,17 +312,14 @@ libxlCapsInitGuests(libxl_ctx *ctx, virCapsPtr caps)
pae = 1;
else
nonpae = 1;
- }
- else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) {
+ } else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) {
arch = VIR_ARCH_X86_64;
- }
- else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) {
+ } else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) {
arch = VIR_ARCH_ITANIUM;
if (subs[3].rm_so != -1 &&
STRPREFIX(&token[subs[3].rm_so], "be"))
ia64_be = 1;
- }
- else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) {
+ } else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) {
arch = VIR_ARCH_PPC64;
} else if (STRPREFIX(&token[subs[2].rm_so], "armv7l")) {
arch = VIR_ARCH_ARMV7L;
@@ -645,8 +642,7 @@ libxlMakeDomBuildInfo(virDomainDefPtr def,
if (def->os.nBootDevs == 0) {
bootorder[0] = 'c';
bootorder[1] = '\0';
- }
- else {
+ } else {
bootorder[def->os.nBootDevs] = '\0';
}
if (VIR_STRDUP(b_info->u.hvm.boot, bootorder) < 0)
diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c
index 0931234..8570653 100644
--- a/src/xen/xen_hypervisor.c
+++ b/src/xen/xen_hypervisor.c
@@ -1664,8 +1664,9 @@ virXen_getvcpusinfo(int handle,
ipt->state = VIR_VCPU_RUNNING;
if (op.u.getvcpuinfo.blocked)
ipt->state = VIR_VCPU_BLOCKED;
- } else
+ } else {
ipt->state = VIR_VCPU_OFFLINE;
+ }
ipt->cpuTime = op.u.getvcpuinfo.cpu_time;
ipt->cpu = op.u.getvcpuinfo.online ? (int)op.u.getvcpuinfo.cpu : -1;
@@ -1675,8 +1676,9 @@ virXen_getvcpusinfo(int handle,
ipt->state = VIR_VCPU_RUNNING;
if (op.u.getvcpuinfod5.blocked)
ipt->state = VIR_VCPU_BLOCKED;
- } else
+ } else {
ipt->state = VIR_VCPU_OFFLINE;
+ }
ipt->cpuTime = op.u.getvcpuinfod5.cpu_time;
ipt->cpu = op.u.getvcpuinfod5.online ? (int)op.u.getvcpuinfod5.cpu : -1;
@@ -2375,8 +2377,9 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
subs[1].rm_eo-subs[1].rm_so,
sizeof(hvm_type)) == NULL)
goto no_memory;
- } else if (regexec(&flags_pae_rec, line, 0, NULL, 0) == 0)
+ } else if (regexec(&flags_pae_rec, line, 0, NULL, 0) == 0) {
host_pae = 1;
+ }
}
}
@@ -2427,17 +2430,14 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn,
pae = 1;
else
nonpae = 1;
- }
- else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) {
+ } else if (STRPREFIX(&token[subs[2].rm_so], "x86_64")) {
arch = VIR_ARCH_X86_64;
- }
- else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) {
+ } else if (STRPREFIX(&token[subs[2].rm_so], "ia64")) {
arch = VIR_ARCH_ITANIUM;
if (subs[3].rm_so != -1 &&
STRPREFIX(&token[subs[3].rm_so], "be"))
ia64_be = 1;
- }
- else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64")) {
+ } else if (STRPREFIX(&token[subs[2].rm_so], "powerpc64"))
{
arch = VIR_ARCH_PPC64;
} else {
/* XXX surely no other Xen archs exist. Arrrrrrrrrm */
diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c
index 6d1fec7..d9e76fc 100644
--- a/src/xen/xend_internal.c
+++ b/src/xen/xend_internal.c
@@ -883,7 +883,7 @@ xend_detect_config_version(virConnectPtr conn)
if (value) {
if (virStrToLong_i(value, NULL, 10, &priv->xendConfigVersion) < 0)
goto cleanup;
- } else {
+ } else {
/* Xen prior to 3.0.3 did not have the xend_config_format
field, and is implicitly version 1. */
priv->xendConfigVersion = XEND_CONFIG_VERSION_3_0_2;
@@ -1206,8 +1206,7 @@ xenDaemonOpen(virConnectPtr conn,
if (xenDaemonOpen_unix(conn, conn->uri->path) < 0 ||
xend_detect_config_version(conn) == -1)
goto failed;
- }
- else if (STRCASEEQ(conn->uri->scheme, "xen")) {
+ } else if (STRCASEEQ(conn->uri->scheme, "xen")) {
/*
* try first to open the unix socket
*/
@@ -2531,8 +2530,7 @@ xenDaemonDetachDeviceFlags(virConnectPtr conn,
ret = xend_op(conn, minidef->name, "op",
"device_configure",
"config", xendev, "dev", ref, NULL);
VIR_FREE(xendev);
- }
- else {
+ } else {
ret = xend_op(conn, minidef->name, "op",
"device_destroy",
"type", class, "dev", ref, "force",
"0", "rm_cfg", "1",
NULL);
@@ -2767,8 +2765,7 @@ xenDaemonDomainMigratePerform(virConnectPtr conn,
if (uriptr->port)
snprintf(port, sizeof(port), "%d", uriptr->port);
virURIFree(uriptr);
- }
- else if ((p = strrchr(uri, ':')) != NULL) { /* "hostname:port" */
+ } else if ((p = strrchr(uri, ':')) != NULL) { /* "hostname:port"
*/
int port_nr, n;
if (virStrToLong_i(p+1, NULL, 10, &port_nr) < 0) {
@@ -2783,8 +2780,7 @@ xenDaemonDomainMigratePerform(virConnectPtr conn,
if (VIR_STRDUP(hostname, uri) < 0)
return -1;
hostname[n] = '\0';
- }
- else { /* "hostname" (or IP address) */
+ } else { /* "hostname" (or IP address) */
if (VIR_STRDUP(hostname, uri) < 0)
return -1;
}
@@ -3244,13 +3240,13 @@ xenDaemonDomainBlockPeek(virConnectPtr conn,
const char *actual;
/* Security check: The path must correspond to a block device. */
- if (minidef->id > 0)
+ if (minidef->id > 0) {
root = sexpr_get(conn, "/xend/domain/%d?detail=1",
minidef->id);
- else if (minidef->id < 0)
+ } else if (minidef->id < 0) {
root = sexpr_get(conn, "/xend/domain/%s?detail=1",
minidef->name);
- else {
+ } else {
/* This call always fails for dom0. */
virReportError(VIR_ERR_OPERATION_INVALID,
"%s", _("domainBlockPeek is not supported for
dom0"));
diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c
index 50331c9..723544a 100644
--- a/src/xenapi/xenapi_driver.c
+++ b/src/xenapi/xenapi_driver.c
@@ -472,8 +472,9 @@ xenapiConnectListDomains(virConnectPtr conn, int *ids, int maxids)
if (xen_session_get_this_host(session, &host, session)) {
xen_host_get_resident_vms(session, &result, host);
xen_host_free(host);
- } else
+ } else {
xenapiSessionErrorHandler(conn, VIR_ERR_INTERNAL_ERROR, NULL);
+ }
if (result != NULL) {
for (i = 0; (i < (result->size)) && (i < maxids); i++) {
xen_vm_get_domid(session, &t0, result->contents[i]);
@@ -656,12 +657,13 @@ xenapiDomainLookupByUUID(virConnectPtr conn,
domP->id = record->domid;
}
xen_vm_record_free(record);
- }
- else
+ } else {
xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
+ }
xen_vm_free(vm);
- } else
+ } else {
xenapiSessionErrorHandler(conn, VIR_ERR_NO_DOMAIN, NULL);
+ }
return domP;
}
@@ -958,8 +960,9 @@ xenapiDomainGetOSType(virDomainPtr dom)
ignore_value(VIR_STRDUP(ostype,
STREQ(boot_policy, "BIOS order") ?
"hvm" : "xen"));
VIR_FREE(boot_policy);
- } else
+ } else {
xenapiSessionErrorHandler(dom->conn, VIR_ERR_NO_DOMAIN, NULL);
+ }
cleanup:
if (vms)
diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c
index 9beaf6c..accd25f 100644
--- a/src/xenconfig/xen_common.c
+++ b/src/xenconfig/xen_common.c
@@ -541,7 +541,7 @@ xenParseCPUFeatures(virConfPtr conf, virDomainDefPtr def)
if (xenConfigGetBool(conf, "hpet", &val, -1) < 0)
return -1;
- else if (val != -1) {
+ if (val != -1) {
virDomainTimerDefPtr timer;
if (VIR_ALLOC_N(def->clock.timers, 1) < 0 ||
@@ -1269,12 +1269,10 @@ xenFormatNet(virConnectPtr conn,
if (!hvm) {
if (net->model != NULL)
virBufferAsprintf(&buf, ",model=%s", net->model);
- }
- else {
+ } else {
if (net->model != NULL && STREQ(net->model, "netfront"))
{
virBufferAddLit(&buf, ",type=netfront");
- }
- else {
+ } else {
if (net->model != NULL)
virBufferAsprintf(&buf, ",model=%s", net->model);
diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c
index ff81c36..6c48e97 100644
--- a/src/xenconfig/xen_sxpr.c
+++ b/src/xenconfig/xen_sxpr.c
@@ -1176,8 +1176,9 @@ xenParseSxpr(const struct sexpr *root,
_("unknown lifecycle type %s"), tmp);
goto error;
}
- } else
+ } else {
def->onPoweroff = VIR_DOMAIN_LIFECYCLE_DESTROY;
+ }
tmp = sexpr_node(root, "domain/on_reboot");
if (tmp != NULL) {
@@ -1186,8 +1187,9 @@ xenParseSxpr(const struct sexpr *root,
_("unknown lifecycle type %s"), tmp);
goto error;
}
- } else
+ } else {
def->onReboot = VIR_DOMAIN_LIFECYCLE_RESTART;
+ }
tmp = sexpr_node(root, "domain/on_crash");
if (tmp != NULL) {
@@ -1196,8 +1198,9 @@ xenParseSxpr(const struct sexpr *root,
_("unknown lifecycle type %s"), tmp);
goto error;
}
- } else
+ } else {
def->onCrash = VIR_DOMAIN_LIFECYCLE_DESTROY;
+ }
if (hvm) {
if (sexpr_int(root, "domain/image/hvm/acpi"))
@@ -1950,12 +1953,10 @@ xenFormatSxprNet(virConnectPtr conn,
if (!hvm) {
if (def->model != NULL)
virBufferEscapeSexpr(buf, "(model '%s')", def->model);
- }
- else {
+ } else {
if (def->model != NULL && STREQ(def->model, "netfront"))
{
virBufferAddLit(buf, "(type netfront)");
- }
- else {
+ } else {
if (def->model != NULL) {
virBufferEscapeSexpr(buf, "(model '%s')",
def->model);
}
@@ -2393,8 +2394,7 @@ xenFormatSxpr(virConnectPtr conn,
}
}
virBufferAddLit(&buf, "))");
- }
- else {
+ } else {
virBufferAddLit(&buf, "(serial ");
if (xenFormatSxprChr(def->serials[0], &buf) < 0)
goto error;
--
1.9.3