/*
* stream.c: APIs for managing client streams
*
- * Copyright (C) 2009, 2011 Red Hat, Inc.
+ * Copyright (C) 2009-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
virStreamEventRemoveCallback(stream->st);
virStreamAbort(stream->st);
- if (msg->header.status == VIR_NET_ERROR)
+ if (msg->header.status == VIR_NET_ERROR) {
virReportError(VIR_ERR_RPC,
"%s", _("stream aborted at client request"));
- else {
+ } else {
VIR_WARN("unexpected stream status %d", msg->header.status);
virReportError(VIR_ERR_RPC,
_("stream aborted with unexpected status %d"),
#
# esx_vi_generator.py: generates most of the SOAP type mapping code
#
+# Copyright (C) 2014 Red Hat, Inc.
# Copyright (C) 2010-2012 Matthias Bolte <matthias.bolte@googlemail.com>
# Copyright (C) 2013 Ata E Husain Bohra <ata.husain@hotmail.com>
#
def generate_typefromstring(self):
- string = " else if (STREQ(type, \"%s\")) {\n" % self.name
+ string = " if (STREQ(type, \"%s\"))\n" % self.name
string += " return esxVI_Type_%s;\n" % self.name
- string += " }\n"
return string
/*
* esx_vi_types.c: client for the VMware VI API 2.5 to manage ESX hosts
*
- * Copyright (C) 2010 Red Hat, Inc.
+ * Copyright (C) 2010, 2014 Red Hat, Inc.
* Copyright (C) 2009-2011 Matthias Bolte <matthias.bolte@googlemail.com>
*
* This library is free software; you can redistribute it and/or
#include "esx_vi_types.generated.typefromstring"
- else {
- return esxVI_Type_Other;
- }
+ return esxVI_Type_Other;
}
else
transport = trans_unix;
} else {
- if (STRCASEEQ(transport_str, "tls"))
+ if (STRCASEEQ(transport_str, "tls")) {
transport = trans_tls;
- else if (STRCASEEQ(transport_str, "unix")) {
+ } else if (STRCASEEQ(transport_str, "unix")) {
if (conn->uri->server) {
virReportError(VIR_ERR_INVALID_ARG,
_("using unix socket and remote "
} else {
transport = trans_unix;
}
- } else if (STRCASEEQ(transport_str, "ssh"))
+ } else if (STRCASEEQ(transport_str, "ssh")) {
transport = trans_ssh;
- else if (STRCASEEQ(transport_str, "libssh2"))
+ } else if (STRCASEEQ(transport_str, "libssh2")) {
transport = trans_libssh2;
- else if (STRCASEEQ(transport_str, "ext"))
+ } else if (STRCASEEQ(transport_str, "ext")) {
transport = trans_ext;
- else if (STRCASEEQ(transport_str, "tcp"))
+ } else if (STRCASEEQ(transport_str, "tcp")) {
transport = trans_tcp;
- else {
+ } else {
virReportError(VIR_ERR_INVALID_ARG, "%s",
_("remote_open: transport in URL not recognised "
"(should be tls|unix|ssh|ext|tcp|libssh2)"));
if (virNetSSHSessionAuthSetCallback(sess, auth) != 0)
goto error;
- if (STRCASEEQ("auto", knownHostsVerify))
+ if (STRCASEEQ("auto", knownHostsVerify)) {
verify = VIR_NET_SSH_HOSTKEY_VERIFY_AUTO_ADD;
- else if (STRCASEEQ("ignore", knownHostsVerify))
+ } else if (STRCASEEQ("ignore", knownHostsVerify)) {
verify = VIR_NET_SSH_HOSTKEY_VERIFY_IGNORE;
- else if (STRCASEEQ("normal", knownHostsVerify))
+ } else if (STRCASEEQ("normal", knownHostsVerify)) {
verify = VIR_NET_SSH_HOSTKEY_VERIFY_NORMAL;
- else {
+ } else {
virReportError(VIR_ERR_INVALID_ARG,
_("Invalid host key verification method: '%s'"),
knownHostsVerify);
authMethodNext = authMethodsCopy;
while ((authMethod = strsep(&authMethodNext, ","))) {
- if (STRCASEEQ(authMethod, "keyboard-interactive"))
+ if (STRCASEEQ(authMethod, "keyboard-interactive")) {
ret = virNetSSHSessionAuthAddKeyboardAuth(sess, username, -1);
- else if (STRCASEEQ(authMethod, "password"))
+ } else if (STRCASEEQ(authMethod, "password")) {
ret = virNetSSHSessionAuthAddPasswordAuth(sess,
uri,
username);
- else if (STRCASEEQ(authMethod, "privkey"))
+ } else if (STRCASEEQ(authMethod, "privkey")) {
ret = virNetSSHSessionAuthAddPrivKeyAuth(sess,
username,
privkey,
NULL);
- else if (STRCASEEQ(authMethod, "agent"))
+ } else if (STRCASEEQ(authMethod, "agent")) {
ret = virNetSSHSessionAuthAddAgentAuth(sess, username);
- else {
+ } else {
virReportError(VIR_ERR_INVALID_ARG,
_("Invalid authentication method: '%s'"),
authMethod);
if (STRNEQLEN(path, "/", 1))
return 1;
- if (!virFileExists(path))
+ if (!virFileExists(path)) {
vah_warning(_("path does not exist, skipping file type checks"));
- else {
+ } else {
if (stat(path, &sb) == -1)
return -1;
vah_error(NULL, 0, _("could not find realpath for disk"));
return rc;
}
- } else
- if (VIR_STRDUP_QUIET(tmp, path) < 0)
- return rc;
+ } else if (VIR_STRDUP_QUIET(tmp, path) < 0) {
+ return rc;
+ }
if (strchr(perms, 'w') != NULL)
readonly = false;
APPARMOR_DIR "/libvirt", ctl->uuid) < 0)
vah_error(ctl, 0, _("could not allocate memory"));
- if (ctl->cmd == 'a')
+ if (ctl->cmd == 'a') {
rc = parserLoad(ctl->uuid);
- else if (ctl->cmd == 'R' || ctl->cmd == 'D') {
+ } else if (ctl->cmd == 'R' || ctl->cmd == 'D') {
rc = parserRemove(ctl->uuid);
if (ctl->cmd == 'D') {
unlink(include_file);
dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_DISK) {
if (dev->data.disk->bus == VIR_DOMAIN_DISK_BUS_UML)
ret = umlDomainDetachUmlDisk(driver, vm, dev);
- else {
+ else
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
_("This type of disk cannot be hot unplugged"));
- }
} else {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("This type of device cannot be hot unplugged"));
/*
* viralloc.c: safer memory allocation
*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-2014 Red Hat, Inc.
* Copyright (C) 2008 Daniel P. Berrange
*
* This library is free software; you can redistribute it and/or
*/
void virShrinkN(void *ptrptr, size_t size, size_t *countptr, size_t toremove)
{
- if (toremove < *countptr)
+ if (toremove < *countptr) {
ignore_value(virReallocN(ptrptr, size, *countptr -= toremove,
false, 0, NULL, NULL, 0));
- else {
+ } else {
virFree(ptrptr);
*countptr = 0;
}
/*
* virbuffer.c: buffers for libvirt
*
- * Copyright (C) 2005-2008, 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2005-2008, 2010-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
return;
for (p = str; *p; ++p) {
- if (c_isalnum(*p))
+ if (c_isalnum(*p)) {
buf->content[buf->use++] = *p;
- else {
+ } else {
uc = (unsigned char) *p;
buf->content[buf->use++] = '%';
buf->content[buf->use++] = hex[uc >> 4];
call,
VIR_DBUS_METHOD_CALL_TIMEOUT_MILLIS,
error ? error : &localerror))) {
- if (error)
+ if (error) {
ret = 0;
- else {
+ } else {
virReportError(VIR_ERR_DBUS_SERVICE, _("%s: %s"), member,
localerror.message ? localerror.message : _("unknown error"));
}
if (ifindex != -1) {
if (virNetDevGetIndex(ifname, &idx) < 0)
goto cleanup;
- else if (idx != ifindex) {
+ if (idx != ifindex) {
ret = 0;
goto cleanup;
}
if (tb[IFLA_LINK]) {
ifindex = *(int *)RTA_DATA(tb[IFLA_LINK]);
ifname = NULL;
- } else
+ } else {
end = true;
+ }
i++;
}
virPCIDeviceFree(check);
ret = -1;
break;
- }
- else if (rc == 1) {
+ } else if (rc == 1) {
VIR_DEBUG("%s %s: iter matched on %s", dev->id, dev->name, check->name);
*matched = check;
ret = 1;
ret = 1;
break;
}
- }
- else {
+ } else {
in_matching_device = false;
/* expected format: <start>-<end> : <domain>:<bus>:<slot>.<function> */
* into play since devices on the root bus can't P2P without going
* through the root IOMMU.
*/
- if (dev->bus == 0)
+ if (dev->bus == 0) {
return 0;
- else {
+ } else {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Failed to find parent device for %s"),
dev->name);
j = i << 3;
while (j < (8 * 4)) {
bit = 1 << (7 - (j & 7));
- if ((tm[j >> 3] & bit)) {
+ if ((tm[j >> 3] & bit))
c++;
- } else
+ else
break;
j++;
}
j = i << 4;
while (j < (16 * 8)) {
bit = 1 << (15 - (j & 0xf));
- if ((tm[j >> 4] & bit)) {
+ if ((tm[j >> 4] & bit))
c++;
- } else
+ else
break;
j++;
}
/*
* viruri.c: URI parsing wrappers for libxml2 functions
*
- * Copyright (C) 2012 Red Hat, Inc.
+ * Copyright (C) 2012-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
eq = strchr(query, '=');
if (eq && eq >= end) eq = NULL;
- /* Empty section (eg. "&&"). */
- if (end == query)
+ if (end == query) {
+ /* Empty section (eg. "&&"). */
goto next;
-
- /* If there is no '=' character, then we have just "name"
- * and consistent with CGI.pm we assume value is "".
- */
- else if (!eq) {
+ } else if (!eq) {
+ /* If there is no '=' character, then we have just "name"
+ * and consistent with CGI.pm we assume value is "".
+ */
name = xmlURIUnescapeString(query, end - query, NULL);
if (!name) goto no_memory;
- }
- /* Or if we have "name=" here (works around annoying
- * problem when calling xmlURIUnescapeString with len = 0).
- */
- else if (eq+1 == end) {
+ } else if (eq+1 == end) {
+ /* Or if we have "name=" here (works around annoying
+ * problem when calling xmlURIUnescapeString with len = 0).
+ */
name = xmlURIUnescapeString(query, eq - query, NULL);
if (!name) goto no_memory;
- }
- /* If the '=' character is at the beginning then we have
- * "=value" and consistent with CGI.pm we _ignore_ this.
- */
- else if (query == eq)
+ } else if (query == eq) {
+ /* If the '=' character is at the beginning then we have
+ * "=value" and consistent with CGI.pm we _ignore_ this.
+ */
goto next;
-
- /* Otherwise it's "name=value". */
- else {
+ } else {
+ /* Otherwise it's "name=value". */
name = xmlURIUnescapeString(query, eq - query, NULL);
if (!name)
goto no_memory;
/*
* cputest.c: Test the libvirtd internal CPU APIs
*
- * Copyright (C) 2010-2013 Red Hat, Inc.
+ * Copyright (C) 2010-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
baseline = cpuBaseline(cpus, ncpus, NULL, 0, data->flags);
if (data->result < 0) {
virResetLastError();
- if (!baseline)
+ if (!baseline) {
ret = 0;
- else if (virTestGetVerbose()) {
+ } else if (virTestGetVerbose()) {
fprintf(stderr, "\n%-70s... ",
"cpuBaseline was expected to fail but it succeeded");
}
testCounter++;
if (virTestGetVerbose()) {
fprintf(stderr, "%3zu) %-60s ", testCounter, name);
- if (ret == 0)
+ if (ret == 0) {
fprintf(stderr, "OK\n");
- else {
+ } else {
fprintf(stderr, "FAILED\n");
if (msg) {
char *str;
if (vshCommandOptStringReq(ctl, cmd, "target", &target) < 0)
goto cleanup;
- if (STREQ(target, "mem"))
+ if (STREQ(target, "mem")) {
suspendTarget = VIR_NODE_SUSPEND_TARGET_MEM;
- else if (STREQ(target, "disk"))
+ } else if (STREQ(target, "disk")) {
suspendTarget = VIR_NODE_SUSPEND_TARGET_DISK;
- else if (STREQ(target, "hybrid"))
+ } else if (STREQ(target, "hybrid")) {
suspendTarget = VIR_NODE_SUSPEND_TARGET_HYBRID;
- else {
+ } else {
vshError(ctl, "%s", _("Invalid target"));
goto cleanup;
}
return false;
}
- if (STREQ(target, "mem"))
+ if (STREQ(target, "mem")) {
suspendTarget = VIR_NODE_SUSPEND_TARGET_MEM;
- else if (STREQ(target, "disk"))
+ } else if (STREQ(target, "disk")) {
suspendTarget = VIR_NODE_SUSPEND_TARGET_DISK;
- else if (STREQ(target, "hybrid"))
+ } else if (STREQ(target, "hybrid")) {
suspendTarget = VIR_NODE_SUSPEND_TARGET_HYBRID;
- else {
+ } else {
vshError(ctl, "%s", _("Invalid target"));
return false;
}