[libvirt] [PATCH 00/15] Cleanup some curly braces

There were unnecessary curly braces in few places (and the whole esx driver), so this series proposes fixing them. As this couldn't be done automatically, there is no syntax-check. We have to keep trying to eliminate that ;) Martin Kletzander (15): vbox: Remove useless condition branches Remove unneeded curly brackets around oneline code blocks in src/conf/ Remove unneeded curly brackets around oneline code blocks in src/esx/ Remove unneeded curly brackets around oneline code blocks in src/hyperv/ Remove unneeded curly brackets around oneline code blocks in src/node_device/ Remove unneeded curly brackets around oneline code blocks in src/qemu/ Remove unneeded curly brackets around oneline code blocks in src/util/ Remove unneeded curly brackets around oneline code blocks in src/vbox/ Remove unneeded curly brackets around oneline code blocks in src/vmx/ Remove unneeded curly brackets around oneline code blocks in src/[u-z]*/ Remove unneeded curly brackets around oneline code blocks in src/[st]*/ Remove unneeded curly brackets around oneline code blocks in src/[n-r]*/ Remove unneeded curly brackets around oneline code blocks in src/[a-m]*/ Remove unneeded curly brackets around oneline code blocks in tests/ Remove unneeded curly brackets around oneline code blocks daemon/libvirtd.c | 15 +- daemon/remote.c | 15 +- examples/object-events/event-test.c | 3 +- examples/openauth/openauth.c | 9 +- src/access/viraccessdriverstack.c | 3 +- src/bhyve/bhyve_driver.c | 3 +- src/conf/capabilities.c | 3 +- src/conf/device_conf.c | 6 +- src/conf/domain_conf.c | 203 +++----- src/conf/interface_conf.c | 9 +- src/conf/netdev_vport_profile_conf.c | 12 +- src/conf/network_conf.c | 114 ++-- src/conf/node_device_conf.c | 27 +- src/conf/nwfilter_conf.c | 24 +- src/conf/object_event.c | 6 +- src/conf/storage_conf.c | 30 +- src/cpu/cpu_powerpc.c | 3 +- src/cpu/cpu_x86.c | 3 +- src/datatypes.c | 6 +- src/driver.c | 3 +- src/esx/esx_device_monitor.c | 3 +- src/esx/esx_driver.c | 838 ++++++++++-------------------- src/esx/esx_interface_driver.c | 36 +- src/esx/esx_network_driver.c | 132 ++--- src/esx/esx_nwfilter_driver.c | 3 +- src/esx/esx_secret_driver.c | 3 +- src/esx/esx_storage_backend_iscsi.c | 78 +-- src/esx/esx_storage_backend_vmfs.c | 204 +++----- src/esx/esx_storage_driver.c | 81 +-- src/esx/esx_util.c | 51 +- src/esx/esx_vi.c | 606 +++++++-------------- src/esx/esx_vi_methods.c | 3 +- src/esx/esx_vi_types.c | 54 +- src/hyperv/hyperv_device_monitor.c | 3 +- src/hyperv/hyperv_driver.c | 132 ++--- src/hyperv/hyperv_interface_driver.c | 3 +- src/hyperv/hyperv_network_driver.c | 3 +- src/hyperv/hyperv_nwfilter_driver.c | 3 +- src/hyperv/hyperv_secret_driver.c | 3 +- src/hyperv/hyperv_storage_driver.c | 3 +- src/hyperv/hyperv_util.c | 6 +- src/hyperv/hyperv_wmi.c | 45 +- src/interface/interface_backend_udev.c | 15 +- src/libvirt-domain.c | 6 +- src/libvirt-lxc.c | 3 +- src/libvirt-nodedev.c | 3 +- src/libvirt-storage.c | 6 +- src/libxl/libxl_conf.c | 3 +- src/libxl/libxl_driver.c | 12 +- src/locking/lock_daemon.c | 9 +- src/locking/lock_driver_sanlock.c | 6 +- src/lxc/lxc_container.c | 12 +- src/lxc/lxc_driver.c | 12 +- src/lxc/lxc_process.c | 6 +- src/network/bridge_driver.c | 53 +- src/network/bridge_driver_linux.c | 9 +- src/network/leaseshelper.c | 3 +- src/node_device/node_device_driver.c | 33 +- src/node_device/node_device_hal.c | 6 +- src/node_device/node_device_udev.c | 222 +++----- src/nodeinfo.c | 3 +- src/nwfilter/nwfilter_dhcpsnoop.c | 6 +- src/nwfilter/nwfilter_ebiptables_driver.c | 12 +- src/nwfilter/nwfilter_gentech_driver.c | 12 +- src/nwfilter/nwfilter_learnipaddr.c | 3 +- src/openvz/openvz_conf.c | 3 +- src/openvz/openvz_driver.c | 33 +- src/parallels/parallels_driver.c | 6 +- src/phyp/phyp_driver.c | 21 +- src/qemu/qemu_agent.c | 3 +- src/qemu/qemu_capabilities.c | 15 +- src/qemu/qemu_cgroup.c | 12 +- src/qemu/qemu_command.c | 42 +- src/qemu/qemu_conf.c | 3 +- src/qemu/qemu_domain.c | 9 +- src/qemu/qemu_driver.c | 57 +- src/qemu/qemu_hotplug.c | 42 +- src/qemu/qemu_migration.c | 18 +- src/qemu/qemu_monitor_json.c | 30 +- src/qemu/qemu_monitor_text.c | 9 +- src/qemu/qemu_process.c | 36 +- src/remote/remote_driver.c | 33 +- src/rpc/virnetclient.c | 9 +- src/rpc/virnetserver.c | 3 +- src/rpc/virnetserverclient.c | 3 +- src/rpc/virnetserverservice.c | 3 +- src/security/security_dac.c | 9 +- src/security/security_manager.c | 3 +- src/security/security_selinux.c | 6 +- src/security/virt-aa-helper.c | 15 +- src/storage/parthelper.c | 3 +- src/storage/storage_backend.c | 9 +- src/storage/storage_backend_disk.c | 21 +- src/storage/storage_backend_fs.c | 9 +- src/storage/storage_backend_mpath.c | 30 +- src/storage/storage_backend_rbd.c | 30 +- src/storage/storage_backend_scsi.c | 9 +- src/storage/storage_driver.c | 9 +- src/test/test_driver.c | 66 +-- src/uml/uml_conf.c | 6 +- src/uml/uml_driver.c | 9 +- src/util/virauth.c | 21 +- src/util/virbitmap.c | 6 +- src/util/virbuffer.c | 3 +- src/util/vircgroup.c | 3 +- src/util/vircommand.c | 12 +- src/util/virconf.c | 15 +- src/util/virdbus.c | 6 +- src/util/virdnsmasq.c | 6 +- src/util/vireventpoll.c | 12 +- src/util/virfile.c | 9 +- src/util/virfirewall.c | 6 +- src/util/virhostdev.c | 6 +- src/util/viriscsi.c | 12 +- src/util/virjson.c | 3 +- src/util/virlockspace.c | 6 +- src/util/virlog.c | 6 +- src/util/virnetdev.c | 12 +- src/util/virnetdevbridge.c | 3 +- src/util/virnetdevmacvlan.c | 15 +- src/util/virnetdevtap.c | 9 +- src/util/virnetdevvlan.c | 3 +- src/util/virnetdevvportprofile.c | 6 +- src/util/virpci.c | 33 +- src/util/virsexpr.c | 30 +- src/util/virstorageencryption.c | 3 +- src/util/virstoragefile.c | 6 +- src/util/virsysinfo.c | 3 +- src/util/virthreadpool.c | 9 +- src/util/virutil.c | 12 +- src/util/virxml.c | 18 +- src/vbox/vbox_MSCOMGlue.c | 33 +- src/vbox/vbox_XPCOMCGlue.c | 33 +- src/vbox/vbox_common.c | 77 +-- src/vbox/vbox_network.c | 24 +- src/vbox/vbox_snapshot_conf.c | 21 +- src/vbox/vbox_storage.c | 30 +- src/vbox/vbox_tmpl.c | 30 +- src/vmware/vmware_conf.c | 9 +- src/vmware/vmware_driver.c | 6 +- src/vmx/vmx.c | 369 +++++-------- src/xen/block_stats.c | 3 +- src/xen/xen_driver.c | 6 +- src/xen/xen_hypervisor.c | 12 +- src/xen/xen_inotify.c | 3 +- src/xen/xend_internal.c | 21 +- src/xen/xm_internal.c | 11 +- src/xenapi/xenapi_driver.c | 15 +- src/xenapi/xenapi_utils.c | 15 +- src/xenconfig/xen_common.c | 12 +- src/xenconfig/xen_sxpr.c | 12 +- src/xenconfig/xen_xm.c | 3 +- tests/commandhelper.c | 3 +- tests/esxutilstest.c | 18 +- tests/eventtest.c | 3 +- tests/networkxml2conftest.c | 3 +- tests/networkxml2xmltest.c | 3 +- tests/networkxml2xmlupdatetest.c | 3 +- tests/nodeinfotest.c | 3 +- tests/nwfilterxml2xmltest.c | 3 +- tests/openvzutilstest.c | 9 +- tests/qemuxml2argvtest.c | 6 +- tests/qemuxmlnstest.c | 3 +- tests/secretxml2xmltest.c | 3 +- tests/securityselinuxlabeltest.c | 6 +- tests/sexpr2xmltest.c | 3 +- tests/shunloadtest.c | 6 +- tests/storagepoolxml2xmltest.c | 3 +- tests/storagevolxml2argvtest.c | 3 +- tests/storagevolxml2xmltest.c | 3 +- tests/sysinfotest.c | 6 +- tests/utiltest.c | 3 +- tests/virbuftest.c | 3 +- tests/virhashtest.c | 42 +- tests/virtimetest.c | 3 +- tests/vmx2xmltest.c | 24 +- tests/xml2sexprtest.c | 3 +- tests/xml2vmxtest.c | 39 +- tools/virsh-console.c | 15 +- tools/virsh-domain.c | 30 +- tools/virsh-edit.c | 6 +- tools/virsh-host.c | 3 +- tools/virsh-interface.c | 6 +- tools/virsh-pool.c | 6 +- tools/virsh-volume.c | 15 +- tools/virsh.c | 18 +- tools/wireshark/src/packet-libvirt.c | 6 +- 187 files changed, 1746 insertions(+), 3474 deletions(-) -- 2.1.3

These were probably left there after some code movement. Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/vbox/vbox_common.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index bc80338..cd5b478 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -4144,23 +4144,12 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, const char *src = virDomainDiskGetSource(dev->data.disk); int type = virDomainDiskGetType(dev->data.disk); - if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM) { - if (type == VIR_STORAGE_TYPE_FILE && src) { - ret = gVBoxAPI.attachDVD(data, machine, src); - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } else if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) { - if (type == VIR_STORAGE_TYPE_FILE && src) { - ret = gVBoxAPI.attachFloppy(data, machine, src); - } else if (type == VIR_STORAGE_TYPE_BLOCK) { - } - } - } - } else if (dev->type == VIR_DOMAIN_DEVICE_NET) { - } else if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) { - if (dev->data.hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) { - if (dev->data.hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB) { - } + if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_CDROM && + type == VIR_STORAGE_TYPE_FILE && src) + ret = gVBoxAPI.attachDVD(data, machine, src); + else if (dev->data.disk->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && + type == VIR_STORAGE_TYPE_FILE && src) + ret = gVBoxAPI.attachFloppy(data, machine, src); } } else if (dev->type == VIR_DOMAIN_DEVICE_FS && dev->data.fs->type == VIR_DOMAIN_FS_TYPE_MOUNT) { -- 2.1.3

On 11/06/2014 05:38 PM, Martin Kletzander wrote:
These were probably left there after some code movement.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/vbox/vbox_common.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
ACK to this one, regardless of the fate of the rest of the series. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Nov 07, 2014 at 10:43:47AM +0100, Eric Blake wrote:
On 11/06/2014 05:38 PM, Martin Kletzander wrote:
These were probably left there after some code movement.
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/vbox/vbox_common.c | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-)
ACK to this one, regardless of the fate of the rest of the series.
I pushed this one only, we'll see about the rest. Martin

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/conf/capabilities.c | 3 +- src/conf/device_conf.c | 6 +- src/conf/domain_conf.c | 203 ++++++++++++----------------------- src/conf/interface_conf.c | 9 +- src/conf/netdev_vport_profile_conf.c | 12 +-- src/conf/network_conf.c | 114 +++++++------------- src/conf/node_device_conf.c | 27 ++--- src/conf/nwfilter_conf.c | 24 ++--- src/conf/object_event.c | 6 +- src/conf/storage_conf.c | 30 ++---- 10 files changed, 149 insertions(+), 285 deletions(-) diff --git a/src/conf/capabilities.c b/src/conf/capabilities.c index dc2c01a..37d19c1 100644 --- a/src/conf/capabilities.c +++ b/src/conf/capabilities.c @@ -219,9 +219,8 @@ virCapabilitiesDispose(void *object) VIR_FREE(caps->host.migrateTrans[i]); VIR_FREE(caps->host.migrateTrans); - for (i = 0; i < caps->host.nsecModels; i++) { + for (i = 0; i < caps->host.nsecModels; i++) virCapabilitiesClearSecModel(&caps->host.secModels[i]); - } VIR_FREE(caps->host.secModels); VIR_FREE(caps->host.pagesSize); diff --git a/src/conf/device_conf.c b/src/conf/device_conf.c index b3b04e1..8b833e3 100644 --- a/src/conf/device_conf.c +++ b/src/conf/device_conf.c @@ -1,7 +1,7 @@ /* * device_conf.c: device XML handling * - * Copyright (C) 2006-2012 Red Hat, Inc. + * Copyright (C) 2006-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 @@ -138,9 +138,9 @@ virDevicePCIAddressEqual(virDevicePCIAddress *addr1, if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && addr1->slot == addr2->slot && - addr1->function == addr2->function) { + addr1->function == addr2->function) return true; - } + return false; } diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1b8efb1..9821b33 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2007,9 +2007,8 @@ virDomainVcpuPinDefArrayFree(virDomainVcpuPinDefPtr *def, if (!def) return; - for (i = 0; i < nvcpupin; i++) { + for (i = 0; i < nvcpupin; i++) virDomainVcpuPinDefFree(def[i]); - } VIR_FREE(def); } @@ -2688,9 +2687,8 @@ virDomainDeviceInfoCopy(virDomainDeviceInfoPtr dst, void virDomainDeviceInfoClear(virDomainDeviceInfoPtr info) { VIR_FREE(info->alias); - if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) { + if (info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB) VIR_FREE(info->addr.usb.port); - } memset(&info->addr, 0, sizeof(info->addr)); info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE; VIR_FREE(info->romfile); @@ -3268,9 +3266,8 @@ virDomainDeviceInfoFormat(virBufferPtr buf, virBufferAsprintf(buf, "<boot order='%d'/>\n", info->bootIndex); if (info->alias && - !(flags & VIR_DOMAIN_XML_INACTIVE)) { + !(flags & VIR_DOMAIN_XML_INACTIVE)) virBufferAsprintf(buf, "<alias name='%s'/>\n", info->alias); - } if (info->mastertype == VIR_DOMAIN_CONTROLLER_MASTER_USB) { virBufferAsprintf(buf, "<master startport='%d'/>\n", @@ -3762,23 +3759,22 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (cur->type == XML_ELEMENT_NODE) { if (alias == NULL && !(flags & VIR_DOMAIN_XML_INACTIVE) && - xmlStrEqual(cur->name, BAD_CAST "alias")) { + xmlStrEqual(cur->name, BAD_CAST "alias")) alias = cur; - } else if (address == NULL && - xmlStrEqual(cur->name, BAD_CAST "address")) { + else if (address == NULL && + xmlStrEqual(cur->name, BAD_CAST "address")) address = cur; - } else if (master == NULL && - xmlStrEqual(cur->name, BAD_CAST "master")) { + else if (master == NULL && + xmlStrEqual(cur->name, BAD_CAST "master")) master = cur; - } else if (boot == NULL && - (flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) && - xmlStrEqual(cur->name, BAD_CAST "boot")) { + else if (boot == NULL && + (flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) && + xmlStrEqual(cur->name, BAD_CAST "boot")) boot = cur; - } else if (rom == NULL && - (flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) && - xmlStrEqual(cur->name, BAD_CAST "rom")) { + else if (rom == NULL && + (flags & VIR_DOMAIN_XML_INTERNAL_ALLOW_ROM) && + xmlStrEqual(cur->name, BAD_CAST "rom")) rom = cur; - } } cur = cur->next; } @@ -4768,9 +4764,8 @@ virDomainDiskFindByBusAndDst(virDomainDefPtr def, for (i = 0; i < def->ndisks; i++) { if (def->disks[i]->bus == bus && - STREQ(def->disks[i]->dst, dst)) { + STREQ(def->disks[i]->dst, dst)) return def->disks[i]; - } } return NULL; @@ -4803,9 +4798,8 @@ virDomainDiskDefAssignAddress(virDomainXMLOptionPtr xmlopt, def->info.addr.drive.unit = idx % 15; /* Skip the SCSI controller at unit 7 */ - if (def->info.addr.drive.unit >= 7) { + if (def->info.addr.drive.unit >= 7) ++def->info.addr.drive.unit; - } } else { /* For a narrow SCSI bus we define the default mapping to be * 7 units per bus, 1 bus per controller, many controllers */ @@ -5080,9 +5074,8 @@ virSecurityLabelDefsParseXML(virDomainDefPtr def, error: ctxt->node = saved_node; - for (; i > 0; i--) { + for (; i > 0; i--) virSecurityLabelDefFree(def->seclabels[i - 1]); - } VIR_FREE(def->seclabels); def->nseclabels = 0; VIR_FREE(list); @@ -5186,9 +5179,8 @@ virSecurityDeviceLabelDefParseXML(virSecurityDeviceLabelDefPtr **seclabels_rtn, return 0; error: - for (i = 0; i < nseclabels; i++) { + for (i = 0; i < nseclabels; i++) virSecurityDeviceLabelDefFree(seclabels[i]); - } VIR_FREE(seclabels); VIR_FREE(list); return -1; @@ -6078,9 +6070,8 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; } } else { - if (def->bus == VIR_DOMAIN_DISK_BUS_USB) { + if (def->bus == VIR_DOMAIN_DISK_BUS_USB) def->removable = VIR_TRISTATE_SWITCH_ABSENT; - } } if (def->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY && @@ -6879,9 +6870,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (!(actual->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | - VIR_VPORT_XML_REQUIRE_TYPE))) { + VIR_VPORT_XML_REQUIRE_TYPE))) goto error; - } } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("<virtualport> element unsupported for type='%s'" @@ -6921,9 +6911,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, goto error; hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, - hostdev, flags) < 0) { + hostdev, flags) < 0) goto error; - } } else if (actual->type == VIR_DOMAIN_NET_TYPE_NETWORK) { char *class_id = virXPathString("string(./class/@id)", ctxt); if (class_id && @@ -7082,9 +7071,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, if (def->type == VIR_DOMAIN_NET_TYPE_NETWORK) { if (!(def->virtPortProfile = virNetDevVPortProfileParse(cur, - VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS))) { + VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS))) goto error; - } } else if (def->type == VIR_DOMAIN_NET_TYPE_BRIDGE || def->type == VIR_DOMAIN_NET_TYPE_DIRECT || def->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) { @@ -7092,9 +7080,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, = virNetDevVPortProfileParse(cur, VIR_VPORT_XML_GENERATE_MISSING_DEFAULTS| VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES| - VIR_VPORT_XML_REQUIRE_TYPE))) { + VIR_VPORT_XML_REQUIRE_TYPE))) goto error; - } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("<virtualport> element unsupported for" @@ -7161,9 +7148,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, def->type == VIR_DOMAIN_NET_TYPE_NETWORK && xmlStrEqual(cur->name, BAD_CAST "actual")) { if (virDomainActualNetDefParseXML(cur, ctxt, def, - &actual, flags) < 0) { + &actual, flags) < 0) goto error; - } } else if (xmlStrEqual(cur->name, BAD_CAST "bandwidth")) { if (!(def->bandwidth = virNetDevBandwidthParse(cur, def->type))) @@ -7417,9 +7403,8 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, goto error; hostdev->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS; if (virDomainHostdevDefParseXMLSubsys(node, ctxt, addrtype, - hostdev, flags) < 0) { + hostdev, flags) < 0) goto error; - } break; case VIR_DOMAIN_NET_TYPE_USER: @@ -8225,9 +8210,8 @@ virDomainChrDefParseXML(xmlXPathContextPtr ctxt, if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "target")) { seenTarget = true; - if (virDomainChrDefParseTargetXML(def, cur) < 0) { + if (virDomainChrDefParseTargetXML(def, cur) < 0) goto error; - } } } cur = cur->next; @@ -9001,9 +8985,8 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, if (virDomainGraphicsListenGetType(def, i) == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS) { found = virDomainGraphicsListenGetAddress(def, i); - if (STREQ_NULLABLE(found, listenAddr)) { + if (STREQ_NULLABLE(found, listenAddr)) matched = true; - } break; } } @@ -9139,16 +9122,14 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, def->data.rdp.port = 0; if ((replaceUser = virXMLPropString(node, "replaceUser")) != NULL) { - if (STREQ(replaceUser, "yes")) { + if (STREQ(replaceUser, "yes")) def->data.rdp.replaceUser = true; - } VIR_FREE(replaceUser); } if ((multiUser = virXMLPropString(node, "multiUser")) != NULL) { - if (STREQ(multiUser, "yes")) { + if (STREQ(multiUser, "yes")) def->data.rdp.multiUser = true; - } VIR_FREE(multiUser); } @@ -10348,9 +10329,8 @@ virDomainRedirdevDefParseXML(xmlNodePtr node, if (remaining < 0) goto error; - if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) { + if (def->source.chr.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) def->source.chr.data.spicevmc = VIR_DOMAIN_CHR_SPICEVMC_USBREDIR; - } if (virDomainDeviceInfoParseXML(node, bootHash, &def->info, flags | VIR_DOMAIN_XML_INTERNAL_ALLOW_BOOT) < 0) @@ -10544,9 +10524,8 @@ virDomainRedirFilterDefParseXML(xmlNodePtr node, goto error; ctxt->node = node; - if ((n = virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./usbdev", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->usbdevs, n) < 0) goto error; @@ -11303,9 +11282,8 @@ virDomainControllerFind(virDomainDefPtr def, for (i = 0; i < def->ncontrollers; i++) { if ((def->controllers[i]->type == type) && - (def->controllers[i]->idx == idx)) { + (def->controllers[i]->idx == idx)) return i; - } } return -1; @@ -11605,9 +11583,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, } /* analysis of the boot devices */ - if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./os/boot", ctxt, &nodes)) < 0) goto cleanup; - } if (n > 0 && deviceBoot) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -12049,9 +12026,8 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def) hostdev = def->hostdevs[i]; if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI && - (int)hostdev->info->addr.drive.controller > maxController) { + (int)hostdev->info->addr.drive.controller > maxController) maxController = hostdev->info->addr.drive.controller; - } } if (maxController == -1) @@ -13161,9 +13137,8 @@ virDomainDefParseXML(xmlDocPtr xml, def->os.init = virXPathString("string(./os/init[1])", ctxt); def->os.cmdline = virXPathString("string(./os/cmdline[1])", ctxt); - if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./os/initarg", ctxt, &nodes)) < 0) goto error; - } if (VIR_ALLOC_N(def->os.initargv, n+1) < 0) goto error; @@ -13303,9 +13278,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* analysis of the filesystems */ - if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/filesystem", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->fss, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13319,9 +13293,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* analysis of the network devices */ - if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/interface", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->nets, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13340,17 +13313,15 @@ virDomainDefParseXML(xmlDocPtr xml, * hostdev) must also be in the hostdevs array. */ if (virDomainNetGetActualType(net) == VIR_DOMAIN_NET_TYPE_HOSTDEV && - virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)) < 0) { + virDomainHostdevInsert(def, virDomainNetGetActualHostdev(net)) < 0) goto error; - } } VIR_FREE(nodes); /* analysis of the smartcard devices */ - if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/smartcard", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->smartcards, n) < 0) goto error; @@ -13366,9 +13337,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the character devices */ - if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/parallel", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->parallels, n) < 0) goto error; @@ -13442,9 +13412,8 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); - if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/channel", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->channels, n) < 0) goto error; @@ -13482,9 +13451,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the input devices */ - if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/input", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->inputs, n) < 0) goto error; @@ -13524,9 +13492,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* analysis of the graphics devices */ - if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/graphics", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->graphics, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13560,9 +13527,8 @@ virDomainDefParseXML(xmlDocPtr xml, } /* analysis of the sound devices */ - if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/sound", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->sounds, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13577,9 +13543,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* analysis of the video devices */ - if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/video", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->videos, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13634,9 +13599,8 @@ virDomainDefParseXML(xmlDocPtr xml, } /* analysis of the host devices */ - if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/hostdev", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_REALLOC_N(def->hostdevs, def->nhostdevs + n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13665,9 +13629,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the watchdog devices */ def->watchdog = NULL; - if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/watchdog", ctxt, &nodes)) < 0) goto error; - } if (n > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("only a single watchdog device is supported")); @@ -13685,9 +13648,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the memballoon devices */ def->memballoon = NULL; - if ((n = virXPathNodeSet("./devices/memballoon", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/memballoon", ctxt, &nodes)) < 0) goto error; - } if (n > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("only a single memory balloon device is supported")); @@ -13735,9 +13697,8 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); - if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/nvram", ctxt, &nodes)) < 0) goto error; - } if (n > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -13753,9 +13714,8 @@ virDomainDefParseXML(xmlDocPtr xml, } /* analysis of the hub devices */ - if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/hub", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->hubs, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13776,9 +13736,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* analysis of the redirected devices */ - if ((n = virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/redirdev", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->redirdevs, n) < 0) goto error; for (i = 0; i < n; i++) { @@ -13801,9 +13760,8 @@ virDomainDefParseXML(xmlDocPtr xml, VIR_FREE(nodes); /* analysis of the redirection filter rules */ - if ((n = virXPathNodeSet("./devices/redirfilter", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/redirfilter", ctxt, &nodes)) < 0) goto error; - } if (n > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("only one set of redirection filter rule is supported")); @@ -13822,9 +13780,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* analysis of the panic devices */ def->panic = NULL; - if ((n = virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/panic", ctxt, &nodes)) < 0) goto error; - } if (n > 1) { virReportError(VIR_ERR_XML_ERROR, "%s", _("only a single panic device is supported")); @@ -13841,9 +13798,8 @@ virDomainDefParseXML(xmlDocPtr xml, } /* analysis of the shmem devices */ - if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./devices/shmem", ctxt, &nodes)) < 0) goto error; - } if (n && VIR_ALLOC_N(def->shmems, n) < 0) goto error; @@ -14017,9 +13973,8 @@ virDomainObjParseXML(xmlDocPtr xml, } obj->pid = (pid_t)val; - if ((n = virXPathNodeSet("./taint", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./taint", ctxt, &nodes)) < 0) goto error; - } for (i = 0; i < n; i++) { char *str = virXMLPropString(nodes[i], "flag"); if (str) { @@ -15797,9 +15752,8 @@ virDomainEmulatorPinAdd(virDomainDefPtr def, int virDomainEmulatorPinDel(virDomainDefPtr def) { - if (!def->cputune.emulatorpin) { + if (!def->cputune.emulatorpin) return 0; - } virDomainVcpuPinDefFree(def->cputune.emulatorpin); def->cputune.emulatorpin = NULL; @@ -16456,9 +16410,8 @@ virDomainControllerDefFormat(virBufferPtr buf, "<controller type='%s' index='%u'", type, def->idx); - if (model) { + if (model) virBufferEscapeString(buf, " model='%s'", model); - } switch (def->type) { case VIR_DOMAIN_CONTROLLER_TYPE_VIRTIO_SERIAL: @@ -16810,9 +16763,8 @@ virDomainActualNetDefContentsFormat(virBufferPtr buf, case VIR_DOMAIN_NET_TYPE_HOSTDEV: if (virDomainHostdevDefFormatSubsys(buf, virDomainNetGetActualHostdev(def), - flags, true) < 0) { + flags, true) < 0) return -1; - } break; case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -17136,9 +17088,8 @@ virDomainNetDefFormat(virBufferPtr buf, case VIR_DOMAIN_NET_TYPE_HOSTDEV: if (virDomainHostdevDefFormatSubsys(buf, &def->data.hostdev.def, - flags, true) < 0) { + flags, true) < 0) return -1; - } break; case VIR_DOMAIN_NET_TYPE_USER: @@ -17424,9 +17375,8 @@ virDomainChrDefFormat(virBufferPtr buf, } case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO: { - if (def->target.name) { + if (def->target.name) virBufferEscapeString(buf, " name='%s'", def->target.name); - } break; } @@ -17982,9 +17932,8 @@ virDomainTimerDefFormat(virBufferPtr buf, } if (def->name == VIR_DOMAIN_TIMER_NAME_TSC) { - if (def->frequency > 0) { + if (def->frequency > 0) virBufferAsprintf(buf, " frequency='%lu'", def->frequency); - } if (def->mode != -1) { const char *mode @@ -18006,15 +17955,12 @@ virDomainTimerDefFormat(virBufferPtr buf, virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); virBufferAddLit(buf, "<catchup"); - if (def->catchup.threshold > 0) { + if (def->catchup.threshold > 0) virBufferAsprintf(buf, " threshold='%lu'", def->catchup.threshold); - } - if (def->catchup.slew > 0) { + if (def->catchup.slew > 0) virBufferAsprintf(buf, " slew='%lu'", def->catchup.slew); - } - if (def->catchup.limit > 0) { + if (def->catchup.limit > 0) virBufferAsprintf(buf, " limit='%lu'", def->catchup.limit); - } virBufferAddLit(buf, "/>\n"); virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</timer>\n"); @@ -18075,9 +18021,8 @@ virDomainGraphicsListenDefFormat(virBufferPtr buf, } if (def->network && - (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) { + (def->type == VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK)) virBufferEscapeString(buf, " network='%s'", def->network); - } if (flags & VIR_DOMAIN_XML_INTERNAL_STATUS) virBufferAsprintf(buf, " fromConfig='%d'", def->fromConfig); @@ -19363,9 +19308,8 @@ virDomainDefFormatInternal(virDomainDefPtr def, * and will have already been formatted there. */ if (def->hostdevs[n]->parent.type == VIR_DOMAIN_DEVICE_NONE && - virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) { + virDomainHostdevDefFormat(buf, def->hostdevs[n], flags) < 0) goto error; - } } for (n = 0; n < def->nredirdevs; n++) @@ -20404,9 +20348,8 @@ virDomainNetGetActualBridgeName(virDomainNetDefPtr iface) return iface->data.bridge.brname; if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && iface->data.network.actual && - iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE) { + iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_BRIDGE) return iface->data.network.actual->data.bridge.brname; - } return NULL; } @@ -20417,9 +20360,8 @@ virDomainNetGetActualDirectDev(virDomainNetDefPtr iface) return iface->data.direct.linkdev; if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && iface->data.network.actual && - iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT) { + iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT) return iface->data.network.actual->data.direct.linkdev; - } return NULL; } @@ -20430,9 +20372,8 @@ virDomainNetGetActualDirectMode(virDomainNetDefPtr iface) return iface->data.direct.mode; if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && iface->data.network.actual && - iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT) { + iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_DIRECT) return iface->data.network.actual->data.direct.mode; - } return 0; } @@ -20443,9 +20384,8 @@ virDomainNetGetActualHostdev(virDomainNetDefPtr iface) return &iface->data.hostdev.def; if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && iface->data.network.actual && - iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) { + iface->data.network.actual->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) return &iface->data.network.actual->data.hostdev.def; - } return NULL; } @@ -20480,9 +20420,8 @@ virDomainNetGetActualBandwidth(virDomainNetDefPtr iface) * its bandwidth rather than the NetDef's bandwidth. */ if (iface->type == VIR_DOMAIN_NET_TYPE_NETWORK && - iface->data.network.actual) { + iface->data.network.actual) return iface->data.network.actual->bandwidth; - } return iface->bandwidth; } diff --git a/src/conf/interface_conf.c b/src/conf/interface_conf.c index 10c7c09..c2eb945 100644 --- a/src/conf/interface_conf.c +++ b/src/conf/interface_conf.c @@ -60,9 +60,8 @@ void virInterfaceProtocolDefFree(virInterfaceProtocolDefPtr def) if (def == NULL) return; - for (i = 0; i < def->nips; i++) { + for (i = 0; i < def->nips; i++) virInterfaceIpDefFree(def->ips[i]); - } VIR_FREE(def->ips); VIR_FREE(def->family); VIR_FREE(def->gateway); @@ -106,9 +105,8 @@ void virInterfaceDefFree(virInterfaceDefPtr def) } /* free all protos */ - for (pp = 0; pp < def->nprotos; pp++) { + for (pp = 0; pp < def->nprotos; pp++) virInterfaceProtocolDefFree(def->protos[pp]); - } VIR_FREE(def->protos); VIR_FREE(def); } @@ -1081,9 +1079,8 @@ virInterfaceDefDevFormat(virBufferPtr buf, const virInterfaceDef *def, virInterfaceProtocolDefFormat(buf, def); } - if (def->type != VIR_INTERFACE_TYPE_BRIDGE) { + if (def->type != VIR_INTERFACE_TYPE_BRIDGE) virInterfaceLinkFormat(buf, &def->lnk); - } switch (def->type) { case VIR_INTERFACE_TYPE_ETHERNET: if (def->mac) diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c index 8da0838..d820b75 100644 --- a/src/conf/netdev_vport_profile_conf.c +++ b/src/conf/netdev_vport_profile_conf.c @@ -176,9 +176,8 @@ virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags) /* check for required/unsupported attributes */ if ((flags & VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES) && - (virNetDevVPortProfileCheckComplete(virtPort, false) < 0)) { + (virNetDevVPortProfileCheckComplete(virtPort, false) < 0)) goto error; - } if (virNetDevVPortProfileCheckNoExtras(virtPort) < 0) goto error; @@ -237,14 +236,12 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr virtPort, if (virtPort->managerID_specified && (type == VIR_NETDEV_VPORT_PROFILE_8021QBG || - type == VIR_NETDEV_VPORT_PROFILE_NONE)) { + type == VIR_NETDEV_VPORT_PROFILE_NONE)) virBufferAsprintf(buf, " managerid='%d'", virtPort->managerID); - } if (virtPort->typeID_specified && (type == VIR_NETDEV_VPORT_PROFILE_8021QBG || - type == VIR_NETDEV_VPORT_PROFILE_NONE)) { + type == VIR_NETDEV_VPORT_PROFILE_NONE)) virBufferAsprintf(buf, " typeid='%d'", virtPort->typeID); - } if (virtPort->typeIDVersion_specified && (type == VIR_NETDEV_VPORT_PROFILE_8021QBG || type == VIR_NETDEV_VPORT_PROFILE_NONE)) { @@ -270,9 +267,8 @@ virNetDevVPortProfileFormat(virNetDevVPortProfilePtr virtPort, if (virtPort->profileID[0] && (type == VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH || type == VIR_NETDEV_VPORT_PROFILE_8021QBH || - type == VIR_NETDEV_VPORT_PROFILE_NONE)) { + type == VIR_NETDEV_VPORT_PROFILE_NONE)) virBufferAsprintf(buf, " profileid='%s'", virtPort->profileID); - } virBufferAddLit(buf, "/>\n"); virBufferAdjustIndent(buf, -2); diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index 3bad07d..0a2c230 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -218,14 +218,12 @@ virNetworkForwardDefClear(virNetworkForwardDefPtr def) { size_t i; - for (i = 0; i < def->npfs && def->pfs; i++) { + for (i = 0; i < def->npfs && def->pfs; i++) virNetworkForwardPfDefClear(&def->pfs[i]); - } VIR_FREE(def->pfs); - for (i = 0; i < def->nifs && def->ifs; i++) { + for (i = 0; i < def->nifs && def->ifs; i++) virNetworkForwardIfDefClear(&def->ifs[i]); - } VIR_FREE(def->ifs); def->nifs = def->npfs = 0; } @@ -244,19 +242,16 @@ virNetworkDefFree(virNetworkDefPtr def) virNetworkForwardDefClear(&def->forward); - for (i = 0; i < def->nips && def->ips; i++) { + for (i = 0; i < def->nips && def->ips; i++) virNetworkIpDefClear(&def->ips[i]); - } VIR_FREE(def->ips); - for (i = 0; i < def->nroutes && def->routes; i++) { + for (i = 0; i < def->nroutes && def->routes; i++) virNetworkRouteDefClear(&def->routes[i]); - } VIR_FREE(def->routes); - for (i = 0; i < def->nPortGroups && def->portGroups; i++) { + for (i = 0; i < def->nPortGroups && def->portGroups; i++) virPortGroupDefClear(&def->portGroups[i]); - } VIR_FREE(def->portGroups); virNetworkDNSDefClear(&def->dns); @@ -596,16 +591,14 @@ virNetworkDefGetIpByIndex(const virNetworkDef *def, if (!def->ips || n >= def->nips) return NULL; - if (family == AF_UNSPEC) { + if (family == AF_UNSPEC) return &def->ips[n]; - } /* find the nth ip of type "family" */ for (i = 0; i < def->nips; i++) { if (VIR_SOCKET_ADDR_IS_FAMILY(&def->ips[i].address, family) - && (n-- <= 0)) { + && (n-- <= 0)) return &def->ips[i]; - } } /* failed to find enough of the right family */ return NULL; @@ -816,9 +809,8 @@ virNetworkDHCPDefParseXML(const char *networkName, if (VIR_REALLOC_N(def->ranges, def->nranges + 1) < 0) return -1; if (virSocketAddrRangeParseXML(networkName, cur, - &def->ranges[def->nranges]) < 0) { + &def->ranges[def->nranges]) < 0) return -1; - } def->nranges++; } else if (cur->type == XML_ELEMENT_NODE && @@ -828,9 +820,8 @@ virNetworkDHCPDefParseXML(const char *networkName, return -1; if (virNetworkDHCPHostDefParseXML(networkName, def, cur, &def->hosts[def->nhosts], - false) < 0) { + false) < 0) return -1; - } def->nhosts++; } else if (VIR_SOCKET_ADDR_IS_FAMILY(&def->address, AF_INET) && @@ -1164,9 +1155,8 @@ virNetworkDNSDefParseXML(const char *networkName, for (i = 0; i < nhosts; i++) { if (virNetworkDNSHostDefParseXML(networkName, hostNodes[i], - &def->hosts[def->nhosts], false) < 0) { + &def->hosts[def->nhosts], false) < 0) goto cleanup; - } def->nhosts++; } } @@ -1184,9 +1174,8 @@ virNetworkDNSDefParseXML(const char *networkName, for (i = 0; i < nsrvs; i++) { if (virNetworkDNSSrvDefParseXML(networkName, srvNodes[i], ctxt, - &def->srvs[def->nsrvs], false) < 0) { + &def->srvs[def->nsrvs], false) < 0) goto cleanup; - } def->nsrvs++; } } @@ -1204,9 +1193,8 @@ virNetworkDNSDefParseXML(const char *networkName, for (i = 0; i < ntxts; i++) { if (virNetworkDNSTxtDefParseXML(networkName, txtNodes[i], - &def->txts[def->ntxts], false) < 0) { + &def->txts[def->ntxts], false) < 0) goto cleanup; - } def->ntxts++; } } @@ -1363,9 +1351,8 @@ virNetworkIPDefParseXML(const char *networkName, result = 0; cleanup: - if (result < 0) { + if (result < 0) virNetworkIpDefClear(def); - } VIR_FREE(address); VIR_FREE(netmask); @@ -1589,9 +1576,8 @@ virNetworkRouteDefParseXML(const char *networkName, result = 0; cleanup: - if (result < 0) { + if (result < 0) virNetworkRouteDefClear(def); - } VIR_FREE(address); VIR_FREE(netmask); VIR_FREE(gateway); @@ -1647,15 +1633,13 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, virtPortNode = virXPathNode("./virtualport", ctxt); if (virtPortNode && - (!(def->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, 0)))) { + (!(def->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, 0)))) goto cleanup; - } bandwidth_node = virXPathNode("./bandwidth", ctxt); if (bandwidth_node && - !(def->bandwidth = virNetDevBandwidthParse(bandwidth_node, -1))) { + !(def->bandwidth = virNetDevBandwidthParse(bandwidth_node, -1))) goto cleanup; - } vlanNode = virXPathNode("./vlan", ctxt); if (vlanNode && virNetDevVlanParse(vlanNode, ctxt, &def->vlan) < 0) @@ -1663,9 +1647,8 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, result = 0; cleanup: - if (result < 0) { + if (result < 0) virPortGroupDefClear(def); - } VIR_FREE(isDefault); VIR_FREE(trustGuestRxFilters); @@ -1814,9 +1797,8 @@ virNetworkForwardDefParseXML(const char *networkName, forwardManaged = virXPathString("string(./@managed)", ctxt); if (forwardManaged != NULL && - STRCASEEQ(forwardManaged, "yes")) { + STRCASEEQ(forwardManaged, "yes")) def->managed = true; - } forwardDriverName = virXPathString("string(./driver/@name)", ctxt); if (forwardDriverName) { @@ -1959,9 +1941,8 @@ virNetworkForwardDefParseXML(const char *networkName, switch (def->ifs[i].type) { case VIR_NETWORK_FORWARD_HOSTDEV_DEVICE_PCI: if (virDevicePCIAddressParseXML(forwardAddrNodes[i], - &def->ifs[i].device.pci) < 0) { + &def->ifs[i].device.pci) < 0) goto cleanup; - } break; /* Add USB case here if we ever find a reason to support it */ @@ -2137,16 +2118,14 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) dnsNode = virXPathNode("./dns", ctxt); if (dnsNode != NULL && - virNetworkDNSDefParseXML(def->name, dnsNode, ctxt, &def->dns) < 0) { + virNetworkDNSDefParseXML(def->name, dnsNode, ctxt, &def->dns) < 0) goto error; - } virtPortNode = virXPathNode("./virtualport", ctxt); if (virtPortNode && (!(def->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, - VIR_VPORT_XML_REQUIRE_TYPE)))) { + VIR_VPORT_XML_REQUIRE_TYPE)))) goto error; - } nPortGroups = virXPathNodeSet("./portgroup", ctxt, &portGroupNodes); if (nPortGroups < 0) @@ -2228,9 +2207,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) for (j = 0; j < nIps; j++) { virNetworkIpDefPtr def2 = &def->ips[j]; if (VIR_SOCKET_ADDR_FAMILY(&gwdef->gateway) - != VIR_SOCKET_ADDR_FAMILY(&def2->address)) { + != VIR_SOCKET_ADDR_FAMILY(&def2->address)) continue; - } int prefix = virNetworkIpDefPrefix(def2); virSocketAddrMaskByPrefix(&def2->address, prefix, &testAddr); virSocketAddrMaskByPrefix(&gwdef->gateway, prefix, &testGw); @@ -2255,9 +2233,8 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt) forwardNode = virXPathNode("./forward", ctxt); if (forwardNode && - virNetworkForwardDefParseXML(def->name, forwardNode, ctxt, &def->forward) < 0) { + virNetworkForwardDefParseXML(def->name, forwardNode, ctxt, &def->forward) < 0) goto error; - } /* Validate some items in the main NetworkDef that need to align * with the chosen forward mode. @@ -2483,9 +2460,8 @@ virNetworkIpDefFormat(virBufferPtr buf, virBufferAddLit(buf, "<ip"); - if (def->family) { + if (def->family) virBufferAsprintf(buf, " family='%s'", def->family); - } if (VIR_SOCKET_ADDR_VALID(&def->address)) { char *addr = virSocketAddrFormat(&def->address); if (!addr) @@ -2500,9 +2476,8 @@ virNetworkIpDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " netmask='%s'", addr); VIR_FREE(addr); } - if (def->prefix > 0) { + if (def->prefix > 0) virBufferAsprintf(buf, " prefix='%u'", def->prefix); - } virBufferAddLit(buf, ">\n"); virBufferAdjustIndent(buf, 2); @@ -2580,9 +2555,8 @@ virNetworkRouteDefFormat(virBufferPtr buf, virBufferAddLit(buf, "<route"); - if (def->family) { + if (def->family) virBufferAsprintf(buf, " family='%s'", def->family); - } if (VIR_SOCKET_ADDR_VALID(&def->address)) { char *addr = virSocketAddrFormat(&def->address); @@ -2599,9 +2573,8 @@ virNetworkRouteDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " netmask='%s'", addr); VIR_FREE(addr); } - if (def->has_prefix) { + if (def->has_prefix) virBufferAsprintf(buf, " prefix='%u'", def->prefix); - } if (VIR_SOCKET_ADDR_VALID(&def->gateway)) { char *addr = virSocketAddrFormat(&def->gateway); if (!addr) @@ -2609,9 +2582,8 @@ virNetworkRouteDefFormat(virBufferPtr buf, virBufferAsprintf(buf, " gateway='%s'", addr); VIR_FREE(addr); } - if (def->has_metric && def->metric > 0) { + if (def->has_metric && def->metric > 0) virBufferAsprintf(buf, " metric='%u'", def->metric); - } virBufferAddLit(buf, "/>\n"); result = 0; @@ -2624,9 +2596,8 @@ virPortGroupDefFormat(virBufferPtr buf, const virPortGroupDef *def) { virBufferAsprintf(buf, "<portgroup name='%s'", def->name); - if (def->isDefault) { + if (def->isDefault) virBufferAddLit(buf, " default='yes'"); - } if (def->trustGuestRxFilters) virBufferAsprintf(buf, " trustGuestRxFilters='%s'", virTristateBoolTypeToString(def->trustGuestRxFilters)); @@ -2703,9 +2674,8 @@ virNetworkDefFormatBuf(virBufferPtr buf, bool shortforward; virBufferAddLit(buf, "<network"); - if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0)) { + if (!(flags & VIR_NETWORK_XML_INACTIVE) && (def->connections > 0)) virBufferAsprintf(buf, " connections='%d'", def->connections); - } if (def->ipv6nogw) virBufferAddLit(buf, " ipv6='yes'"); if (def->trustGuestRxFilters) @@ -3326,9 +3296,8 @@ char *virNetworkAllocateBridge(virNetworkObjListPtr nets, do { if (virAsprintf(&newname, template, id) < 0) return NULL; - if (!virNetworkBridgeInUse(nets, newname, NULL)) { + if (!virNetworkBridgeInUse(nets, newname, NULL)) return newname; - } VIR_FREE(newname); id++; @@ -3525,9 +3494,8 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, (VIR_SOCKET_ADDR_VALID(&host.ip) && virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip)) || (host.name && - STREQ_NULLABLE(host.name, ipdef->hosts[i].name))) { + STREQ_NULLABLE(host.name, ipdef->hosts[i].name))) break; - } } if (i == ipdef->nhosts) { @@ -3589,9 +3557,8 @@ virNetworkDefUpdateIPDHCPHost(virNetworkDefPtr def, (!host.name || STREQ_NULLABLE(host.name, ipdef->hosts[i].name)) && (!VIR_SOCKET_ADDR_VALID(&host.ip) || - virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip))) { + virSocketAddrEqual(&host.ip, &ipdef->hosts[i].ip))) break; - } } if (i == ipdef->nhosts) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -3652,9 +3619,8 @@ virNetworkDefUpdateIPDHCPRange(virNetworkDefPtr def, /* check if an entry with same name/address/ip already exists */ for (i = 0; i < ipdef->nranges; i++) { if (virSocketAddrEqual(&range.start, &ipdef->ranges[i].start) && - virSocketAddrEqual(&range.end, &ipdef->ranges[i].end)) { + virSocketAddrEqual(&range.end, &ipdef->ranges[i].end)) break; - } } if ((command == VIR_NETWORK_UPDATE_COMMAND_ADD_FIRST) || @@ -4278,9 +4244,8 @@ virNetworkObjUpdate(virNetworkObjPtr network, if (!(livedef = virNetworkDefCopy(network->def, 0))) goto cleanup; if (virNetworkDefUpdateSection(livedef, command, section, - parentIndex, xml, flags) < 0) { + parentIndex, xml, flags) < 0) goto cleanup; - } /* run a final format/parse cycle to make sure we didn't * add anything illegal to the def */ @@ -4294,17 +4259,14 @@ virNetworkObjUpdate(virNetworkObjPtr network, /* work on a copy of the def */ if (!(configdef = virNetworkDefCopy(virNetworkObjGetPersistentDef(network), - VIR_NETWORK_XML_INACTIVE))) { + VIR_NETWORK_XML_INACTIVE))) goto cleanup; - } if (virNetworkDefUpdateSection(configdef, command, section, - parentIndex, xml, flags) < 0) { + parentIndex, xml, flags) < 0) goto cleanup; - } if (!(checkdef = virNetworkDefCopy(configdef, - VIR_NETWORK_XML_INACTIVE))) { + VIR_NETWORK_XML_INACTIVE))) goto cleanup; - } virNetworkDefFree(checkdef); } diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 2a947df..9a38c0c 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -93,9 +93,8 @@ virNodeDeviceFindBySysfsPath(virNodeDeviceObjListPtr devs, for (i = 0; i < devs->count; i++) { virNodeDeviceObjLock(devs->objs[i]); if ((devs->objs[i]->def->sysfs_path != NULL) && - (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) { + (STREQ(devs->objs[i]->def->sysfs_path, sysfs_path))) return devs->objs[i]; - } virNodeDeviceObjUnlock(devs->objs[i]); } @@ -669,9 +668,8 @@ virNodeDevCapStorageParseXML(xmlXPathContextPtr ctxt, data->storage.vendor = virXPathString("string(./vendor[1])", ctxt); data->storage.serial = virXPathString("string(./serial[1])", ctxt); - if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) goto out; - } for (i = 0; i < n; i++) { char *type = virXMLPropString(nodes[i], "type"); @@ -829,21 +827,18 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, if (virNodeDevCapsDefParseULong("number(./host[1])", ctxt, &data->scsi_host.host, def, _("no SCSI host ID supplied for '%s'"), - _("invalid SCSI host ID supplied for '%s'")) < 0) { + _("invalid SCSI host ID supplied for '%s'")) < 0) goto out; - } /* Optional unique_id value */ data->scsi_host.unique_id = -1; if (virNodeDevCapsDefParseIntOptional("number(./unique_id[1])", ctxt, &data->scsi_host.unique_id, def, - _("invalid unique_id supplied for '%s'")) < 0) { + _("invalid unique_id supplied for '%s'")) < 0) goto out; - } } - if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) goto out; - } for (i = 0; i < n; i++) { type = virXMLPropString(nodes[i], "type"); @@ -1265,9 +1260,8 @@ virNodeDevCapPCIDevParseXML(xmlXPathContextPtr ctxt, if ((iommuGroupNode = virXPathNode("./iommuGroup[1]", ctxt))) { if (virNodeDevCapPCIDevIommuGroupParseXML(ctxt, iommuGroupNode, - data) < 0) { + data) < 0) goto out; - } } /* The default value is -1 since zero is valid NUMA node number */ @@ -1453,9 +1447,8 @@ virNodeDeviceDefParseXML(xmlXPathContextPtr ctxt, /* Parse device capabilities */ nodes = NULL; - if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) { + if ((n = virXPathNodeSet("./capability", ctxt, &nodes)) < 0) goto error; - } if (n == 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1656,13 +1649,11 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) VIR_FREE(data->pci_dev.product_name); VIR_FREE(data->pci_dev.vendor_name); VIR_FREE(data->pci_dev.physical_function); - for (i = 0; i < data->pci_dev.num_virtual_functions; i++) { + for (i = 0; i < data->pci_dev.num_virtual_functions; i++) VIR_FREE(data->pci_dev.virtual_functions[i]); - } VIR_FREE(data->pci_dev.virtual_functions); - for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) { + for (i = 0; i < data->pci_dev.nIommuGroupDevices; i++) VIR_FREE(data->pci_dev.iommuGroupDevices[i]); - } VIR_FREE(data->pci_dev.iommuGroupDevices); virPCIEDeviceInfoFree(data->pci_dev.pci_express); break; diff --git a/src/conf/nwfilter_conf.c b/src/conf/nwfilter_conf.c index 4b22709..d3cf6ee 100644 --- a/src/conf/nwfilter_conf.c +++ b/src/conf/nwfilter_conf.c @@ -535,9 +535,8 @@ checkVlanVlanID(enum attrDatatype datatype, union data *value, int32_t res; res = value->ui; - if (res < 0 || res > 4095) { + if (res < 0 || res > 4095) res = -1; - } if (res != -1) { nwf->p.vlanHdrFilter.dataVlanID.u.u16 = res; @@ -1928,18 +1927,16 @@ virNWFilterRuleDetailsParse(xmlNodePtr node, case DATATYPE_MACADDR: if (virMacAddrParse(prop, - &item->u.macaddr) < 0) { + &item->u.macaddr) < 0) rc = -1; - } found = true; break; case DATATYPE_MACMASK: validator = checkMACMask; if (virMacAddrParse(prop, - &item->u.macaddr) < 0) { + &item->u.macaddr) < 0) rc = -1; - } data.v = &item->u.macaddr; found = true; break; @@ -2453,9 +2450,8 @@ virNWFilterRuleParse(xmlNodePtr node) if (virNWFilterRuleDetailsParse(cur, ret, - virAttr[i].att) < 0) { + virAttr[i].att) < 0) goto err_exit; - } if (virNWFilterRuleValidate(ret) < 0) goto err_exit; break; @@ -2899,9 +2895,8 @@ static virNWFilterCallbackDriverPtr callbackDrvArray[MAX_CALLBACK_DRIVER]; void virNWFilterRegisterCallbackDriver(virNWFilterCallbackDriverPtr cbd) { - if (nCallbackDriver < MAX_CALLBACK_DRIVER) { + if (nCallbackDriver < MAX_CALLBACK_DRIVER) callbackDrvArray[nCallbackDriver++] = cbd; - } } void @@ -3141,9 +3136,8 @@ virNWFilterObjLoad(virNWFilterObjListPtr nwfilters, virNWFilterDefPtr def; virNWFilterObjPtr nwfilter; - if (!(def = virNWFilterDefParseFile(path))) { + if (!(def = virNWFilterDefParseFile(path))) return NULL; - } if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { virReportError(VIR_ERR_XML_ERROR, @@ -3177,9 +3171,8 @@ virNWFilterLoadAllConfigs(virNWFilterObjListPtr nwfilters, int ret = -1; if (!(dir = opendir(configDir))) { - if (errno == ENOENT) { + if (errno == ENOENT) return 0; - } virReportSystemError(errno, _("Failed to open dir '%s'"), configDir); return -1; @@ -3228,9 +3221,8 @@ virNWFilterObjSaveDef(virNWFilterDriverStatePtr driver, } if (!(nwfilter->configFile = virFileBuildPath(driver->configDir, - def->name, ".xml"))) { + def->name, ".xml"))) return -1; - } } if (!(xml = virNWFilterDefFormat(def))) { diff --git a/src/conf/object_event.c b/src/conf/object_event.c index beef3e1..06eedff 100644 --- a/src/conf/object_event.c +++ b/src/conf/object_event.c @@ -388,9 +388,8 @@ virObjectEventCallbackListAddID(virConnectPtr conn, callback, opaque, legacy, callbackID, serverFilter); /* Check incoming */ - if (!cbList) { + if (!cbList) return -1; - } /* If there is no additional filtering, then check if we already * have this callback on our list. */ @@ -460,9 +459,8 @@ virObjectEventQueueClear(virObjectEventQueuePtr queue) if (!queue) return; - for (i = 0; i < queue->count; i++) { + for (i = 0; i < queue->count; i++) virObjectUnref(queue->events[i]); - } VIR_FREE(queue->events); queue->count = 0; } diff --git a/src/conf/storage_conf.c b/src/conf/storage_conf.c index afd6cd4..16fe244 100644 --- a/src/conf/storage_conf.c +++ b/src/conf/storage_conf.c @@ -333,9 +333,8 @@ virStorageVolDefFree(virStorageVolDefPtr def) VIR_FREE(def->name); VIR_FREE(def->key); - for (i = 0; i < def->source.nextent; i++) { + for (i = 0; i < def->source.nextent; i++) VIR_FREE(def->source.extents[i].path); - } VIR_FREE(def->source.extents); virStorageSourceClear(&def->target); @@ -370,9 +369,8 @@ virStoragePoolSourceClear(virStoragePoolSourcePtr source) if (!source) return; - for (i = 0; i < source->nhost; i++) { + for (i = 0; i < source->nhost; i++) VIR_FREE(source->hosts[i].name); - } VIR_FREE(source->hosts); for (i = 0; i < source->ndevice; i++) @@ -480,9 +478,8 @@ virStoragePoolDefParseSource(xmlXPathContextPtr ctxt, relnode = ctxt->node; ctxt->node = node; - if ((options = virStoragePoolOptionsForPoolType(pool_type)) == NULL) { + if ((options = virStoragePoolOptionsForPoolType(pool_type)) == NULL) goto cleanup; - } source->name = virXPathString("string(./name)", ctxt); if (pool_type == VIR_STORAGE_POOL_RBD && source->name == NULL) { @@ -819,9 +816,8 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) goto error; } - if ((options = virStoragePoolOptionsForPoolType(ret->type)) == NULL) { + if ((options = virStoragePoolOptionsForPoolType(ret->type)) == NULL) goto error; - } source_node = virXPathNode("./source", ctxt); if (source_node) { @@ -931,13 +927,11 @@ virStoragePoolDefParseXML(xmlXPathContextPtr ctxt) * path and permissions */ if (!(options->flags & VIR_STORAGE_POOL_SOURCE_NETWORK)) { if (ret->type == VIR_STORAGE_POOL_LOGICAL) { - if (virAsprintf(&target_path, "/dev/%s", ret->source.name) < 0) { + if (virAsprintf(&target_path, "/dev/%s", ret->source.name) < 0) goto error; - } } else if (ret->type == VIR_STORAGE_POOL_ZFS) { - if (virAsprintf(&target_path, "/dev/zvol/%s", ret->source.name) < 0) { + if (virAsprintf(&target_path, "/dev/zvol/%s", ret->source.name) < 0) goto error; - } } else { target_path = virXPathString("string(./target/path)", ctxt); if (!target_path) { @@ -1797,9 +1791,8 @@ virStoragePoolObjLoad(virStoragePoolObjListPtr pools, virStoragePoolDefPtr def; virStoragePoolObjPtr pool; - if (!(def = virStoragePoolDefParseFile(path))) { + if (!(def = virStoragePoolDefParseFile(path))) return NULL; - } if (!virFileMatchesNameSuffix(file, def->name, ".xml")) { virReportError(VIR_ERR_XML_ERROR, @@ -1901,9 +1894,8 @@ virStoragePoolObjSaveDef(virStorageDriverStatePtr driver, } if (!(pool->configFile = virFileBuildPath(driver->configDir, - def->name, ".xml"))) { + def->name, ".xml"))) return -1; - } if (!(pool->autostartLink = virFileBuildPath(driver->autostartDir, def->name, ".xml"))) { @@ -1982,9 +1974,8 @@ virStoragePoolSourceListFormat(virStoragePoolSourceListPtr def) virBufferAddLit(&buf, "<sources>\n"); virBufferAdjustIndent(&buf, 2); - for (i = 0; i < def->nsources; i++) { + for (i = 0; i < def->nsources; i++) virStoragePoolSourceFormat(&buf, options, &def->sources[i]); - } virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "</sources>\n"); @@ -2110,9 +2101,8 @@ matchSCSIAdapterParent(virStoragePoolObjPtr pool, pooladdr->bus == defaddr->bus && pooladdr->slot == defaddr->slot && pooladdr->function == defaddr->function && - pool_unique_id == def_unique_id) { + pool_unique_id == def_unique_id) return true; - } return false; } -- 2.1.3

On 11/06/2014 05:38 PM, Martin Kletzander wrote:
As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions).
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> ---
+++ b/src/conf/capabilities.c @@ -219,9 +219,8 @@ virCapabilitiesDispose(void *object) VIR_FREE(caps->host.migrateTrans[i]); VIR_FREE(caps->host.migrateTrans);
- for (i = 0; i < caps->host.nsecModels; i++) { + for (i = 0; i < caps->host.nsecModels; i++) virCapabilitiesClearSecModel(&caps->host.secModels[i]); - }
Conversions like this make sense...
@@ -138,9 +138,9 @@ virDevicePCIAddressEqual(virDevicePCIAddress *addr1, if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && addr1->slot == addr2->slot && - addr1->function == addr2->function) { + addr1->function == addr2->function) return true; - }
Conversions like this are a little harder to read (that is, any time the 'if' condition extends over multiple lines, but there is exactly four space indentation of the condition, it's visually hard to see where the multi-line condition ends and the loop body begins). The opening { is hard to see either way, but seeing the closing } is my visual clue that "yes, the last line of this blob of code is not part of the 'if' but the one-line body". I'm not opposed to your removal of {}, but wonder if we should rethink our style to recommend keeping the {} if the 'if' expression is multiline. Besides, it is easier to write a syntax check that checks for one-line 'if' expressions (that's how I wrote my checks for mis-matched if{}else; and if;else{}) than it is for multi-line if expressions. So distinguishing between the two types may make it easier to write a syntax check and enforce a consistent style.
@@ -3762,23 +3759,22 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (cur->type == XML_ELEMENT_NODE) { if (alias == NULL && !(flags & VIR_DOMAIN_XML_INACTIVE) && - xmlStrEqual(cur->name, BAD_CAST "alias")) { + xmlStrEqual(cur->name, BAD_CAST "alias")) alias = cur;
This one is multi-line with no indentation to help...
- } else if (address == NULL && - xmlStrEqual(cur->name, BAD_CAST "address")) { + else if (address == NULL && + xmlStrEqual(cur->name, BAD_CAST "address")) address = cur;
...while this one has indentation help because of the 'else if'; see the difference in spotting the one-line statement?
@@ -6879,9 +6870,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (!(actual->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | - VIR_VPORT_XML_REQUIRE_TYPE))) { + VIR_VPORT_XML_REQUIRE_TYPE))) goto error; - }
And this is an example of a multi-line 'if' expression, but it is indented (both because the '=' is split over lines, and because the last part of the expression is a function call split over lines), so the one-liner is easy to spot here. But my earlier claim that one-liner 'if' expressions are easier to grep for than multi-line 'if' may mean that a syntax check would not flag this one as a place to remove the {}. Maybe it doesn't matter. (Ideally, if we could figure out how to make GNU indent or some other code prettifier enforce a style, we'd use that instead of syntax check grep rules). So, I'm welcome to other opinions... -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Fri, Nov 07, 2014 at 11:09:11AM +0100, Eric Blake wrote:
On 11/06/2014 05:38 PM, Martin Kletzander wrote:
As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions).
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> ---
+++ b/src/conf/capabilities.c @@ -219,9 +219,8 @@ virCapabilitiesDispose(void *object) VIR_FREE(caps->host.migrateTrans[i]); VIR_FREE(caps->host.migrateTrans);
- for (i = 0; i < caps->host.nsecModels; i++) { + for (i = 0; i < caps->host.nsecModels; i++) virCapabilitiesClearSecModel(&caps->host.secModels[i]); - }
Conversions like this make sense...
@@ -138,9 +138,9 @@ virDevicePCIAddressEqual(virDevicePCIAddress *addr1, if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && addr1->slot == addr2->slot && - addr1->function == addr2->function) { + addr1->function == addr2->function) return true; - }
Conversions like this are a little harder to read (that is, any time the 'if' condition extends over multiple lines, but there is exactly four space indentation of the condition, it's visually hard to see where the multi-line condition ends and the loop body begins). The opening { is hard to see either way, but seeing the closing } is my visual clue that "yes, the last line of this blob of code is not part of the 'if' but the one-line body". I'm not opposed to your removal of {}, but wonder if we should rethink our style to recommend keeping the {} if the 'if' expression is multiline.
Besides, it is easier to write a syntax check that checks for one-line 'if' expressions (that's how I wrote my checks for mis-matched if{}else; and if;else{}) than it is for multi-line if expressions. So distinguishing between the two types may make it easier to write a syntax check and enforce a consistent style.
@@ -3762,23 +3759,22 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (cur->type == XML_ELEMENT_NODE) { if (alias == NULL && !(flags & VIR_DOMAIN_XML_INACTIVE) && - xmlStrEqual(cur->name, BAD_CAST "alias")) { + xmlStrEqual(cur->name, BAD_CAST "alias")) alias = cur;
This one is multi-line with no indentation to help...
- } else if (address == NULL && - xmlStrEqual(cur->name, BAD_CAST "address")) { + else if (address == NULL && + xmlStrEqual(cur->name, BAD_CAST "address")) address = cur;
...while this one has indentation help because of the 'else if'; see the difference in spotting the one-line statement?
@@ -6879,9 +6870,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (!(actual->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | - VIR_VPORT_XML_REQUIRE_TYPE))) { + VIR_VPORT_XML_REQUIRE_TYPE))) goto error; - }
And this is an example of a multi-line 'if' expression, but it is indented (both because the '=' is split over lines, and because the last part of the expression is a function call split over lines), so the one-liner is easy to spot here.
But my earlier claim that one-liner 'if' expressions are easier to grep for than multi-line 'if' may mean that a syntax check would not flag this one as a place to remove the {}. Maybe it doesn't matter. (Ideally, if we could figure out how to make GNU indent or some other code prettifier enforce a style, we'd use that instead of syntax check grep rules).
Yeah, I'd really like to be able to run something like GNU indent over the code and check input==output, but there were a couple of rules in our coding style that indent didn't appear to support Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Fri, Nov 07, 2014 at 11:11:27AM +0100, Daniel P. Berrange wrote:
On Fri, Nov 07, 2014 at 11:09:11AM +0100, Eric Blake wrote:
On 11/06/2014 05:38 PM, Martin Kletzander wrote:
As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions).
Signed-off-by: Martin Kletzander <mkletzan@redhat.com> ---
+++ b/src/conf/capabilities.c @@ -219,9 +219,8 @@ virCapabilitiesDispose(void *object) VIR_FREE(caps->host.migrateTrans[i]); VIR_FREE(caps->host.migrateTrans);
- for (i = 0; i < caps->host.nsecModels; i++) { + for (i = 0; i < caps->host.nsecModels; i++) virCapabilitiesClearSecModel(&caps->host.secModels[i]); - }
Conversions like this make sense...
@@ -138,9 +138,9 @@ virDevicePCIAddressEqual(virDevicePCIAddress *addr1, if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && addr1->slot == addr2->slot && - addr1->function == addr2->function) { + addr1->function == addr2->function) return true; - }
Conversions like this are a little harder to read (that is, any time the 'if' condition extends over multiple lines, but there is exactly four space indentation of the condition, it's visually hard to see where the multi-line condition ends and the loop body begins). The opening { is hard to see either way, but seeing the closing } is my visual clue that "yes, the last line of this blob of code is not part of the 'if' but the one-line body". I'm not opposed to your removal of {}, but wonder if we should rethink our style to recommend keeping the {} if the 'if' expression is multiline.
Besides, it is easier to write a syntax check that checks for one-line 'if' expressions (that's how I wrote my checks for mis-matched if{}else; and if;else{}) than it is for multi-line if expressions. So distinguishing between the two types may make it easier to write a syntax check and enforce a consistent style.
@@ -3762,23 +3759,22 @@ virDomainDeviceInfoParseXML(xmlNodePtr node, if (cur->type == XML_ELEMENT_NODE) { if (alias == NULL && !(flags & VIR_DOMAIN_XML_INACTIVE) && - xmlStrEqual(cur->name, BAD_CAST "alias")) { + xmlStrEqual(cur->name, BAD_CAST "alias")) alias = cur;
This one is multi-line with no indentation to help...
- } else if (address == NULL && - xmlStrEqual(cur->name, BAD_CAST "address")) { + else if (address == NULL && + xmlStrEqual(cur->name, BAD_CAST "address")) address = cur;
...while this one has indentation help because of the 'else if'; see the difference in spotting the one-line statement?
@@ -6879,9 +6870,8 @@ virDomainActualNetDefParseXML(xmlNodePtr node, if (!(actual->virtPortProfile = virNetDevVPortProfileParse(virtPortNode, VIR_VPORT_XML_REQUIRE_ALL_ATTRIBUTES | - VIR_VPORT_XML_REQUIRE_TYPE))) { + VIR_VPORT_XML_REQUIRE_TYPE))) goto error; - }
And this is an example of a multi-line 'if' expression, but it is indented (both because the '=' is split over lines, and because the last part of the expression is a function call split over lines), so the one-liner is easy to spot here.
But my earlier claim that one-liner 'if' expressions are easier to grep for than multi-line 'if' may mean that a syntax check would not flag this one as a place to remove the {}. Maybe it doesn't matter. (Ideally, if we could figure out how to make GNU indent or some other code prettifier enforce a style, we'd use that instead of syntax check grep rules).
Yeah, I'd really like to be able to run something like GNU indent over the code and check input==output, but there were a couple of rules in our coding style that indent didn't appear to support
I tried playing with the indent tool many times but I've never got to any better situation than where we were at the time I started hacking on libvirt. Maybe if we can adjust our rules to match whatever indent supports, although I don't remember what the particular problems were. Martin

On 11/07/2014 05:09 AM, Eric Blake wrote:
On 11/06/2014 05:38 PM, Martin Kletzander wrote:
@@ -138,9 +138,9 @@ virDevicePCIAddressEqual(virDevicePCIAddress *addr1, if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && addr1->slot == addr2->slot && - addr1->function == addr2->function) { + addr1->function == addr2->function) return true; - } Conversions like this are a little harder to read (that is, any time the 'if' condition extends over multiple lines, but there is exactly four space indentation of the condition, it's visually hard to see where the multi-line condition ends and the loop body begins). The opening { is hard to see either way, but seeing the closing } is my visual clue that "yes, the last line of this blob of code is not part of the 'if' but the one-line body". I'm not opposed to your removal of {}, but wonder if we should rethink our style to recommend keeping the {} if the 'if' expression is multiline.
I've always thought this, and used to do it that way until a few reviewers complained. So I for one would welcome our new "use braces if condition is multiple lines" overlords :-) (I also agree that this is all an exercise in futility unless there is a matching syntax-check rule to enforce it.)

On Fri, Nov 07, 2014 at 09:58:11AM -0500, Laine Stump wrote:
On 11/07/2014 05:09 AM, Eric Blake wrote:
On 11/06/2014 05:38 PM, Martin Kletzander wrote:
@@ -138,9 +138,9 @@ virDevicePCIAddressEqual(virDevicePCIAddress *addr1, if (addr1->domain == addr2->domain && addr1->bus == addr2->bus && addr1->slot == addr2->slot && - addr1->function == addr2->function) { + addr1->function == addr2->function) return true; - } Conversions like this are a little harder to read (that is, any time the 'if' condition extends over multiple lines, but there is exactly four space indentation of the condition, it's visually hard to see where the multi-line condition ends and the loop body begins). The opening { is hard to see either way, but seeing the closing } is my visual clue that "yes, the last line of this blob of code is not part of the 'if' but the one-line body". I'm not opposed to your removal of {}, but wonder if we should rethink our style to recommend keeping the {} if the 'if' expression is multiline.
I've always thought this, and used to do it that way until a few reviewers complained. So I for one would welcome our new "use braces if condition is multiple lines" overlords :-)
(I also agree that this is all an exercise in futility unless there is a matching syntax-check rule to enforce it.)
Well, I used to place opening curly brackets on their own new lines as we do with functions (pre-libvirt) and this is something I had to get used to. Anyway, I'd be more than OK with changing contributor guidelines and saying that we require curly brackets if either a) the body or b) the condition itself spans over multiple lines. syntax-check for that is *way* easier ;) Martin

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/esx/esx_device_monitor.c | 3 +- src/esx/esx_driver.c | 838 ++++++++++++------------------------ src/esx/esx_interface_driver.c | 36 +- src/esx/esx_network_driver.c | 132 ++---- src/esx/esx_nwfilter_driver.c | 3 +- src/esx/esx_secret_driver.c | 3 +- src/esx/esx_storage_backend_iscsi.c | 78 ++-- src/esx/esx_storage_backend_vmfs.c | 204 +++------ src/esx/esx_storage_driver.c | 81 ++-- src/esx/esx_util.c | 51 +-- src/esx/esx_vi.c | 606 +++++++++----------------- src/esx/esx_vi_methods.c | 3 +- src/esx/esx_vi_types.c | 54 +-- 13 files changed, 700 insertions(+), 1392 deletions(-) diff --git a/src/esx/esx_device_monitor.c b/src/esx/esx_device_monitor.c index c02b00f..b1bc07a 100644 --- a/src/esx/esx_device_monitor.c +++ b/src/esx/esx_device_monitor.c @@ -43,9 +43,8 @@ esxNodeDeviceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_ESX) { + if (conn->driver->no != VIR_DRV_ESX) return VIR_DRV_OPEN_DECLINED; - } conn->nodeDevicePrivateData = conn->privateData; diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 0770e89..bceb448 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -66,9 +66,8 @@ struct _esxVMX_Data { static void esxFreePrivate(esxPrivate **priv) { - if (!priv || !(*priv)) { + if (!priv || !(*priv)) return; - } esxVI_Context_Free(&(*priv)->host); esxVI_Context_Free(&(*priv)->vCenter); @@ -154,9 +153,8 @@ esxParseVMXFileName(const char *fileName, void *opaque) if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name") < 0 || esxVI_LookupDatastoreList(data->ctx, propertyNameList, - &datastoreList) < 0) { + &datastoreList) < 0) return NULL; - } /* Search for datastore by mount path */ for (datastore = datastoreList; datastore; @@ -168,32 +166,27 @@ esxParseVMXFileName(const char *fileName, void *opaque) &hostMount, esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetStringValue(datastore, "summary.name", &datastoreName, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } tmp = (char *)STRSKIP(fileName, hostMount->mountInfo->path); - if (!tmp) { + if (!tmp) continue; - } /* Found a match. Strip leading separators */ - while (*tmp == '/' || *tmp == '\\') { + while (*tmp == '/' || *tmp == '\\') ++tmp; - } - if (VIR_STRDUP(strippedFileName, tmp) < 0) { + if (VIR_STRDUP(strippedFileName, tmp) < 0) goto cleanup; - } tmp = strippedFileName; /* Convert \ to / */ while (*tmp != '\0') { - if (*tmp == '\\') { + if (*tmp == '\\') *tmp = '/'; - } ++tmp; } @@ -207,9 +200,8 @@ esxParseVMXFileName(const char *fileName, void *opaque) /* Fallback to direct datastore name match */ if (!result && STRPREFIX(fileName, "/vmfs/volumes/")) { - if (VIR_STRDUP(copyOfFileName, fileName) < 0) { + if (VIR_STRDUP(copyOfFileName, fileName) < 0) goto cleanup; - } /* Expected format: '/vmfs/volumes/<datastore>/<path>' */ if (!(tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) || @@ -225,9 +217,8 @@ esxParseVMXFileName(const char *fileName, void *opaque) if (esxVI_LookupDatastoreByName(data->ctx, datastoreName, NULL, &datastoreList, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!datastoreList) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -244,9 +235,8 @@ esxParseVMXFileName(const char *fileName, void *opaque) /* If it's an absolute path outside of a datastore just use it as is */ if (!result && *fileName == '/') { /* FIXME: need to deal with Windows paths here too */ - if (VIR_STRDUP(result, fileName) < 0) { + if (VIR_STRDUP(result, fileName) < 0) goto cleanup; - } } if (!result) { @@ -299,29 +289,25 @@ esxFormatVMXFileName(const char *fileName, void *opaque) if (*fileName == '[') { /* Parse datastore path and lookup datastore */ if (esxUtil_ParseDatastorePath(fileName, &datastoreName, NULL, - &directoryAndFileName) < 0) { + &directoryAndFileName) < 0) goto cleanup; - } if (esxVI_LookupDatastoreByName(data->ctx, datastoreName, NULL, &datastore, esxVI_Occurrence_RequiredItem) < 0 || esxVI_LookupDatastoreHostMount(data->ctx, datastore->obj, &hostMount, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* Detect separator type */ - if (strchr(hostMount->mountInfo->path, '\\')) { + if (strchr(hostMount->mountInfo->path, '\\')) separator = '\\'; - } /* Strip trailing separators */ length = strlen(hostMount->mountInfo->path); - while (length > 0 && hostMount->mountInfo->path[length - 1] == separator) { + while (length > 0 && hostMount->mountInfo->path[length - 1] == separator) --length; - } /* Format as <mount>[/<directory>]/<file>, convert / to \ when necessary */ virBufferAdd(&buffer, hostMount->mountInfo->path, length); @@ -330,9 +316,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque) tmp = directoryAndFileName; while (*tmp != '\0') { - if (*tmp == '/') { + if (*tmp == '/') *tmp = separator; - } ++tmp; } @@ -347,9 +332,8 @@ esxFormatVMXFileName(const char *fileName, void *opaque) result = virBufferContentAndReset(&buffer); } else if (*fileName == '/') { /* FIXME: need to deal with Windows paths here too */ - if (VIR_STRDUP(result, fileName) < 0) { + if (VIR_STRDUP(result, fileName) < 0) goto cleanup; - } } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not handle file name '%s'"), fileName); @@ -399,9 +383,8 @@ esxAutodetectSCSIControllerModel(virDomainDiskDefPtr def, int *model, if (esxVI_LookupFileInfoByDatastorePath(data->ctx, src, false, &fileInfo, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo); @@ -451,36 +434,31 @@ esxSupportsLongMode(esxPrivate *priv) esxVI_ParsedHostCpuIdInfo parsedHostCpuIdInfo; char edxLongModeBit = '?'; - if (priv->supportsLongMode != esxVI_Boolean_Undefined) { + if (priv->supportsLongMode != esxVI_Boolean_Undefined) return priv->supportsLongMode; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return esxVI_Boolean_Undefined; - } if (esxVI_String_AppendValueToList(&propertyNameList, "hardware.cpuFeature") < 0 || esxVI_LookupHostSystemProperties(priv->primary, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "hardware.cpuFeature")) { if (esxVI_HostCpuIdInfo_CastListFromAnyType - (dynamicProperty->val, &hostCpuIdInfoList) < 0) { + (dynamicProperty->val, &hostCpuIdInfoList) < 0) goto cleanup; - } for (hostCpuIdInfo = hostCpuIdInfoList; hostCpuIdInfo; hostCpuIdInfo = hostCpuIdInfo->_next) { if (hostCpuIdInfo->level->value == -2147483647) { /* 0x80000001 */ if (esxVI_ParseHostCpuIdInfo(&parsedHostCpuIdInfo, - hostCpuIdInfo) < 0) { + hostCpuIdInfo) < 0) goto cleanup; - } edxLongModeBit = parsedHostCpuIdInfo.edx[29]; @@ -529,18 +507,16 @@ esxLookupHostSystemBiosUuid(esxPrivate *priv, unsigned char *uuid) esxVI_ObjectContent *hostSystem = NULL; char *uuid_string = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "hardware.systemInfo.uuid") < 0 || esxVI_LookupHostSystemProperties(priv->primary, propertyNameList, &hostSystem) < 0 || esxVI_GetStringValue(hostSystem, "hardware.systemInfo.uuid", - &uuid_string, esxVI_Occurrence_RequiredItem) < 0) { + &uuid_string, esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (strlen(uuid_string) > 0) { if (virUUIDParse(uuid_string, uuid) < 0) { @@ -571,15 +547,13 @@ esxCapsInit(esxPrivate *priv) virCapsPtr caps = NULL; virCapsGuestPtr guest = NULL; - if (supportsLongMode == esxVI_Boolean_Undefined) { + if (supportsLongMode == esxVI_Boolean_Undefined) return NULL; - } - if (supportsLongMode == esxVI_Boolean_True) { + if (supportsLongMode == esxVI_Boolean_True) caps = virCapabilitiesNew(VIR_ARCH_X86_64, true, true); - } else { + else caps = virCapabilitiesNew(VIR_ARCH_I686, true, true); - } if (!caps) return NULL; @@ -587,9 +561,8 @@ esxCapsInit(esxPrivate *priv) virCapabilitiesAddHostMigrateTransport(caps, "vpxmigr"); - if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) { + if (esxLookupHostSystemBiosUuid(priv, caps->host.host_uuid) < 0) goto failure; - } /* i686 */ guest = virCapabilitiesAddGuest(caps, "hvm", @@ -597,13 +570,11 @@ esxCapsInit(esxPrivate *priv) NULL, NULL, 0, NULL); - if (!guest) { + if (!guest) goto failure; - } - if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) { + if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) goto failure; - } /* x86_64 */ if (supportsLongMode == esxVI_Boolean_True) { @@ -612,13 +583,11 @@ esxCapsInit(esxPrivate *priv) NULL, NULL, 0, NULL); - if (!guest) { + if (!guest) goto failure; - } - if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) { + if (!virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, NULL)) goto failure; - } } return caps; @@ -655,9 +624,8 @@ esxConnectToHost(esxPrivate *priv, return -1; } - if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0) { + if (esxUtil_ResolveHostname(conn->uri->server, ipAddress, NI_MAXHOST) < 0) return -1; - } if (conn->uri->user) { if (VIR_STRDUP(username, conn->uri->user) < 0) @@ -680,9 +648,8 @@ esxConnectToHost(esxPrivate *priv, password = esxUtil_EscapeForXml(unescapedPassword); - if (!password) { + if (!password) goto cleanup; - } if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport, conn->uri->server, conn->uri->port) < 0) @@ -691,9 +658,8 @@ esxConnectToHost(esxPrivate *priv, if (esxVI_Context_Alloc(&priv->host) < 0 || esxVI_Context_Connect(priv->host, url, ipAddress, username, password, priv->parsedUri) < 0 || - esxVI_Context_LookupManagedObjects(priv->host) < 0) { + esxVI_Context_LookupManagedObjects(priv->host) < 0) goto cleanup; - } if (expectedProductVersion == esxVI_ProductVersion_ESX) { if (priv->host->productVersion != esxVI_ProductVersion_ESX35 && @@ -727,14 +693,12 @@ esxConnectToHost(esxPrivate *priv, esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetStringValue(hostSystem, "summary.managementServerIp", vCenterIpAddress, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } /* Warn if host is in maintenance mode */ - if (inMaintenanceMode == esxVI_Boolean_True) { + if (inMaintenanceMode == esxVI_Boolean_True) VIR_WARN("The server is in maintenance mode"); - } if (VIR_STRDUP(*vCenterIpAddress, *vCenterIpAddress) < 0) goto cleanup; @@ -775,14 +739,12 @@ esxConnectToVCenter(esxPrivate *priv, return -1; } - if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) { + if (esxUtil_ResolveHostname(hostname, ipAddress, NI_MAXHOST) < 0) return -1; - } if (conn->uri->user) { - if (VIR_STRDUP(username, conn->uri->user) < 0) { + if (VIR_STRDUP(username, conn->uri->user) < 0) goto cleanup; - } } else { username = virAuthGetUsername(conn, auth, "esx", "administrator", hostname); @@ -801,9 +763,8 @@ esxConnectToVCenter(esxPrivate *priv, password = esxUtil_EscapeForXml(unescapedPassword); - if (!password) { + if (!password) goto cleanup; - } if (virAsprintf(&url, "%s://%s:%d/sdk", priv->parsedUri->transport, hostname, conn->uri->port) < 0) @@ -811,9 +772,8 @@ esxConnectToVCenter(esxPrivate *priv, if (esxVI_Context_Alloc(&priv->vCenter) < 0 || esxVI_Context_Connect(priv->vCenter, url, ipAddress, username, - password, priv->parsedUri) < 0) { + password, priv->parsedUri) < 0) goto cleanup; - } if (priv->vCenter->productVersion != esxVI_ProductVersion_VPX25 && priv->vCenter->productVersion != esxVI_ProductVersion_VPX40 && @@ -830,14 +790,12 @@ esxConnectToVCenter(esxPrivate *priv, if (hostSystemIpAddress) { if (esxVI_Context_LookupManagedObjectsByHostSystemIp - (priv->vCenter, hostSystemIpAddress) < 0) { + (priv->vCenter, hostSystemIpAddress) < 0) goto cleanup; - } } else { if (esxVI_Context_LookupManagedObjectsByPath(priv->vCenter, - priv->parsedUri->path) < 0) { + priv->parsedUri->path) < 0) goto cleanup; - } } result = 0; @@ -911,9 +869,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); /* Decline if the URI is NULL or the scheme is NULL */ - if (!conn->uri || !conn->uri->scheme) { + if (!conn->uri || !conn->uri->scheme) return VIR_DRV_OPEN_DECLINED; - } /* Decline if the scheme is not one of {vpx|esx|gsx} */ plus = strchr(conn->uri->scheme, '+'); @@ -921,16 +878,14 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, if (!plus) { if (STRCASENEQ(conn->uri->scheme, "vpx") && STRCASENEQ(conn->uri->scheme, "esx") && - STRCASENEQ(conn->uri->scheme, "gsx")) { + STRCASENEQ(conn->uri->scheme, "gsx")) return VIR_DRV_OPEN_DECLINED; - } } else { if (plus - conn->uri->scheme != 3 || (STRCASENEQLEN(conn->uri->scheme, "vpx", 3) && STRCASENEQLEN(conn->uri->scheme, "esx", 3) && - STRCASENEQLEN(conn->uri->scheme, "gsx", 3))) { + STRCASENEQLEN(conn->uri->scheme, "gsx", 3))) return VIR_DRV_OPEN_DECLINED; - } virReportError(VIR_ERR_INVALID_ARG, _("Transport '%s' in URI scheme is not supported, try again " @@ -962,9 +917,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, if (VIR_ALLOC(priv) < 0) goto cleanup; - if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) { + if (esxUtil_ParseUri(&priv->parsedUri, conn->uri) < 0) goto cleanup; - } priv->maxVcpus = -1; priv->supportsVMotion = esxVI_Boolean_Undefined; @@ -999,9 +953,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, STRCASEEQ(conn->uri->scheme, "gsx")) { /* Connect to host */ if (esxConnectToHost(priv, conn, auth, - &potentialVCenterIpAddress) < 0) { + &potentialVCenterIpAddress) < 0) goto cleanup; - } /* Connect to vCenter */ if (priv->parsedUri->vCenter) { @@ -1021,9 +974,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, } } else { if (esxUtil_ResolveHostname(priv->parsedUri->vCenter, - vCenterIpAddress, NI_MAXHOST) < 0) { + vCenterIpAddress, NI_MAXHOST) < 0) goto cleanup; - } if (potentialVCenterIpAddress && STRNEQ(vCenterIpAddress, potentialVCenterIpAddress)) { @@ -1039,9 +991,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, if (esxConnectToVCenter(priv, conn, auth, vCenterIpAddress, - priv->host->ipAddress) < 0) { + priv->host->ipAddress) < 0) goto cleanup; - } } priv->primary = priv->host; @@ -1049,9 +1000,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, /* Connect to vCenter */ if (esxConnectToVCenter(priv, conn, auth, conn->uri->server, - NULL) < 0) { + NULL) < 0) goto cleanup; - } priv->primary = priv->vCenter; } @@ -1059,9 +1009,8 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, /* Setup capabilities */ priv->caps = esxCapsInit(priv); - if (!priv->caps) { + if (!priv->caps) goto cleanup; - } if (!(priv->xmlopt = virVMXDomainXMLConfInit())) goto cleanup; @@ -1087,16 +1036,14 @@ esxConnectClose(virConnectPtr conn) if (priv->host) { if (esxVI_EnsureSession(priv->host) < 0 || - esxVI_Logout(priv->host) < 0) { + esxVI_Logout(priv->host) < 0) result = -1; - } } if (priv->vCenter) { if (esxVI_EnsureSession(priv->vCenter) < 0 || - esxVI_Logout(priv->vCenter) < 0) { + esxVI_Logout(priv->vCenter) < 0) result = -1; - } } esxFreePrivate(&priv); @@ -1114,13 +1061,11 @@ esxSupportsVMotion(esxPrivate *priv) esxVI_String *propertyNameList = NULL; esxVI_ObjectContent *hostSystem = NULL; - if (priv->supportsVMotion != esxVI_Boolean_Undefined) { + if (priv->supportsVMotion != esxVI_Boolean_Undefined) return priv->supportsVMotion; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return esxVI_Boolean_Undefined; - } if (esxVI_String_AppendValueToList(&propertyNameList, "capability.vmotionSupported") < 0 || @@ -1128,9 +1073,8 @@ esxSupportsVMotion(esxPrivate *priv) &hostSystem) < 0 || esxVI_GetBoolean(hostSystem, "capability.vmotionSupported", &priv->supportsVMotion, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } cleanup: /* @@ -1189,9 +1133,8 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature) case VIR_DRV_FEATURE_MIGRATION_V1: supportsVMotion = esxSupportsVMotion(priv); - if (supportsVMotion == esxVI_Boolean_Undefined) { + if (supportsVMotion == esxVI_Boolean_Undefined) return -1; - } /* Migration is only possible via a vCenter and if VMotion is enabled */ return priv->vCenter && @@ -1242,35 +1185,31 @@ esxConnectGetHostname(virConnectPtr conn) const char *domainName = NULL; char *complete = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_String_AppendValueListToList (&propertyNameList, "config.network.dnsConfig.hostName\0" "config.network.dnsConfig.domainName\0") < 0 || esxVI_LookupHostSystemProperties(priv->primary, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.network.dnsConfig.hostName")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) goto cleanup; - } hostName = dynamicProperty->val->string; } else if (STREQ(dynamicProperty->name, "config.network.dnsConfig.domainName")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) goto cleanup; - } domainName = dynamicProperty->val->string; } else { @@ -1324,9 +1263,8 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo) memset(nodeinfo, 0, sizeof(*nodeinfo)); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "hardware.cpuInfo.hz\0" @@ -1337,64 +1275,56 @@ esxNodeGetInfo(virConnectPtr conn, virNodeInfoPtr nodeinfo) "hardware.numaInfo.numNodes\0" "summary.hardware.cpuModel\0") < 0 || esxVI_LookupHostSystemProperties(priv->primary, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "hardware.cpuInfo.hz")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } cpuInfo_hz = dynamicProperty->val->int64; } else if (STREQ(dynamicProperty->name, "hardware.cpuInfo.numCpuCores")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Short) < 0) { + esxVI_Type_Short) < 0) goto cleanup; - } cpuInfo_numCpuCores = dynamicProperty->val->int16; } else if (STREQ(dynamicProperty->name, "hardware.cpuInfo.numCpuPackages")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Short) < 0) { + esxVI_Type_Short) < 0) goto cleanup; - } cpuInfo_numCpuPackages = dynamicProperty->val->int16; } else if (STREQ(dynamicProperty->name, "hardware.cpuInfo.numCpuThreads")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Short) < 0) { + esxVI_Type_Short) < 0) goto cleanup; - } cpuInfo_numCpuThreads = dynamicProperty->val->int16; } else if (STREQ(dynamicProperty->name, "hardware.memorySize")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } memorySize = dynamicProperty->val->int64; } else if (STREQ(dynamicProperty->name, "hardware.numaInfo.numNodes")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Int) < 0) { + esxVI_Type_Int) < 0) goto cleanup; - } numaInfo_numNodes = dynamicProperty->val->int32; } else if (STREQ(dynamicProperty->name, "summary.hardware.cpuModel")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) goto cleanup; - } ptr = dynamicProperty->val->string; @@ -1471,31 +1401,26 @@ esxConnectListDomains(virConnectPtr conn, int *ids, int maxids) esxVI_VirtualMachinePowerState powerState; int count = 0; - if (maxids == 0) { + if (maxids == 0) return 0; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineList(priv->primary, propertyNameList, - &virtualMachineList) < 0) { + &virtualMachineList) < 0) goto cleanup; - } for (virtualMachine = virtualMachineList; virtualMachine; virtualMachine = virtualMachine->_next) { if (esxVI_GetVirtualMachinePowerState(virtualMachine, - &powerState) < 0) { + &powerState) < 0) goto cleanup; - } - if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) { + if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) continue; - } if (esxUtil_ParseVirtualMachineIDString(virtualMachine->obj->value, &ids[count]) < 0 || @@ -1508,9 +1433,8 @@ esxConnectListDomains(virConnectPtr conn, int *ids, int maxids) count++; - if (count >= maxids) { + if (count >= maxids) break; - } } success = true; @@ -1529,9 +1453,8 @@ esxConnectNumOfDomains(virConnectPtr conn) { esxPrivate *priv = conn->privateData; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return esxVI_LookupNumberOfDomainsByPowerState (priv->primary, esxVI_VirtualMachinePowerState_PoweredOn, false); @@ -1552,9 +1475,8 @@ esxDomainLookupByID(virConnectPtr conn, int id) unsigned char uuid_candidate[VIR_UUID_BUFLEN]; virDomainPtr domain = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "configStatus\0" @@ -1562,48 +1484,41 @@ esxDomainLookupByID(virConnectPtr conn, int id) "runtime.powerState\0" "config.uuid\0") < 0 || esxVI_LookupVirtualMachineList(priv->primary, propertyNameList, - &virtualMachineList) < 0) { + &virtualMachineList) < 0) goto cleanup; - } for (virtualMachine = virtualMachineList; virtualMachine; virtualMachine = virtualMachine->_next) { if (esxVI_GetVirtualMachinePowerState(virtualMachine, - &powerState) < 0) { + &powerState) < 0) goto cleanup; - } /* Only running/suspended domains have an ID != -1 */ - if (powerState == esxVI_VirtualMachinePowerState_PoweredOff) { + if (powerState == esxVI_VirtualMachinePowerState_PoweredOff) continue; - } VIR_FREE(name_candidate); if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id_candidate, &name_candidate, - uuid_candidate) < 0) { + uuid_candidate) < 0) goto cleanup; - } - if (id != id_candidate) { + if (id != id_candidate) continue; - } domain = virGetDomain(conn, name_candidate, uuid_candidate); - if (!domain) { + if (!domain) goto cleanup; - } domain->id = id; break; } - if (!domain) { + if (!domain) virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id); - } cleanup: esxVI_String_Free(&propertyNameList); @@ -1626,9 +1541,8 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) char *name = NULL; virDomainPtr domain = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "name\0" @@ -1637,22 +1551,19 @@ esxDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetVirtualMachineIdentity(virtualMachine, &id, &name, NULL) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } domain = virGetDomain(conn, name, uuid); - if (!domain) { + if (!domain) goto cleanup; - } /* Only running/suspended virtual machines have an ID != -1 */ - if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { + if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) domain->id = id; - } else { + else domain->id = -1; - } cleanup: esxVI_String_Free(&propertyNameList); @@ -1675,9 +1586,8 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) unsigned char uuid[VIR_UUID_BUFLEN]; virDomainPtr domain = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "configStatus\0" @@ -1685,9 +1595,8 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) "config.uuid\0") < 0 || esxVI_LookupVirtualMachineByName(priv->primary, name, propertyNameList, &virtualMachine, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!virtualMachine) { virReportError(VIR_ERR_NO_DOMAIN, _("No domain with name '%s'"), name); @@ -1695,22 +1604,19 @@ esxDomainLookupByName(virConnectPtr conn, const char *name) } if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, uuid) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } domain = virGetDomain(conn, name, uuid); - if (!domain) { + if (!domain) goto cleanup; - } /* Only running/suspended virtual machines have an ID != -1 */ - if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { + if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) domain->id = id; - } else { + else domain->id = -1; - } cleanup: esxVI_String_Free(&propertyNameList); @@ -1733,18 +1639,16 @@ esxDomainSuspend(virDomainPtr domain) esxVI_TaskInfoState taskInfoState; char *taskInfoErrorMessage = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->primary, domain->uuid, propertyNameList, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1756,9 +1660,8 @@ esxDomainSuspend(virDomainPtr domain) esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not suspend domain: %s"), @@ -1791,18 +1694,16 @@ esxDomainResume(virDomainPtr domain) esxVI_TaskInfoState taskInfoState; char *taskInfoErrorMessage = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->primary, domain->uuid, propertyNameList, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_Suspended) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", _("Domain is not suspended")); @@ -1814,9 +1715,8 @@ esxDomainResume(virDomainPtr domain) esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not resume domain: %s"), @@ -1848,18 +1748,16 @@ esxDomainShutdownFlags(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1867,9 +1765,8 @@ esxDomainShutdownFlags(virDomainPtr domain, unsigned int flags) goto cleanup; } - if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0) { + if (esxVI_ShutdownGuest(priv->primary, virtualMachine->obj) < 0) goto cleanup; - } result = 0; @@ -1899,18 +1796,16 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1918,9 +1813,8 @@ esxDomainReboot(virDomainPtr domain, unsigned int flags) goto cleanup; } - if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0) { + if (esxVI_RebootGuest(priv->primary, virtualMachine->obj) < 0) goto cleanup; - } result = 0; @@ -1949,24 +1843,21 @@ esxDomainDestroyFlags(virDomainPtr domain, virCheckFlags(0, -1); - if (priv->vCenter) { + if (priv->vCenter) ctx = priv->vCenter; - } else { + else ctx = priv->host; - } - if (esxVI_EnsureSession(ctx) < 0) { + if (esxVI_EnsureSession(ctx) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuidAndPrepareForTask (ctx, domain->uuid, propertyNameList, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_PoweredOn) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1978,9 +1869,8 @@ esxDomainDestroyFlags(virDomainPtr domain, esxVI_WaitForTaskCompletion(ctx, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not destroy domain: %s"), @@ -2028,25 +1918,22 @@ esxDomainGetMaxMemory(virDomainPtr domain) esxVI_DynamicProperty *dynamicProperty = NULL; unsigned long memoryMB = 0; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return 0; - } if (esxVI_String_AppendValueToList(&propertyNameList, "config.hardware.memoryMB") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = virtualMachine->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.hardware.memoryMB")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Int) < 0) { + esxVI_Type_Int) < 0) goto cleanup; - } if (dynamicProperty->val->int32 < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2084,18 +1971,16 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) esxVI_TaskInfoState taskInfoState; char *taskInfoErrorMessage = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->primary, domain->uuid, propertyNameList, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -2104,9 +1989,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) } if (esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 || - esxVI_Long_Alloc(&spec->memoryMB) < 0) { + esxVI_Long_Alloc(&spec->memoryMB) < 0) goto cleanup; - } /* max-memory must be a multiple of 4096 kilobyte */ spec->memoryMB->value = @@ -2117,9 +2001,8 @@ esxDomainSetMaxMemory(virDomainPtr domain, unsigned long memory) esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2153,18 +2036,16 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory) esxVI_TaskInfoState taskInfoState; char *taskInfoErrorMessage = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->primary, domain->uuid, NULL, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 || esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0 || - esxVI_Long_Alloc(&spec->memoryAllocation->limit) < 0) { + esxVI_Long_Alloc(&spec->memoryAllocation->limit) < 0) goto cleanup; - } spec->memoryAllocation->limit->value = VIR_DIV_UP(memory, 1024); /* Scale from kilobytes to megabytes */ @@ -2174,9 +2055,8 @@ esxDomainSetMemory(virDomainPtr domain, unsigned long memory) esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2234,9 +2114,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) memset(info, 0, sizeof(*info)); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "runtime.powerState\0" @@ -2245,9 +2124,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) "config.memoryAllocation.limit\0") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } info->state = VIR_DOMAIN_NOSTATE; @@ -2255,38 +2133,33 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "runtime.powerState")) { if (esxVI_VirtualMachinePowerState_CastFromAnyType - (dynamicProperty->val, &powerState) < 0) { + (dynamicProperty->val, &powerState) < 0) goto cleanup; - } info->state = esxVI_VirtualMachinePowerState_ConvertToLibvirt (powerState); } else if (STREQ(dynamicProperty->name, "config.hardware.memoryMB")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Int) < 0) { + esxVI_Type_Int) < 0) goto cleanup; - } info->maxMem = dynamicProperty->val->int32 * 1024; /* Scale from megabyte to kilobyte */ } else if (STREQ(dynamicProperty->name, "config.hardware.numCPU")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Int) < 0) { + esxVI_Type_Int) < 0) goto cleanup; - } info->nrVirtCpu = dynamicProperty->val->int32; } else if (STREQ(dynamicProperty->name, "config.memoryAllocation.limit")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } memory_limit = dynamicProperty->val->int64; - if (memory_limit > 0) { + if (memory_limit > 0) memory_limit *= 1024; /* Scale from megabyte to kilobyte */ - } } else { VIR_WARN("Unexpected '%s' property", dynamicProperty->name); } @@ -2300,20 +2173,17 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) /* FIXME: Currently no host for a vpx:// connection */ if (priv->host) { if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId >= 0) { - if (esxVI_Int_Alloc(&counterId) < 0) { + if (esxVI_Int_Alloc(&counterId) < 0) goto cleanup; - } counterId->value = priv->usedCpuTimeCounterId; - if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) { + if (esxVI_Int_AppendToList(&counterIdList, counterId) < 0) goto cleanup; - } if (esxVI_QueryPerfCounter(priv->host, counterIdList, - &perfCounterInfo) < 0) { + &perfCounterInfo) < 0) goto cleanup; - } if (STRNEQ(perfCounterInfo->groupInfo->key, "cpu") || STRNEQ(perfCounterInfo->nameInfo->key, "used") || @@ -2335,9 +2205,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) if (info->state == VIR_DOMAIN_RUNNING && priv->usedCpuTimeCounterId < 0) { if (esxVI_QueryAvailablePerfMetric(priv->host, virtualMachine->obj, NULL, NULL, NULL, - &perfMetricIdList) < 0) { + &perfMetricIdList) < 0) goto cleanup; - } for (perfMetricId = perfMetricIdList; perfMetricId; perfMetricId = perfMetricId->_next) { @@ -2347,15 +2216,13 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) counterId = NULL; if (esxVI_Int_DeepCopy(&counterId, perfMetricId->counterId) < 0 || - esxVI_Int_AppendToList(&counterIdList, counterId) < 0) { + esxVI_Int_AppendToList(&counterIdList, counterId) < 0) goto cleanup; - } } if (esxVI_QueryPerfCounter(priv->host, counterIdList, - &perfCounterInfoList) < 0) { + &perfCounterInfoList) < 0) goto cleanup; - } for (perfCounterInfo = perfCounterInfoList; perfCounterInfo; perfCounterInfo = perfCounterInfo->_next) { @@ -2376,9 +2243,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) } } - if (priv->usedCpuTimeCounterId < 0) { + if (priv->usedCpuTimeCounterId < 0) VIR_WARN("Could not find 'used CPU time' performance counter"); - } } /* @@ -2391,9 +2257,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) if (esxVI_PerfQuerySpec_Alloc(&querySpec) < 0 || esxVI_Int_Alloc(&querySpec->maxSample) < 0 || esxVI_PerfMetricId_Alloc(&querySpec->metricId) < 0 || - esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) { + esxVI_Int_Alloc(&querySpec->metricId->counterId) < 0) goto cleanup; - } querySpec->entity = virtualMachine->obj; querySpec->maxSample->value = 1; @@ -2402,9 +2267,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) querySpec->format = (char *)"normal"; if (esxVI_QueryPerf(priv->host, querySpec, - &perfEntityMetricBaseList) < 0) { + &perfEntityMetricBaseList) < 0) goto cleanup; - } for (perfEntityMetricBase = perfEntityMetricBaseList; perfEntityMetricBase; @@ -2437,9 +2301,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) for (value = perfMetricIntSeries->value; value; - value = value->_next) { + value = value->_next) VIR_DEBUG("value %lld", (long long int)value->value); - } } } @@ -2465,9 +2328,8 @@ esxDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) querySpec->entity = NULL; querySpec->format = NULL; - if (querySpec->metricId) { + if (querySpec->metricId) querySpec->metricId->instance = NULL; - } } #endif @@ -2500,18 +2362,16 @@ esxDomainGetState(virDomainPtr domain, virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } *state = esxVI_VirtualMachinePowerState_ConvertToLibvirt(powerState); @@ -2631,15 +2491,13 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, return -1; } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } maxVcpus = esxDomainGetMaxVcpus(domain); - if (maxVcpus < 0) { + if (maxVcpus < 0) return -1; - } if (nvcpus > maxVcpus) { virReportError(VIR_ERR_INVALID_ARG, @@ -2653,9 +2511,8 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, (priv->primary, domain->uuid, NULL, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 || - esxVI_Int_Alloc(&spec->numCPUs) < 0) { + esxVI_Int_Alloc(&spec->numCPUs) < 0) goto cleanup; - } spec->numCPUs->value = nvcpus; @@ -2664,9 +2521,8 @@ esxDomainSetVcpusFlags(virDomainPtr domain, unsigned int nvcpus, esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2709,30 +2565,26 @@ esxDomainGetVcpusFlags(virDomainPtr domain, unsigned int flags) return -1; } - if (priv->maxVcpus > 0) { + if (priv->maxVcpus > 0) return priv->maxVcpus; - } priv->maxVcpus = -1; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "capability.maxSupportedVcpus") < 0 || esxVI_LookupHostSystemProperties(priv->primary, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "capability.maxSupportedVcpus")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Int) < 0) { + esxVI_Type_Int) < 0) goto cleanup; - } priv->maxVcpus = dynamicProperty->val->int32; break; @@ -2783,9 +2635,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) memset(&data, 0, sizeof(data)); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "config.files.vmPathName\0" @@ -2796,14 +2647,12 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0 || esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0 || esxVI_GetStringValue(virtualMachine, "config.files.vmPathName", - &vmPathName, esxVI_Occurrence_RequiredItem) < 0) { + &vmPathName, esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (esxUtil_ParseDatastorePath(vmPathName, &datastoreName, &directoryName, - &directoryAndFileName) < 0) { + &directoryAndFileName) < 0) goto cleanup; - } virBufferAsprintf(&buffer, "%s://%s:%d/folder/", priv->parsedUri->transport, domain->conn->uri->server, domain->conn->uri->port); @@ -2818,9 +2667,8 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) url = virBufferContentAndReset(&buffer); - if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0) { + if (esxVI_CURL_Download(priv->primary->curl, url, &vmx, 0, NULL) < 0) goto cleanup; - } data.ctx = priv->primary; @@ -2842,17 +2690,15 @@ esxDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) def = virVMXParseConfig(&ctx, priv->xmlopt, vmx); if (def) { - if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { + if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) def->id = id; - } xml = virDomainDefFormat(def, flags); } cleanup: - if (!url) { + if (!url) virBufferFreeAndReset(&buffer); - } esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); @@ -2900,9 +2746,8 @@ esxConnectDomainXMLFromNative(virConnectPtr conn, const char *nativeFormat, def = virVMXParseConfig(&ctx, priv->xmlopt, nativeConfig); - if (def) { + if (def) xml = virDomainDefFormat(def, VIR_DOMAIN_XML_INACTIVE); - } virDomainDefFree(def); @@ -2936,17 +2781,15 @@ esxConnectDomainXMLToNative(virConnectPtr conn, const char *nativeFormat, virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion (priv->primary->productVersion); - if (virtualHW_version < 0) { + if (virtualHW_version < 0) return NULL; - } def = virDomainDefParseString(domainXml, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); - if (!def) { + if (!def) return NULL; - } data.ctx = priv->primary; data.datastorePathWithoutFileName = NULL; @@ -2977,54 +2820,46 @@ esxConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxname int count = 0; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "name\0" "runtime.powerState\0") < 0 || esxVI_LookupVirtualMachineList(priv->primary, propertyNameList, - &virtualMachineList) < 0) { + &virtualMachineList) < 0) goto cleanup; - } for (virtualMachine = virtualMachineList; virtualMachine; virtualMachine = virtualMachine->_next) { if (esxVI_GetVirtualMachinePowerState(virtualMachine, - &powerState) < 0) { + &powerState) < 0) goto cleanup; - } - if (powerState == esxVI_VirtualMachinePowerState_PoweredOn) { + if (powerState == esxVI_VirtualMachinePowerState_PoweredOn) continue; - } names[count] = NULL; if (esxVI_GetVirtualMachineIdentity(virtualMachine, NULL, &names[count], - NULL) < 0) { + NULL) < 0) goto cleanup; - } ++count; - if (count >= maxnames) { + if (count >= maxnames) break; - } } success = true; cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -3042,9 +2877,8 @@ esxConnectNumOfDefinedDomains(virConnectPtr conn) { esxPrivate *priv = conn->privateData; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return esxVI_LookupNumberOfDomainsByPowerState (priv->primary, esxVI_VirtualMachinePowerState_PoweredOn, true); @@ -3067,9 +2901,8 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || @@ -3077,9 +2910,8 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) (priv->primary, domain->uuid, propertyNameList, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0 || - esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0) { + esxVI_GetVirtualMachineIdentity(virtualMachine, &id, NULL, NULL) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -3092,9 +2924,8 @@ esxDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not start domain: %s"), @@ -3153,32 +2984,28 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) memset(&data, 0, sizeof(data)); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } /* Parse domain XML */ def = virDomainDefParseString(xml, priv->caps, priv->xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); - if (!def) { + if (!def) return NULL; - } /* Check if an existing domain should be edited */ if (esxVI_LookupVirtualMachineByUuid(priv->primary, def->uuid, NULL, &virtualMachine, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!virtualMachine && esxVI_LookupVirtualMachineByName(priv->primary, def->name, NULL, &virtualMachine, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (virtualMachine) { /* FIXME */ @@ -3192,9 +3019,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) virtualHW_version = esxVI_ProductVersionToDefaultVirtualHWVersion (priv->primary->productVersion); - if (virtualHW_version < 0) { + if (virtualHW_version < 0) goto cleanup; - } data.ctx = priv->primary; data.datastorePathWithoutFileName = NULL; @@ -3206,9 +3032,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) vmx = virVMXFormatConfig(&ctx, priv->xmlopt, def, virtualHW_version); - if (!vmx) { + if (!vmx) goto cleanup; - } /* * Build VMX datastore URL. Use the source of the first file-based harddisk @@ -3248,9 +3073,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) } if (esxUtil_ParseDatastorePath(src, &datastoreName, &directoryName, - NULL) < 0) { + NULL) < 0) goto cleanup; - } if (! virFileHasSuffix(src, ".vmdk")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3269,9 +3093,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) escapedName = esxUtil_EscapeDatastoreItem(def->name); - if (!escapedName) { + if (!escapedName) goto cleanup; - } virBufferURIEncodeString(&buffer, escapedName); virBufferAddLit(&buffer, ".vmx?dcPath="); @@ -3290,9 +3113,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) /* Upload VMX file */ VIR_DEBUG("Uploading .vmx config, url='%s' vmx='%s'", url, vmx); - if (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0) { + if (esxVI_CURL_Upload(priv->primary->curl, url, vmx) < 0) goto cleanup; - } /* Register the domain */ if (directoryName) { @@ -3313,9 +3135,8 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) esxVI_WaitForTaskCompletion(priv->primary, task, def->uuid, esxVI_Occurrence_OptionalItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not define domain: %s"), @@ -3325,16 +3146,14 @@ esxDomainDefineXML(virConnectPtr conn, const char *xml) domain = virGetDomain(conn, def->name, def->uuid); - if (domain) { + if (domain) domain->id = -1; - } /* FIXME: Add proper rollback in case of an error */ cleanup: - if (!url) { + if (!url) virBufferFreeAndReset(&buffer); - } virDomainDefFree(def); VIR_FREE(vmx); @@ -3371,24 +3190,21 @@ esxDomainUndefineFlags(virDomainPtr domain, * ESX, so we can trivially ignore that flag. */ virCheckFlags(VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA, -1); - if (priv->vCenter) { + if (priv->vCenter) ctx = priv->vCenter; - } else { + else ctx = priv->host; - } - if (esxVI_EnsureSession(ctx) < 0) { + if (esxVI_EnsureSession(ctx) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuid(ctx, domain->uuid, propertyNameList, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } if (powerState != esxVI_VirtualMachinePowerState_Suspended && powerState != esxVI_VirtualMachinePowerState_PoweredOff) { @@ -3397,9 +3213,8 @@ esxDomainUndefineFlags(virDomainPtr domain, goto cleanup; } - if (esxVI_UnregisterVM(ctx, virtualMachine->obj) < 0) { + if (esxVI_UnregisterVM(ctx, virtualMachine->obj) < 0) goto cleanup; - } result = 0; @@ -3430,14 +3245,12 @@ esxDomainGetAutostart(virDomainPtr domain, int *autostart) *autostart = 0; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } /* Check general autostart config */ - if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) { + if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) goto cleanup; - } if (defaults->enabled != esxVI_Boolean_True) { /* Autostart is disabled in general, exit early here */ @@ -3446,9 +3259,8 @@ esxDomainGetAutostart(virDomainPtr domain, int *autostart) } /* Check specific autostart config */ - if (esxVI_LookupAutoStartPowerInfoList(priv->primary, &powerInfoList) < 0) { + if (esxVI_LookupAutoStartPowerInfoList(priv->primary, &powerInfoList) < 0) goto cleanup; - } if (!powerInfoList) { /* powerInfo list is empty, exit early here */ @@ -3458,16 +3270,14 @@ esxDomainGetAutostart(virDomainPtr domain, int *autostart) if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, NULL, &virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (powerInfo = powerInfoList; powerInfo; powerInfo = powerInfo->_next) { if (STREQ(powerInfo->key->value, virtualMachine->obj->value)) { - if (STRCASEEQ(powerInfo->startAction, "powerOn")) { + if (STRCASEEQ(powerInfo->startAction, "powerOn")) *autostart = 1; - } break; } @@ -3498,16 +3308,14 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart) esxVI_AutoStartPowerInfo *powerInfo = NULL; esxVI_AutoStartPowerInfo *newPowerInfo = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, NULL, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_HostAutoStartManagerConfig_Alloc(&spec) < 0) { + esxVI_HostAutoStartManagerConfig_Alloc(&spec) < 0) goto cleanup; - } if (autostart) { /* @@ -3516,9 +3324,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart) * autostart. If it's enabled then the autostart behavior depends on * the per-domain autostart config. */ - if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) { + if (esxVI_LookupAutoStartDefaults(priv->primary, &defaults) < 0) goto cleanup; - } if (defaults->enabled != esxVI_Boolean_True) { /* @@ -3528,9 +3335,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart) * behavior of other domains. */ if (esxVI_LookupAutoStartPowerInfoList(priv->primary, - &powerInfoList) < 0) { + &powerInfoList) < 0) goto cleanup; - } for (powerInfo = powerInfoList; powerInfo; powerInfo = powerInfo->_next) { @@ -3543,9 +3349,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart) } /* Enable autostart in general */ - if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0) { + if (esxVI_AutoStartDefaults_Alloc(&spec->defaults) < 0) goto cleanup; - } spec->defaults->enabled = esxVI_Boolean_True; } @@ -3554,9 +3359,8 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart) if (esxVI_AutoStartPowerInfo_Alloc(&newPowerInfo) < 0 || esxVI_Int_Alloc(&newPowerInfo->startOrder) < 0 || esxVI_Int_Alloc(&newPowerInfo->startDelay) < 0 || - esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0) { + esxVI_Int_Alloc(&newPowerInfo->stopDelay) < 0) goto cleanup; - } newPowerInfo->key = virtualMachine->obj; newPowerInfo->startOrder->value = -1; /* no specific start order */ @@ -3567,18 +3371,16 @@ esxDomainSetAutostart(virDomainPtr domain, int autostart) newPowerInfo->stopAction = (char *)"none"; if (esxVI_AutoStartPowerInfo_AppendToList(&spec->powerInfo, - newPowerInfo) < 0) { + newPowerInfo) < 0) goto cleanup; - } newPowerInfo = NULL; if (esxVI_ReconfigureAutostart (priv->primary, priv->primary->hostSystem->configManager->autoStartManager, - spec) < 0) { + spec) < 0) goto cleanup; - } result = 0; @@ -3639,9 +3441,8 @@ esxDomainGetSchedulerType(virDomainPtr domain ATTRIBUTE_UNUSED, int *nparams) if (VIR_STRDUP(type, "allocation") < 0) return NULL; - if (nparams) { + if (nparams) *nparams = 3; /* reservation, limit, shares */ - } return type; } @@ -3664,9 +3465,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain, virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueListToList(&propertyNameList, "config.cpuAllocation.reservation\0" @@ -3674,9 +3474,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain, "config.cpuAllocation.shares\0") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = virtualMachine->propSet; dynamicProperty && mask != 7 && i < 3 && i < *nparams; @@ -3684,9 +3483,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain, if (STREQ(dynamicProperty->name, "config.cpuAllocation.reservation") && ! (mask & (1 << 0))) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } if (virTypedParameterAssign(¶ms[i], VIR_DOMAIN_SCHEDULER_RESERVATION, VIR_TYPED_PARAM_LLONG, @@ -3698,9 +3496,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain, "config.cpuAllocation.limit") && ! (mask & (1 << 1))) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } if (virTypedParameterAssign(¶ms[i], VIR_DOMAIN_SCHEDULER_LIMIT, VIR_TYPED_PARAM_LLONG, @@ -3716,9 +3513,8 @@ esxDomainGetSchedulerParametersFlags(virDomainPtr domain, VIR_TYPED_PARAM_INT, 0) < 0) goto cleanup; if (esxVI_SharesInfo_CastFromAnyType(dynamicProperty->val, - &sharesInfo) < 0) { + &sharesInfo) < 0) goto cleanup; - } switch (sharesInfo->level) { case esxVI_SharesLevel_Custom: @@ -3798,23 +3594,20 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain, NULL) < 0) return -1; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->primary, domain->uuid, NULL, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 || - esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0) { + esxVI_ResourceAllocationInfo_Alloc(&spec->cpuAllocation) < 0) goto cleanup; - } for (i = 0; i < nparams; ++i) { if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_RESERVATION)) { - if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0) { + if (esxVI_Long_Alloc(&spec->cpuAllocation->reservation) < 0) goto cleanup; - } if (params[i].value.l < 0) { virReportError(VIR_ERR_INVALID_ARG, @@ -3825,9 +3618,8 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain, spec->cpuAllocation->reservation->value = params[i].value.l; } else if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_LIMIT)) { - if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0) { + if (esxVI_Long_Alloc(&spec->cpuAllocation->limit) < 0) goto cleanup; - } if (params[i].value.l < -1) { virReportError(VIR_ERR_INVALID_ARG, @@ -3840,9 +3632,8 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain, spec->cpuAllocation->limit->value = params[i].value.l; } else if (STREQ(params[i].field, VIR_DOMAIN_SCHEDULER_SHARES)) { if (esxVI_SharesInfo_Alloc(&sharesInfo) < 0 || - esxVI_Int_Alloc(&sharesInfo->shares) < 0) { + esxVI_Int_Alloc(&sharesInfo->shares) < 0) goto cleanup; - } spec->cpuAllocation->shares = sharesInfo; sharesInfo = NULL; @@ -3885,9 +3676,8 @@ esxDomainSetSchedulerParametersFlags(virDomainPtr domain, esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3986,9 +3776,8 @@ esxDomainMigratePerform(virDomainPtr domain, return -1; } - if (esxVI_EnsureSession(priv->vCenter) < 0) { + if (esxVI_EnsureSession(priv->vCenter) < 0) return -1; - } /* Parse migration URI */ if (!(parsedUri = virURIParse(uri))) @@ -4029,16 +3818,14 @@ esxDomainMigratePerform(virDomainPtr domain, /* Lookup VirtualMachine */ if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->vCenter, domain->uuid, NULL, &virtualMachine, - priv->parsedUri->autoAnswer) < 0) { + priv->parsedUri->autoAnswer) < 0) goto cleanup; - } /* Validate the purposed migration */ if (esxVI_ValidateMigration(priv->vCenter, virtualMachine->obj, esxVI_VirtualMachinePowerState_Undefined, NULL, - &resourcePool, &hostSystem, &eventList) < 0) { + &resourcePool, &hostSystem, &eventList) < 0) goto cleanup; - } if (eventList) { /* @@ -4067,9 +3854,8 @@ esxDomainMigratePerform(virDomainPtr domain, esxVI_WaitForTaskCompletion(priv->vCenter, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4117,9 +3903,8 @@ esxNodeGetFreeMemory(virConnectPtr conn) esxVI_DynamicProperty *dynamicProperty = NULL; esxVI_ResourcePoolResourceUsage *resourcePoolResourceUsage = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return 0; - } /* Get memory usage of resource pool */ if (esxVI_String_AppendValueToList(&propertyNameList, @@ -4128,17 +3913,15 @@ esxNodeGetFreeMemory(virConnectPtr conn) priv->primary->computeResource->resourcePool, "ResourcePool", propertyNameList, &resourcePool, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = resourcePool->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "runtime.memory")) { if (esxVI_ResourcePoolResourceUsage_CastFromAnyType - (dynamicProperty->val, &resourcePoolResourceUsage) < 0) { + (dynamicProperty->val, &resourcePoolResourceUsage) < 0) goto cleanup; - } break; } else { @@ -4169,11 +3952,10 @@ esxConnectIsEncrypted(virConnectPtr conn) { esxPrivate *priv = conn->privateData; - if (STRCASEEQ(priv->parsedUri->transport, "https")) { + if (STRCASEEQ(priv->parsedUri->transport, "https")) return 1; - } else { + else return 0; - } } @@ -4183,11 +3965,10 @@ esxConnectIsSecure(virConnectPtr conn) { esxPrivate *priv = conn->privateData; - if (STRCASEEQ(priv->parsedUri->transport, "https")) { + if (STRCASEEQ(priv->parsedUri->transport, "https")) return 1; - } else { + else return 0; - } } @@ -4218,24 +3999,21 @@ esxDomainIsActive(virDomainPtr domain) esxVI_String *propertyNameList = NULL; esxVI_VirtualMachinePowerState powerState; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineByUuid(priv->primary, domain->uuid, propertyNameList, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) { + esxVI_GetVirtualMachinePowerState(virtualMachine, &powerState) < 0) goto cleanup; - } - if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) { + if (powerState != esxVI_VirtualMachinePowerState_PoweredOff) result = 1; - } else { + else result = 0; - } cleanup: esxVI_ObjectContent_Free(&virtualMachine); @@ -4322,16 +4100,14 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE | VIR_DOMAIN_SNAPSHOT_CREATE_NO_METADATA, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } def = virDomainSnapshotDefParseString(xmlDesc, priv->caps, priv->xmlopt, 0, 0); - if (!def) { + if (!def) return NULL; - } if (def->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", @@ -4346,9 +4122,8 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, def->name, &snapshotTree, NULL, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (snapshotTree) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -4364,9 +4139,8 @@ esxDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not create snapshot: %s"), @@ -4404,26 +4178,23 @@ esxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, memset(&def, 0, sizeof(def)); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, &snapshotTree, &snapshotTreeParent, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } def.name = snapshot->name; def.description = snapshotTree->description; def.parent = snapshotTreeParent ? snapshotTreeParent->name : NULL; if (esxVI_DateTime_ConvertToCalendarTime(snapshotTree->createTime, - &def.creationTime) < 0) { + &def.creationTime) < 0) goto cleanup; - } def.state = esxVI_VirtualMachinePowerState_ConvertToLibvirt (snapshotTree->state); @@ -4456,18 +4227,16 @@ esxDomainSnapshotNum(virDomainPtr domain, unsigned int flags) recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) == 0; leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } /* ESX snapshots do not require libvirt to maintain any metadata. */ if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) return 0; if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid, - &rootSnapshotTreeList) < 0) { + &rootSnapshotTreeList) < 0) return -1; - } count = esxVI_GetNumberOfSnapshotTrees(rootSnapshotTreeList, recurse, leaves); @@ -4501,18 +4270,15 @@ esxDomainSnapshotListNames(virDomainPtr domain, char **names, int nameslen, return -1; } - if (nameslen == 0 || (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA)) { + if (nameslen == 0 || (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA)) return 0; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid, - &rootSnapshotTreeList) < 0) { + &rootSnapshotTreeList) < 0) return -1; - } result = esxVI_GetSnapshotTreeNames(rootSnapshotTreeList, names, nameslen, recurse, leaves); @@ -4541,17 +4307,15 @@ esxDomainSnapshotNumChildren(virDomainSnapshotPtr snapshot, unsigned int flags) recurse = (flags & VIR_DOMAIN_SNAPSHOT_LIST_DESCENDANTS) != 0; leaves = (flags & VIR_DOMAIN_SNAPSHOT_LIST_LEAVES) != 0; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotTreeList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, snapshot->name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* ESX snapshots do not require libvirt to maintain any metadata. */ if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) { @@ -4594,21 +4358,18 @@ esxDomainSnapshotListChildrenNames(virDomainSnapshotPtr snapshot, return -1; } - if (nameslen == 0) { + if (nameslen == 0) return 0; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotTreeList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, snapshot->name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* ESX snapshots do not require libvirt to maintain any metadata. */ if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) { @@ -4638,17 +4399,15 @@ esxDomainSnapshotLookupByName(virDomainPtr domain, const char *name, virCheckFlags(0, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, domain->uuid, &rootSnapshotTreeList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotTreeList, name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } snapshot = virGetDomainSnapshot(domain, name); @@ -4668,15 +4427,13 @@ esxDomainHasCurrentSnapshot(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid, ¤tSnapshotTree, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) return -1; - } if (currentSnapshotTree) { esxVI_VirtualMachineSnapshotTree_Free(¤tSnapshotTree); @@ -4699,17 +4456,15 @@ esxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, unsigned int flags) virCheckFlags(0, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, &snapshotTree, &snapshotTreeParent, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (!snapshotTreeParent) { virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, @@ -4737,15 +4492,13 @@ esxDomainSnapshotCurrent(virDomainPtr domain, unsigned int flags) virCheckFlags(0, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (esxVI_LookupCurrentSnapshotTree(priv->primary, domain->uuid, ¤tSnapshotTree, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return NULL; - } snapshot = virGetDomainSnapshot(domain, currentSnapshotTree->name); @@ -4766,24 +4519,21 @@ esxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } /* Check that snapshot exists. */ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (esxVI_LookupCurrentSnapshotTree(priv->primary, snapshot->domain->uuid, ¤tSnapshotTree, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } ret = STREQ(snapshot->name, currentSnapshotTree->name); @@ -4804,18 +4554,16 @@ esxDomainSnapshotHasMetadata(virDomainSnapshotPtr snapshot, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } /* Check that snapshot exists. If so, there is no metadata. */ if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } ret = 0; @@ -4838,26 +4586,23 @@ esxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, unsigned int flags) virCheckFlags(0, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (esxVI_RevertToSnapshot_Task(priv->primary, snapshotTree->snapshot, NULL, esxVI_Boolean_Undefined, &task) < 0 || esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4893,21 +4638,18 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) virCheckFlags(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN | VIR_DOMAIN_SNAPSHOT_DELETE_METADATA_ONLY, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) { + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN) removeChildren = esxVI_Boolean_True; - } if (esxVI_LookupRootSnapshotTreeList(priv->primary, snapshot->domain->uuid, &rootSnapshotList) < 0 || esxVI_GetSnapshotTreeByName(rootSnapshotList, snapshot->name, &snapshotTree, NULL, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* ESX snapshots do not require any libvirt metadata, making this * flag trivial once we know we have a valid snapshot. */ @@ -4921,9 +4663,8 @@ esxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) esxVI_WaitForTaskCompletion(priv->primary, task, snapshot->domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4964,23 +4705,20 @@ esxDomainSetMemoryParameters(virDomainPtr domain, virTypedParameterPtr params, NULL) < 0) return -1; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_LookupVirtualMachineByUuidAndPrepareForTask (priv->primary, domain->uuid, NULL, &virtualMachine, priv->parsedUri->autoAnswer) < 0 || esxVI_VirtualMachineConfigSpec_Alloc(&spec) < 0 || - esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0) { + esxVI_ResourceAllocationInfo_Alloc(&spec->memoryAllocation) < 0) goto cleanup; - } for (i = 0; i < nparams; ++i) { if (STREQ(params[i].field, VIR_DOMAIN_MEMORY_MIN_GUARANTEE)) { - if (esxVI_Long_Alloc(&spec->memoryAllocation->reservation) < 0) { + if (esxVI_Long_Alloc(&spec->memoryAllocation->reservation) < 0) goto cleanup; - } spec->memoryAllocation->reservation->value = VIR_DIV_UP(params[i].value.ul, 1024); /* Scale from kilobytes to megabytes */ @@ -4992,9 +4730,8 @@ esxDomainSetMemoryParameters(virDomainPtr domain, virTypedParameterPtr params, esxVI_WaitForTaskCompletion(priv->primary, task, domain->uuid, esxVI_Occurrence_RequiredItem, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -5033,9 +4770,8 @@ esxDomainGetMemoryParameters(virDomainPtr domain, virTypedParameterPtr params, return 0; } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } if (esxVI_String_AppendValueToList (&propertyNameList, "config.memoryAllocation.reservation") < 0 || @@ -5043,9 +4779,8 @@ esxDomainGetMemoryParameters(virDomainPtr domain, virTypedParameterPtr params, propertyNameList, &virtualMachine, esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetLong(virtualMachine, "config.memoryAllocation.reservation", - &reservation, esxVI_Occurrence_RequiredItem) < 0) { + &reservation, esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* Scale from megabytes to kilobytes */ if (virTypedParameterAssign(params, VIR_DOMAIN_MEMORY_MIN_GUARANTEE, @@ -5116,15 +4851,13 @@ esxConnectListAllDomains(virConnectPtr conn, /* check system default autostart value */ if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_AUTOSTART)) { if (esxVI_LookupAutoStartDefaults(priv->primary, - &autoStartDefaults) < 0) { + &autoStartDefaults) < 0) goto cleanup; - } if (autoStartDefaults->enabled == esxVI_Boolean_True) { if (esxVI_LookupAutoStartPowerInfoList(priv->primary, - &powerInfoList) < 0) { + &powerInfoList) < 0) goto cleanup; - } } } @@ -5136,9 +4869,8 @@ esxConnectListAllDomains(virConnectPtr conn, if (esxVI_String_AppendValueListToList(&propertyNameList, "configStatus\0" "name\0" - "config.uuid\0") < 0) { + "config.uuid\0") < 0) goto cleanup; - } } needPowerState = MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_ACTIVE) || @@ -5147,9 +4879,8 @@ esxConnectListAllDomains(virConnectPtr conn, if (needPowerState) { if (esxVI_String_AppendValueToList(&propertyNameList, - "runtime.powerState") < 0) { + "runtime.powerState") < 0) goto cleanup; - } } if (esxVI_LookupVirtualMachineList(priv->primary, propertyNameList, @@ -5168,16 +4899,14 @@ esxConnectListAllDomains(virConnectPtr conn, VIR_FREE(name); if (esxVI_GetVirtualMachineIdentity(virtualMachine, &id, - &name, uuid) < 0) { + &name, uuid) < 0) goto cleanup; - } } if (needPowerState) { if (esxVI_GetVirtualMachinePowerState(virtualMachine, - &powerState) < 0) { + &powerState) < 0) goto cleanup; - } } /* filter by active state */ @@ -5193,9 +4922,8 @@ esxConnectListAllDomains(virConnectPtr conn, esxVI_VirtualMachineSnapshotTree_Free(&rootSnapshotTreeList); if (esxVI_LookupRootSnapshotTreeList(priv->primary, uuid, - &rootSnapshotTreeList) < 0) { + &rootSnapshotTreeList) < 0) goto cleanup; - } if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) && rootSnapshotTreeList) || @@ -5272,9 +5000,8 @@ esxConnectListAllDomains(virConnectPtr conn, cleanup: if (doms) { - for (id = 0; id < count; id++) { + for (id = 0; id < count; id++) virDomainFree(doms[id]); - } VIR_FREE(doms); } @@ -5382,9 +5109,8 @@ esxRegister(void) esxStorageRegister() < 0 || esxDeviceRegister() < 0 || esxSecretRegister() < 0 || - esxNWFilterRegister() < 0) { + esxNWFilterRegister() < 0) return -1; - } return 0; } diff --git a/src/esx/esx_interface_driver.c b/src/esx/esx_interface_driver.c index ecc5313..14a2ea1 100644 --- a/src/esx/esx_interface_driver.c +++ b/src/esx/esx_interface_driver.c @@ -46,9 +46,8 @@ esxInterfaceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_ESX) { + if (conn->driver->no != VIR_DRV_ESX) return VIR_DRV_OPEN_DECLINED; - } conn->interfacePrivateData = conn->privateData; @@ -76,14 +75,12 @@ esxConnectNumOfInterfaces(virConnectPtr conn) int count = 0; if (esxVI_EnsureSession(priv->primary) < 0 || - esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) { + esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) return -1; - } for (physicalNic = physicalNicList; physicalNic; - physicalNic = physicalNic->_next) { + physicalNic = physicalNic->_next) ++count; - } esxVI_PhysicalNic_Free(&physicalNicList); @@ -102,14 +99,12 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames) int count = 0; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } if (esxVI_EnsureSession(priv->primary) < 0 || - esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) { + esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) return -1; - } for (physicalNic = physicalNicList; physicalNic; physicalNic = physicalNic->_next) { @@ -123,9 +118,8 @@ esxConnectListInterfaces(virConnectPtr conn, char **const names, int maxnames) cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -166,9 +160,8 @@ esxInterfaceLookupByName(virConnectPtr conn, const char *name) if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupPhysicalNicByMACAddress(priv->primary, name, &physicalNic, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return NULL; - } iface = virGetInterface(conn, physicalNic->device, physicalNic->mac); @@ -188,9 +181,8 @@ esxInterfaceLookupByMACString(virConnectPtr conn, const char *mac) if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupPhysicalNicByMACAddress(priv->primary, mac, &physicalNic, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return NULL; - } iface = virGetInterface(conn, physicalNic->device, physicalNic->mac); @@ -225,9 +217,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupPhysicalNicByMACAddress(priv->primary, iface->mac, &physicalNic, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return NULL; - } def.type = VIR_INTERFACE_TYPE_ETHERNET; def.name = physicalNic->device; @@ -238,16 +229,14 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) if (physicalNic->spec->ip) { protocol.family = (char *)"ipv4"; - if (physicalNic->spec->ip->dhcp == esxVI_Boolean_True) { + if (physicalNic->spec->ip->dhcp == esxVI_Boolean_True) protocol.dhcp = 1; - } if (physicalNic->spec->ip->ipAddress && physicalNic->spec->ip->subnetMask && strlen(physicalNic->spec->ip->ipAddress) > 0 && - strlen(physicalNic->spec->ip->subnetMask) > 0) { + strlen(physicalNic->spec->ip->subnetMask) > 0) hasAddress = true; - } if (protocol.dhcp || hasAddress) { protocols = &protocol; @@ -262,9 +251,8 @@ esxInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags) protocol.ips = &ips; if (virSocketAddrParseIPv4(&socketAddress, - physicalNic->spec->ip->subnetMask) < 0) { + physicalNic->spec->ip->subnetMask) < 0) goto cleanup; - } ip.address = physicalNic->spec->ip->ipAddress; ip.prefix = virSocketAddrGetNumNetmaskBits(&socketAddress); diff --git a/src/esx/esx_network_driver.c b/src/esx/esx_network_driver.c index c6f325c..02d61a6 100644 --- a/src/esx/esx_network_driver.c +++ b/src/esx/esx_network_driver.c @@ -52,9 +52,8 @@ esxNetworkOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_ESX) { + if (conn->driver->no != VIR_DRV_ESX) return VIR_DRV_OPEN_DECLINED; - } conn->networkPrivateData = conn->privateData; @@ -83,14 +82,12 @@ esxConnectNumOfNetworks(virConnectPtr conn) if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupHostVirtualSwitchList(priv->primary, - &hostVirtualSwitchList) < 0) { + &hostVirtualSwitchList) < 0) return -1; - } for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch; - hostVirtualSwitch = hostVirtualSwitch->_next) { + hostVirtualSwitch = hostVirtualSwitch->_next) ++count; - } esxVI_HostVirtualSwitch_Free(&hostVirtualSwitchList); @@ -109,15 +106,13 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) int count = 0; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupHostVirtualSwitchList(priv->primary, - &hostVirtualSwitchList) < 0) { + &hostVirtualSwitchList) < 0) return -1; - } for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch; hostVirtualSwitch = hostVirtualSwitch->_next) { @@ -131,9 +126,8 @@ esxConnectListNetworks(virConnectPtr conn, char **const names, int maxnames) cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -177,17 +171,15 @@ esxNetworkLookupByUUID(virConnectPtr conn, const unsigned char *uuid) if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupHostVirtualSwitchList(priv->primary, - &hostVirtualSwitchList) < 0) { + &hostVirtualSwitchList) < 0) return NULL; - } for (hostVirtualSwitch = hostVirtualSwitchList; hostVirtualSwitch; hostVirtualSwitch = hostVirtualSwitch->_next) { md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5); - if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) { + if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) break; - } } if (!hostVirtualSwitch) { @@ -221,9 +213,8 @@ esxNetworkLookupByName(virConnectPtr conn, const char *name) if (esxVI_EnsureSession(priv->primary) < 0 || esxVI_LookupHostVirtualSwitchByName(priv->primary, name, &hostVirtualSwitch, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return NULL; - } /* * HostVirtualSwitch doesn't have a UUID, but we can use the key property @@ -265,38 +256,33 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth, } if (bandwidth->in->average == 0 && bandwidth->in->peak == 0 && - bandwidth->in->burst == 0) { + bandwidth->in->burst == 0) return 0; - } - if (esxVI_HostNetworkTrafficShapingPolicy_Alloc(shapingPolicy) < 0) { + if (esxVI_HostNetworkTrafficShapingPolicy_Alloc(shapingPolicy) < 0) goto cleanup; - } (*shapingPolicy)->enabled = esxVI_Boolean_True; if (bandwidth->in->average > 0) { - if (esxVI_Long_Alloc(&(*shapingPolicy)->averageBandwidth) < 0) { + if (esxVI_Long_Alloc(&(*shapingPolicy)->averageBandwidth) < 0) goto cleanup; - } /* Scale kilobytes per second to bits per second */ (*shapingPolicy)->averageBandwidth->value = bandwidth->in->average * 8 * 1000; } if (bandwidth->in->peak > 0) { - if (esxVI_Long_Alloc(&(*shapingPolicy)->peakBandwidth) < 0) { + if (esxVI_Long_Alloc(&(*shapingPolicy)->peakBandwidth) < 0) goto cleanup; - } /* Scale kilobytes per second to bits per second */ (*shapingPolicy)->peakBandwidth->value = bandwidth->in->peak * 8 * 1000; } if (bandwidth->in->burst > 0) { - if (esxVI_Long_Alloc(&(*shapingPolicy)->burstSize) < 0) { + if (esxVI_Long_Alloc(&(*shapingPolicy)->burstSize) < 0) goto cleanup; - } /* Scale kilobytes to bytes */ (*shapingPolicy)->burstSize->value = bandwidth->in->burst * 1024; @@ -305,9 +291,8 @@ esxBandwidthToShapingPolicy(virNetDevBandwidthPtr bandwidth, result = 0; cleanup: - if (result < 0) { + if (result < 0) esxVI_HostNetworkTrafficShapingPolicy_Free(shapingPolicy); - } return result; } @@ -332,23 +317,20 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) unsigned char md5[MD5_DIGEST_SIZE]; /* MD5_DIGEST_SIZE = VIR_UUID_BUFLEN = 16 */ - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } /* Parse network XML */ def = virNetworkDefParseString(xml); - if (!def) { + if (!def) return NULL; - } /* Check if an existing HostVirtualSwitch should be edited */ if (esxVI_LookupHostVirtualSwitchByName(priv->primary, def->name, &hostVirtualSwitch, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (hostVirtualSwitch) { /* FIXME */ @@ -376,9 +358,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) /* Verify that specified HostPortGroups don't exist already */ if (def->nPortGroups > 0) { - if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) { + if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) goto cleanup; - } for (i = 0; i < def->nPortGroups; ++i) { for (hostPortGroup = hostPortGroupList; hostPortGroup; @@ -395,23 +376,20 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) /* Create HostVirtualSwitch */ if (esxVI_HostVirtualSwitchSpec_Alloc(&hostVirtualSwitchSpec) < 0 || - esxVI_Int_Alloc(&hostVirtualSwitchSpec->numPorts) < 0) { + esxVI_Int_Alloc(&hostVirtualSwitchSpec->numPorts) < 0) goto cleanup; - } if (def->forward.type != VIR_NETWORK_FORWARD_NONE && def->forward.nifs > 0) { if (esxVI_HostVirtualSwitchBondBridge_Alloc - (&hostVirtualSwitchBondBridge) < 0) { + (&hostVirtualSwitchBondBridge) < 0) goto cleanup; - } hostVirtualSwitchSpec->bridge = (esxVI_HostVirtualSwitchBridge *)hostVirtualSwitchBondBridge; /* Lookup PhysicalNic list and match by name to get key */ - if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) { + if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) goto cleanup; - } for (i = 0; i < def->forward.nifs; ++i) { bool found = false; @@ -430,9 +408,8 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) if (STREQ(def->forward.ifs[i].device.dev, physicalNic->device)) { if (esxVI_String_AppendValueToList (&hostVirtualSwitchBondBridge->nicDevice, - physicalNic->key) < 0) { + physicalNic->key) < 0) goto cleanup; - } found = true; break; @@ -451,23 +428,20 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) hostVirtualSwitchSpec->numPorts->value = 128; if (def->bandwidth) { - if (esxVI_HostNetworkPolicy_Alloc(&hostVirtualSwitchSpec->policy) < 0) { + if (esxVI_HostNetworkPolicy_Alloc(&hostVirtualSwitchSpec->policy) < 0) goto cleanup; - } if (esxBandwidthToShapingPolicy (def->bandwidth, - &hostVirtualSwitchSpec->policy->shapingPolicy) < 0) { + &hostVirtualSwitchSpec->policy->shapingPolicy) < 0) goto cleanup; - } } if (esxVI_AddVirtualSwitch (priv->primary, priv->primary->hostSystem->configManager->networkSystem, - def->name, hostVirtualSwitchSpec) < 0) { + def->name, hostVirtualSwitchSpec) < 0) goto cleanup; - } /* Create HostPortGroup(s) */ for (i = 0; i < def->nPortGroups; ++i) { @@ -477,34 +451,30 @@ esxNetworkDefineXML(virConnectPtr conn, const char *xml) esxVI_HostNetworkPolicy_Alloc(&hostPortGroupSpec->policy) < 0 || esxVI_Int_Alloc(&hostPortGroupSpec->vlanId) < 0 || VIR_STRDUP(hostPortGroupSpec->name, def->portGroups[i].name) < 0 || - VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0) { + VIR_STRDUP(hostPortGroupSpec->vswitchName, def->name) < 0) goto cleanup; - } hostPortGroupSpec->vlanId->value = 0; if (def->portGroups[i].bandwidth) { if (esxBandwidthToShapingPolicy (def->portGroups[i].bandwidth, - &hostPortGroupSpec->policy->shapingPolicy) < 0) { + &hostPortGroupSpec->policy->shapingPolicy) < 0) goto cleanup; - } } if (esxVI_AddPortGroup (priv->primary, priv->primary->hostSystem->configManager->networkSystem, - hostPortGroupSpec) < 0) { + hostPortGroupSpec) < 0) goto cleanup; - } } /* Lookup created HostVirtualSwitch to get the UUID */ if (esxVI_LookupHostVirtualSwitchByName(priv->primary, def->name, &hostVirtualSwitch, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), md5); @@ -534,17 +504,15 @@ esxNetworkUndefine(virNetworkPtr network) esxVI_HostPortGroup *hostPortGroup = NULL; esxVI_HostPortGroupPort *hostPortGroupPort = NULL; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } /* Lookup HostVirtualSwitch and HostPortGroup list*/ if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network->name, &hostVirtualSwitch, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) { + esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) goto cleanup; - } /* Verify that the HostVirtualSwitch is connected to virtual machines only */ for (hostPortGroupKey = hostVirtualSwitch->portgroup; @@ -589,9 +557,8 @@ esxNetworkUndefine(virNetworkPtr network) if (esxVI_RemovePortGroup (priv->primary, priv->primary->hostSystem->configManager->networkSystem, - hostPortGroup->spec->name) < 0) { + hostPortGroup->spec->name) < 0) goto cleanup; - } found = true; break; @@ -610,9 +577,8 @@ esxNetworkUndefine(virNetworkPtr network) if (esxVI_RemoveVirtualSwitch (priv->primary, priv->primary->hostSystem->configManager->networkSystem, - network->name) < 0) { + network->name) < 0) goto cleanup; - } result = 0; @@ -634,9 +600,8 @@ esxShapingPolicyToBandwidth(esxVI_HostNetworkTrafficShapingPolicy *shapingPolicy return -1; } - if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True) { + if (!shapingPolicy || shapingPolicy->enabled != esxVI_Boolean_True) return 0; - } if (VIR_ALLOC(*bandwidth) < 0 || VIR_ALLOC((*bandwidth)->in) < 0 || @@ -686,9 +651,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) esxVI_String *networkName = NULL; virNetworkDefPtr def; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } if (VIR_ALLOC(def) < 0) goto cleanup; @@ -696,9 +660,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) /* Lookup HostVirtualSwitch */ if (esxVI_LookupHostVirtualSwitchByName(priv->primary, network_->name, &hostVirtualSwitch, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } md5_buffer(hostVirtualSwitch->key, strlen(hostVirtualSwitch->key), def->uuid); @@ -711,9 +674,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) count = 0; for (physicalNicKey = hostVirtualSwitch->pnic; - physicalNicKey; physicalNicKey = physicalNicKey->_next) { + physicalNicKey; physicalNicKey = physicalNicKey->_next) ++count; - } if (count > 0) { def->forward.type = VIR_NETWORK_FORWARD_BRIDGE; @@ -722,9 +684,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) goto cleanup; /* Find PhysicalNic by key */ - if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) { + if (esxVI_LookupPhysicalNicList(priv->primary, &physicalNicList) < 0) goto cleanup; - } for (physicalNicKey = hostVirtualSwitch->pnic; physicalNicKey; physicalNicKey = physicalNicKey->_next) { @@ -759,9 +720,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) count = 0; for (hostPortGroupKey = hostVirtualSwitch->portgroup; - hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) { + hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) ++count; - } if (count > 0) { if (VIR_ALLOC_N(def->portGroups, count) < 0) @@ -770,24 +730,21 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) /* Lookup Network list and create name list */ if (esxVI_String_AppendValueToList(&propertyNameList, "name") < 0 || esxVI_LookupNetworkList(priv->primary, propertyNameList, - &networkList) < 0) { + &networkList) < 0) goto cleanup; - } for (network = networkList; network; network = network->_next) { char *tmp = NULL; if (esxVI_GetStringValue(network, "name", &tmp, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_String_AppendValueToList(&networkNameList, tmp) < 0) { + esxVI_String_AppendValueToList(&networkNameList, tmp) < 0) goto cleanup; - } } /* Find HostPortGroup by key */ - if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) { + if (esxVI_LookupHostPortGroupList(priv->primary, &hostPortGroupList) < 0) goto cleanup; - } for (hostPortGroupKey = hostVirtualSwitch->portgroup; hostPortGroupKey; hostPortGroupKey = hostPortGroupKey->_next) { @@ -835,9 +792,8 @@ esxNetworkGetXMLDesc(virNetworkPtr network_, unsigned int flags) if (hostVirtualSwitch->spec->policy) { if (esxShapingPolicyToBandwidth (hostVirtualSwitch->spec->policy->shapingPolicy, - &def->bandwidth) < 0) { + &def->bandwidth) < 0) goto cleanup; - } } xml = virNetworkDefFormat(def, flags); diff --git a/src/esx/esx_nwfilter_driver.c b/src/esx/esx_nwfilter_driver.c index 3cf70d0..5f0e747 100644 --- a/src/esx/esx_nwfilter_driver.c +++ b/src/esx/esx_nwfilter_driver.c @@ -43,9 +43,8 @@ esxNWFilterOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_ESX) { + if (conn->driver->no != VIR_DRV_ESX) return VIR_DRV_OPEN_DECLINED; - } conn->nwfilterPrivateData = conn->privateData; diff --git a/src/esx/esx_secret_driver.c b/src/esx/esx_secret_driver.c index 558cf07..745115a 100644 --- a/src/esx/esx_secret_driver.c +++ b/src/esx/esx_secret_driver.c @@ -41,9 +41,8 @@ esxSecretOpen(virConnectPtr conn, virConnectAuthPtr auth ATTRIBUTE_UNUSED, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_ESX) { + if (conn->driver->no != VIR_DRV_ESX) return VIR_DRV_OPEN_DECLINED; - } conn->secretPrivateData = conn->privateData; diff --git a/src/esx/esx_storage_backend_iscsi.c b/src/esx/esx_storage_backend_iscsi.c index 41f895d..1b5fc0d 100644 --- a/src/esx/esx_storage_backend_iscsi.c +++ b/src/esx/esx_storage_backend_iscsi.c @@ -79,9 +79,8 @@ esxConnectNumOfStoragePools(virConnectPtr conn) * return iSCSI names for all static targets to avoid duplicate names. */ for (target = hostInternetScsiHba->configuredStaticTarget; - target; target = target->_next) { + target; target = target->_next) ++count; - } success = true; @@ -104,9 +103,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, esxVI_HostInternetScsiHbaStaticTarget *target; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba) < 0) { @@ -140,9 +138,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } } esxVI_HostInternetScsiHba_Free(&hostInternetScsiHba); @@ -168,9 +165,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, * parameter */ if (esxVI_LookupHostInternetScsiHbaStaticTargetByName - (priv->primary, name, &target, esxVI_Occurrence_OptionalItem) < 0) { + (priv->primary, name, &target, esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!target) { /* pool not found, error handling done by the base driver */ @@ -222,9 +218,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, target; target = target->_next) { md5_buffer(target->iScsiName, strlen(target->iScsiName), md5); - if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0) { + if (memcmp(uuid, md5, VIR_UUID_STRING_BUFLEN) == 0) break; - } } if (!target) { @@ -254,9 +249,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, virCheckFlags(0, -1); if (esxVI_LookupHostInternetScsiHba(priv->primary, - &hostInternetScsiHba) < 0) { + &hostInternetScsiHba) < 0) goto cleanup; - } /* * ESX does not allow rescan on a particular target, @@ -264,9 +258,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, */ if (esxVI_RescanHba(priv->primary, priv->primary->hostSystem->configManager->storageSystem, - hostInternetScsiHba->device) < 0) { + hostInternetScsiHba->device) < 0) goto cleanup; - } result = 0; @@ -304,15 +297,13 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) memset(&def, 0, sizeof(def)); - if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba)) { + if (esxVI_LookupHostInternetScsiHba(priv->primary, &hostInternetScsiHba)) goto cleanup; - } for (target = hostInternetScsiHba->configuredStaticTarget; target; target = target->_next) { - if (STREQ(target->iScsiName, pool->name)) { + if (STREQ(target->iScsiName, pool->name)) break; - } } if (!target) { @@ -338,9 +329,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) def.source.hosts[0].name = target->address; - if (target->port) { + if (target->port) def.source.hosts[0].port = target->port->value; - } /* TODO: add CHAP authentication params */ xml = virStoragePoolDefFormat(&def); @@ -363,15 +353,13 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool) esxVI_HostScsiTopologyLun *hostScsiTopologyLun; if (esxVI_LookupHostScsiTopologyLunListByTargetName - (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) { + (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) return -1; - } for (hostScsiTopologyLun = hostScsiTopologyLunList; hostScsiTopologyLun; - hostScsiTopologyLun = hostScsiTopologyLun->_next) { + hostScsiTopologyLun = hostScsiTopologyLun->_next) ++count; - } esxVI_HostScsiTopologyLun_Free(&hostScsiTopologyLunList); @@ -394,18 +382,16 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, size_t i; if (esxVI_LookupHostScsiTopologyLunListByTargetName - (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) { + (priv->primary, pool->name, &hostScsiTopologyLunList) < 0) goto cleanup; - } if (!hostScsiTopologyLunList) { /* iSCSI adapter may not be enabled on ESX host */ return 0; } - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; - } for (scsiLun = scsiLunList; scsiLun && count < maxnames; scsiLun = scsiLun->_next) { @@ -425,9 +411,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -452,9 +437,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, unsigned char md5[MD5_DIGEST_SIZE]; char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; - } for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) { @@ -500,9 +484,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) unsigned char md5[MD5_DIGEST_SIZE]; char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; - } for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) { hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun); @@ -513,9 +496,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary, hostScsiDisk->key, - &poolName) < 0) { + &poolName) < 0) goto cleanup; - } md5_buffer(scsiLun->uuid, strlen(scsiLun->uuid), md5); virUUIDFormat(md5, uuid_string); @@ -548,13 +530,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; /* key may be LUN device path */ - if (STRPREFIX(key, "/")) { + if (STRPREFIX(key, "/")) return esxStorageVolLookupByPath(conn, key); - } - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; - } for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) { @@ -570,9 +550,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) if (esxVI_LookupStoragePoolNameByScsiLunKey(priv->primary, scsiLun->key, - &poolName) < 0) { + &poolName) < 0) goto cleanup; - } volume = virGetStorageVol(conn, poolName, scsiLun->deviceName, uuid_string, &esxStorageBackendISCSI, @@ -631,18 +610,16 @@ esxStorageVolGetInfo(virStorageVolPtr volume, esxVI_ScsiLun *scsiLun; esxVI_HostScsiDisk *hostScsiDisk = NULL; - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; - } for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) { hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun); if (hostScsiDisk && - STREQ(hostScsiDisk->deviceName, volume->name)) { + STREQ(hostScsiDisk->deviceName, volume->name)) break; - } } if (!hostScsiDisk) { @@ -687,18 +664,16 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, memset(&pool, 0, sizeof(pool)); memset(&def, 0, sizeof(def)); - if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) { + if (esxVI_LookupScsiLunList(priv->primary, &scsiLunList) < 0) goto cleanup; - } for (scsiLun = scsiLunList; scsiLun; scsiLun = scsiLun->_next) { hostScsiDisk = esxVI_HostScsiDisk_DynamicCast(scsiLun); if (hostScsiDisk && - STREQ(hostScsiDisk->deviceName, volume->name)) { + STREQ(hostScsiDisk->deviceName, volume->name)) break; - } } if (!hostScsiDisk) { @@ -715,9 +690,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, virUUIDFormat(md5, uuid_string); - if (VIR_STRDUP(def.key, uuid_string) < 0) { + if (VIR_STRDUP(def.key, uuid_string) < 0) goto cleanup; - } /* iSCSI LUN exposes a block device */ def.type = VIR_STORAGE_VOL_BLOCK; diff --git a/src/esx/esx_storage_backend_vmfs.c b/src/esx/esx_storage_backend_vmfs.c index cf0da84..1d2a1d8 100644 --- a/src/esx/esx_storage_backend_vmfs.c +++ b/src/esx/esx_storage_backend_vmfs.c @@ -67,9 +67,8 @@ esxLookupVMFSStoragePoolType(esxVI_Context *ctx, const char *poolName, if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0 || esxVI_LookupDatastoreByName(ctx, poolName, propertyNameList, &datastore, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!datastore) { /* Not found, let the base storage driver handle error reporting */ @@ -80,9 +79,8 @@ esxLookupVMFSStoragePoolType(esxVI_Context *ctx, const char *poolName, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "info")) { if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val, - &datastoreInfo) < 0) { + &datastoreInfo) < 0) goto cleanup; - } break; } @@ -120,14 +118,12 @@ esxConnectNumOfStoragePools(virConnectPtr conn) esxVI_ObjectContent *datastoreList = NULL; esxVI_ObjectContent *datastore = NULL; - if (esxVI_LookupDatastoreList(priv->primary, NULL, &datastoreList) < 0) { + if (esxVI_LookupDatastoreList(priv->primary, NULL, &datastoreList) < 0) return -1; - } for (datastore = datastoreList; datastore; - datastore = datastore->_next) { + datastore = datastore->_next) ++count; - } esxVI_ObjectContent_Free(&datastoreList); @@ -149,16 +145,14 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int count = 0; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name") < 0 || esxVI_LookupDatastoreList(priv->primary, propertyNameList, - &datastoreList) < 0) { + &datastoreList) < 0) goto cleanup; - } for (datastore = datastoreList; datastore; datastore = datastore->_next) { @@ -166,9 +160,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "summary.name")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) goto cleanup; - } if (VIR_STRDUP(names[count], dynamicProperty->val->string) < 0) goto cleanup; @@ -185,9 +178,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -212,9 +204,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, virStoragePoolPtr pool = NULL; if (esxVI_LookupDatastoreByName(priv->primary, name, NULL, &datastore, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!datastore) { /* Not found, let the base storage driver handle error reporting */ @@ -230,9 +221,8 @@ esxStoragePoolLookupByName(virConnectPtr conn, * considered to be collision-free enough for this use case. */ if (esxVI_LookupDatastoreHostMount(priv->primary, datastore->obj, &hostMount, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!hostMount) { /* Not found, let the base storage driver handle error reporting */ @@ -270,9 +260,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name") < 0 || esxVI_LookupDatastoreList(priv->primary, propertyNameList, - &datastoreList) < 0) { + &datastoreList) < 0) goto cleanup; - } for (datastore = datastoreList; datastore; datastore = datastore->_next) { @@ -280,9 +269,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, if (esxVI_LookupDatastoreHostMount(priv->primary, datastore->obj, &hostMount, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!hostMount) { /* @@ -295,9 +283,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, md5_buffer(hostMount->mountInfo->path, strlen(hostMount->mountInfo->path), md5); - if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) { + if (memcmp(uuid, md5, VIR_UUID_BUFLEN) == 0) break; - } } if (!datastore) { @@ -306,9 +293,8 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, } if (esxVI_GetStringValue(datastore, "summary.name", &name, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } pool = virGetStoragePool(conn, name, uuid, &esxStorageBackendVMFS, NULL); @@ -333,9 +319,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags) if (esxVI_LookupDatastoreByName(priv->primary, pool->name, NULL, &datastore, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_RefreshDatastore(priv->primary, datastore->obj) < 0) { + esxVI_RefreshDatastore(priv->primary, datastore->obj) < 0) goto cleanup; - } result = 0; @@ -366,9 +351,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, propertyNameList, &datastore, esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetBoolean(datastore, "summary.accessible", - &accessible, esxVI_Occurrence_RequiredItem) < 0) { + &accessible, esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (accessible == esxVI_Boolean_True) { info->state = VIR_STORAGE_POOL_RUNNING; @@ -377,16 +361,14 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "summary.capacity")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } info->capacity = dynamicProperty->val->int64; } else if (STREQ(dynamicProperty->name, "summary.freeSpace")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } info->available = dynamicProperty->val->int64; } @@ -437,9 +419,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) esxVI_GetBoolean(datastore, "summary.accessible", &accessible, esxVI_Occurrence_RequiredItem) < 0 || esxVI_LookupDatastoreHostMount(priv->primary, datastore->obj, &hostMount, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } def.name = pool->name; memcpy(def.uuid, pool->uuid, VIR_UUID_BUFLEN); @@ -451,16 +432,14 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "summary.capacity")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } def.capacity = dynamicProperty->val->int64; } else if (STREQ(dynamicProperty->name, "summary.freeSpace")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Long) < 0) { + esxVI_Type_Long) < 0) goto cleanup; - } def.available = dynamicProperty->val->int64; } @@ -473,9 +452,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "info")) { if (esxVI_DatastoreInfo_CastFromAnyType(dynamicProperty->val, - &info) < 0) { + &info) < 0) goto cleanup; - } break; } @@ -538,17 +516,15 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool) int count = 0; if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->name, - &searchResultsList) < 0) { + &searchResultsList) < 0) goto cleanup; - } /* Interpret search result */ for (searchResults = searchResultsList; searchResults; searchResults = searchResults->_next) { for (fileInfo = searchResults->file; fileInfo; - fileInfo = fileInfo->_next) { + fileInfo = fileInfo->_next) ++count; - } } success = true; @@ -580,14 +556,12 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, return -1; } - if (maxnames == 0) { + if (maxnames == 0) return 0; - } if (esxVI_LookupDatastoreContentByDatastoreName(priv->primary, pool->name, - &searchResultsList) < 0) { + &searchResultsList) < 0) goto cleanup; - } /* Interpret search result */ for (searchResults = searchResultsList; searchResults; @@ -595,9 +569,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, VIR_FREE(directoryAndFileName); if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, NULL, - &directoryAndFileName) < 0) { + &directoryAndFileName) < 0) goto cleanup; - } /* Strip trailing separators */ length = strlen(directoryAndFileName); @@ -614,9 +587,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, if (VIR_STRDUP(names[count], fileInfo->path) < 0) goto cleanup; } else if (virAsprintf(&names[count], "%s/%s", directoryAndFileName, - fileInfo->path) < 0) { + fileInfo->path) < 0) goto cleanup; - } ++count; } @@ -626,9 +598,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -654,9 +625,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, goto cleanup; if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, - datastorePath, &key) < 0) { + datastorePath, &key) < 0) goto cleanup; - } volume = virGetStorageVol(pool->conn, pool->name, name, key, &esxStorageBackendVMFS, NULL); @@ -680,14 +650,12 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) char *key = NULL; if (esxUtil_ParseDatastorePath(path, &datastoreName, NULL, - &directoryAndFileName) < 0) { + &directoryAndFileName) < 0) goto cleanup; - } if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, path, - &key) < 0) { + &key) < 0) goto cleanup; - } volume = virGetStorageVol(conn, datastoreName, directoryAndFileName, key, &esxStorageBackendVMFS, NULL); @@ -736,26 +704,23 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) /* Lookup all datastores */ if (esxVI_String_AppendValueToList(&propertyNameList, "summary.name") < 0 || esxVI_LookupDatastoreList(priv->primary, propertyNameList, - &datastoreList) < 0) { + &datastoreList) < 0) goto cleanup; - } for (datastore = datastoreList; datastore; datastore = datastore->_next) { datastoreName = NULL; if (esxVI_GetStringValue(datastore, "summary.name", &datastoreName, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* Lookup datastore content */ esxVI_HostDatastoreBrowserSearchResults_Free(&searchResultsList); if (esxVI_LookupDatastoreContentByDatastoreName - (priv->primary, datastoreName, &searchResultsList) < 0) { + (priv->primary, datastoreName, &searchResultsList) < 0) goto cleanup; - } /* Interpret search result */ for (searchResults = searchResultsList; searchResults; @@ -763,9 +728,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) VIR_FREE(directoryAndFileName); if (esxUtil_ParseDatastorePath(searchResults->folderPath, NULL, - NULL, &directoryAndFileName) < 0) { + NULL, &directoryAndFileName) < 0) goto cleanup; - } /* Strip trailing separators */ length = strlen(directoryAndFileName); @@ -785,9 +749,8 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) goto cleanup; } else if (virAsprintf(&volumeName, "%s/%s", directoryAndFileName, - fileInfo->path) < 0) { + fileInfo->path) < 0) goto cleanup; - } if (virAsprintf(&datastorePath, "[%s] %s", datastoreName, volumeName) < 0) @@ -803,13 +766,11 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) if (esxVI_QueryVirtualDiskUuid (priv->primary, datastorePath, priv->primary->datacenter->_reference, - &uuid_string) < 0) { + &uuid_string) < 0) goto cleanup; - } - if (esxUtil_ReformatUuid(uuid_string, key_candidate) < 0) { + if (esxUtil_ReformatUuid(uuid_string, key_candidate) < 0) goto cleanup; - } if (STREQ(key, key_candidate)) { /* Found matching UUID */ @@ -866,16 +827,14 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, memset(&poolDef, 0, sizeof(poolDef)); if (esxLookupVMFSStoragePoolType(priv->primary, pool->name, - &poolDef.type) < 0) { + &poolDef.type) < 0) goto cleanup; - } /* Parse config */ def = virStorageVolDefParseString(&poolDef, xmldesc); - if (!def) { + if (!def) goto cleanup; - } if (def->type != VIR_STORAGE_VOL_FILE) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -908,22 +867,19 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, /* Parse and escape datastore path */ if (esxUtil_ParseDatastorePath(unescapedDatastorePath, NULL, &unescapedDirectoryName, - &unescapedDirectoryAndFileName) < 0) { + &unescapedDirectoryAndFileName) < 0) goto cleanup; - } directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName); - if (!directoryName) { + if (!directoryName) goto cleanup; - } fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName + strlen(unescapedDirectoryName) + 1); - if (!fileName) { + if (!fileName) goto cleanup; - } if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name, directoryName) < 0) @@ -936,23 +892,20 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, /* Create directory, if it doesn't exist yet */ if (esxVI_LookupFileInfoByDatastorePath (priv->primary, datastorePathWithoutFileName, true, &fileInfo, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!fileInfo) { if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName, priv->primary->datacenter->_reference, - esxVI_Boolean_True) < 0) { + esxVI_Boolean_True) < 0) goto cleanup; - } } /* Create VirtualDisk */ if (esxVI_FileBackedVirtualDiskSpec_Alloc(&virtualDiskSpec) < 0 || - esxVI_Long_Alloc(&virtualDiskSpec->capacityKb) < 0) { + esxVI_Long_Alloc(&virtualDiskSpec->capacityKb) < 0) goto cleanup; - } /* From the vSphere API documentation about VirtualDiskType ... */ if (def->target.allocation == def->target.capacity) { @@ -991,9 +944,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, esxVI_Occurrence_None, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1008,18 +960,15 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath, priv->primary->datacenter->_reference, - &uuid_string) < 0) { + &uuid_string) < 0) goto cleanup; - } - if (esxUtil_ReformatUuid(uuid_string, key) < 0) { + if (esxUtil_ReformatUuid(uuid_string, key) < 0) goto cleanup; - } } else { /* Fall back to the path as key */ - if (VIR_STRDUP(key, datastorePath) < 0) { + if (VIR_STRDUP(key, datastorePath) < 0) goto cleanup; - } } } else { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1088,9 +1037,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, memset(&poolDef, 0, sizeof(poolDef)); if (esxLookupVMFSStoragePoolType(priv->primary, pool->name, - &poolDef.type) < 0) { + &poolDef.type) < 0) goto cleanup; - } if (virAsprintf(&sourceDatastorePath, "[%s] %s", sourceVolume->pool, sourceVolume->name) < 0) @@ -1099,9 +1047,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, /* Parse config */ def = virStorageVolDefParseString(&poolDef, xmldesc); - if (!def) { + if (!def) goto cleanup; - } if (def->type != VIR_STORAGE_VOL_FILE) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1134,22 +1081,19 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, /* Parse and escape datastore path */ if (esxUtil_ParseDatastorePath(unescapedDatastorePath, NULL, &unescapedDirectoryName, - &unescapedDirectoryAndFileName) < 0) { + &unescapedDirectoryAndFileName) < 0) goto cleanup; - } directoryName = esxUtil_EscapeDatastoreItem(unescapedDirectoryName); - if (!directoryName) { + if (!directoryName) goto cleanup; - } fileName = esxUtil_EscapeDatastoreItem(unescapedDirectoryAndFileName + strlen(unescapedDirectoryName) + 1); - if (!fileName) { + if (!fileName) goto cleanup; - } if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", pool->name, directoryName) < 0) @@ -1162,16 +1106,14 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, /* Create directory, if it doesn't exist yet */ if (esxVI_LookupFileInfoByDatastorePath (priv->primary, datastorePathWithoutFileName, true, &fileInfo, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!fileInfo) { if (esxVI_MakeDirectory(priv->primary, datastorePathWithoutFileName, priv->primary->datacenter->_reference, - esxVI_Boolean_True) < 0) { + esxVI_Boolean_True) < 0) goto cleanup; - } } /* Copy VirtualDisk */ @@ -1184,9 +1126,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, esxVI_Occurrence_None, priv->parsedUri->autoAnswer, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not copy volume: %s"), @@ -1200,18 +1141,15 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, if (esxVI_QueryVirtualDiskUuid(priv->primary, datastorePath, priv->primary->datacenter->_reference, - &uuid_string) < 0) { + &uuid_string) < 0) goto cleanup; - } - if (esxUtil_ReformatUuid(uuid_string, key) < 0) { + if (esxUtil_ReformatUuid(uuid_string, key) < 0) goto cleanup; - } } else { /* Fall back to the path as key */ - if (VIR_STRDUP(key, datastorePath) < 0) { + if (VIR_STRDUP(key, datastorePath) < 0) goto cleanup; - } } } else { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1265,9 +1203,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags) esxVI_WaitForTaskCompletion(priv->primary, task, NULL, esxVI_Occurrence_None, priv->parsedUri->autoAnswer, - &taskInfoState, &taskInfoErrorMessage) < 0) { + &taskInfoState, &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not delete volume: %s"), @@ -1308,9 +1245,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags) esxVI_WaitForTaskCompletion(priv->primary, task, NULL, esxVI_Occurrence_None, priv->parsedUri->autoAnswer, - &taskInfoState, &taskInfoErrorMessage) < 0) { + &taskInfoState, &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Could not wipe volume: %s"), @@ -1347,9 +1283,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath, false, &fileInfo, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo); @@ -1395,9 +1330,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, memset(&def, 0, sizeof(def)); if (esxLookupVMFSStoragePoolType(priv->primary, volume->pool, - &pool.type) < 0) { + &pool.type) < 0) return NULL; - } /* Lookup file info */ if (virAsprintf(&datastorePath, "[%s] %s", volume->pool, volume->name) < 0) @@ -1405,9 +1339,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, if (esxVI_LookupFileInfoByDatastorePath(priv->primary, datastorePath, false, &fileInfo, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } vmDiskFileInfo = esxVI_VmDiskFileInfo_DynamicCast(fileInfo); isoImageFileInfo = esxVI_IsoImageFileInfo_DynamicCast(fileInfo); @@ -1416,9 +1349,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, def.name = volume->name; if (esxVI_LookupStorageVolumeKeyByDatastorePath(priv->primary, datastorePath, - &def.key) < 0) { + &def.key) < 0) goto cleanup; - } def.type = VIR_STORAGE_VOL_FILE; def.target.path = datastorePath; diff --git a/src/esx/esx_storage_driver.c b/src/esx/esx_storage_driver.c index cae53ed..5b3b8c9 100644 --- a/src/esx/esx_storage_driver.c +++ b/src/esx/esx_storage_driver.c @@ -60,9 +60,8 @@ esxStorageOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_ESX) { + if (conn->driver->no != VIR_DRV_ESX) return VIR_DRV_OPEN_DECLINED; - } conn->storagePrivateData = conn->privateData; @@ -89,16 +88,14 @@ esxConnectNumOfStoragePools(virConnectPtr conn) size_t i; int tmp; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } for (i = 0; i < LAST_BACKEND; ++i) { tmp = backends[i]->connectNumOfStoragePools(conn); - if (tmp < 0) { + if (tmp < 0) return -1; - } count += tmp; } @@ -117,20 +114,17 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames) size_t i; int tmp; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } for (i = 0; i < LAST_BACKEND; ++i) { tmp = backends[i]->connectListStoragePools(conn, &names[count], maxnames - count); - if (tmp < 0) { + if (tmp < 0) goto cleanup; - } count += tmp; } @@ -139,9 +133,8 @@ esxConnectListStoragePools(virConnectPtr conn, char **const names, int maxnames) cleanup: if (! success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -180,16 +173,14 @@ esxStoragePoolLookupByName(virConnectPtr conn, const char *name) virCheckNonNullArgReturn(name, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } for (i = 0; i < LAST_BACKEND; ++i) { pool = backends[i]->storagePoolLookupByName(conn, name); - if (pool) { + if (pool) return pool; - } } virReportError(VIR_ERR_NO_STORAGE_POOL, @@ -208,17 +199,15 @@ esxStoragePoolLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virStoragePoolPtr pool; char uuid_string[VIR_UUID_STRING_BUFLEN] = ""; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } /* invoke backend drive method to search all known pools */ for (i = 0; i < LAST_BACKEND; ++i) { pool = backends[i]->storagePoolLookupByUUID(conn, uuid); - if (pool) { + if (pool) return pool; - } } virUUIDFormat(uuid, uuid_string); @@ -247,9 +236,8 @@ esxStoragePoolRefresh(virStoragePoolPtr pool, unsigned int flags) virCheckNonNullArgReturn(pool->privateData, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storagePoolRefresh(pool, flags); } @@ -266,9 +254,8 @@ esxStoragePoolGetInfo(virStoragePoolPtr pool, virStoragePoolInfoPtr info) memset(info, 0, sizeof(*info)); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storagePoolGetInfo(pool, info); } @@ -283,9 +270,8 @@ esxStoragePoolGetXMLDesc(virStoragePoolPtr pool, unsigned int flags) virCheckNonNullArgReturn(pool->privateData, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } return backend->storagePoolGetXMLDesc(pool, flags); } @@ -330,9 +316,8 @@ esxStoragePoolNumOfVolumes(virStoragePoolPtr pool) virCheckNonNullArgReturn(pool->privateData, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storagePoolNumOfVolumes(pool); } @@ -348,9 +333,8 @@ esxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, virCheckNonNullArgReturn(pool->privateData, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storagePoolListVolumes(pool, names, maxnames); } @@ -365,9 +349,8 @@ esxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) virCheckNonNullArgReturn(pool->privateData, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } return backend->storageVolLookupByName(pool, name); } @@ -379,9 +362,8 @@ esxStorageVolLookupByPath(virConnectPtr conn, const char *path) { esxPrivate *priv = conn->storagePrivateData; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } /* * FIXME: calling backends blindly may set unwanted error codes @@ -412,16 +394,14 @@ esxStorageVolLookupByKey(virConnectPtr conn, const char *key) esxPrivate *priv = conn->storagePrivateData; size_t i; - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } for (i = 0; i < LAST_BACKEND; ++i) { volume = backends[i]->storageVolLookupByKey(conn, key); - if (volume) { + if (volume) return volume; - } } virReportError(VIR_ERR_NO_STORAGE_VOL, @@ -442,9 +422,8 @@ esxStorageVolCreateXML(virStoragePoolPtr pool, const char *xmldesc, virCheckNonNullArgReturn(pool->privateData, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } return backend->storageVolCreateXML(pool, xmldesc, flags); } @@ -460,9 +439,8 @@ esxStorageVolCreateXMLFrom(virStoragePoolPtr pool, const char *xmldesc, virCheckNonNullArgReturn(pool->privateData, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } return backend->storageVolCreateXMLFrom(pool, xmldesc, sourceVolume, flags); } @@ -477,9 +455,8 @@ esxStorageVolDelete(virStorageVolPtr volume, unsigned int flags) virCheckNonNullArgReturn(volume->privateData, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storageVolDelete(volume, flags); } @@ -494,9 +471,8 @@ esxStorageVolWipe(virStorageVolPtr volume, unsigned int flags) virCheckNonNullArgReturn(volume->privateData, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storageVolWipe(volume, flags); } @@ -511,9 +487,8 @@ esxStorageVolGetInfo(virStorageVolPtr volume, virStorageVolInfoPtr info) virCheckNonNullArgReturn(volume->privateData, -1); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return -1; - } return backend->storageVolGetInfo(volume, info); } @@ -528,9 +503,8 @@ esxStorageVolGetXMLDesc(virStorageVolPtr volume, unsigned int flags) virCheckNonNullArgReturn(volume->privateData, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } return backend->storageVolGetXMLDesc(volume, flags); } @@ -545,9 +519,8 @@ esxStorageVolGetPath(virStorageVolPtr volume) virCheckNonNullArgReturn(volume->privateData, NULL); - if (esxVI_EnsureSession(priv->primary) < 0) { + if (esxVI_EnsureSession(priv->primary) < 0) return NULL; - } return backend->storageVolGetPath(volume); } diff --git a/src/esx/esx_util.c b/src/esx/esx_util.c index 9a41241..641a5c8 100644 --- a/src/esx/esx_util.c +++ b/src/esx/esx_util.c @@ -166,9 +166,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri) result = 0; cleanup: - if (result < 0) { + if (result < 0) esxUtil_FreeParsedUri(parsedUri); - } return result; } @@ -179,9 +178,8 @@ esxUtil_ParseUri(esxUtil_ParsedUri **parsedUri, virURIPtr uri) void esxUtil_FreeParsedUri(esxUtil_ParsedUri **parsedUri) { - if (!parsedUri || !(*parsedUri)) { + if (!parsedUri || !(*parsedUri)) return; - } VIR_FREE((*parsedUri)->transport); VIR_FREE((*parsedUri)->vCenter); @@ -197,18 +195,16 @@ int esxUtil_ParseVirtualMachineIDString(const char *id_string, int *id) { /* Try to parse an integer from the complete string. */ - if (virStrToLong_i(id_string, NULL, 10, id) == 0) { + if (virStrToLong_i(id_string, NULL, 10, id) == 0) return 0; - } /* * If that fails try to parse an integer from the string tail * assuming the naming scheme Virtual Center seems to use. */ if (STRPREFIX(id_string, "vm-")) { - if (virStrToLong_i(id_string + 3, NULL, 10, id) == 0) { + if (virStrToLong_i(id_string + 3, NULL, 10, id) == 0) return 0; - } } return -1; @@ -234,9 +230,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName, return -1; } - if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0) { + if (VIR_STRDUP(copyOfDatastorePath, datastorePath) < 0) goto cleanup; - } /* Expected format: '[<datastore>] <path>' where <path> is optional */ if (!(tmp = STRSKIP(copyOfDatastorePath, "[")) || *tmp == ']' || @@ -248,9 +243,8 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName, } if (datastoreName && - VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0) { + VIR_STRDUP(*datastoreName, preliminaryDatastoreName) < 0) goto cleanup; - } preliminaryDirectoryAndFileName = strtok_r(NULL, "", &saveptr); @@ -262,38 +256,32 @@ esxUtil_ParseDatastorePath(const char *datastorePath, char **datastoreName, } if (directoryAndFileName && - VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName) < 0) { + VIR_STRDUP(*directoryAndFileName, preliminaryDirectoryAndFileName) < 0) goto cleanup; - } if (directoryName) { /* Split <path> into <directory>/<file> and remove /<file> */ tmp = strrchr(preliminaryDirectoryAndFileName, '/'); - if (tmp) { + if (tmp) *tmp = '\0'; - } - if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0) { + if (VIR_STRDUP(*directoryName, preliminaryDirectoryAndFileName) < 0) goto cleanup; - } } result = 0; cleanup: if (result < 0) { - if (datastoreName) { + if (datastoreName) VIR_FREE(*datastoreName); - } - if (directoryName) { + if (directoryName) VIR_FREE(*directoryName); - } - if (directoryAndFileName) { + if (directoryAndFileName) VIR_FREE(*directoryAndFileName); - } } VIR_FREE(copyOfDatastorePath); @@ -408,20 +396,17 @@ esxUtil_EscapeBase64(const char *string) virBufferAddChar(&buffer, base64[(c1 >> 2) & 0x3f]); virBufferAddChar(&buffer, base64[((c1 << 4) + (c2 >> 4)) & 0x3f]); - if (length > 1) { + if (length > 1) virBufferAddChar(&buffer, base64[((c2 << 2) + (c3 >> 6)) & 0x3f]); - } - if (length > 2) { + if (length > 2) virBufferAddChar(&buffer, base64[c3 & 0x3f]); - } length -= length > 3 ? 3 : length; } - if (*tmp1 != '\0') { + if (*tmp1 != '\0') virBufferAddChar(&buffer, '-'); - } } } @@ -450,9 +435,8 @@ esxUtil_ReplaceSpecialWindowsPathChars(char *string) --length; } - if (*tmp != '\0') { + if (*tmp != '\0') ++tmp; - } } } @@ -472,9 +456,8 @@ esxUtil_EscapeDatastoreItem(const char *string) escaped1 = virVMXEscapeHexPercent(replaced); - if (!escaped1) { + if (!escaped1) goto cleanup; - } escaped2 = esxUtil_EscapeBase64(escaped1); diff --git a/src/esx/esx_vi.c b/src/esx/esx_vi.c index b00d8e7..4db1dd4 100644 --- a/src/esx/esx_vi.c +++ b/src/esx/esx_vi.c @@ -98,26 +98,22 @@ ESX_VI__TEMPLATE__FREE(CURL, if (shared) { esxVI_SharedCURL_Remove(shared, item); - if (shared->count == 0) { + if (shared->count == 0) esxVI_SharedCURL_Free(&shared); - } } if (multi) { esxVI_MultiCURL_Remove(multi, item); - if (multi->count == 0) { + if (multi->count == 0) esxVI_MultiCURL_Free(&multi); - } } - if (item->handle) { + if (item->handle) curl_easy_cleanup(item->handle); - } - if (item->headers) { + if (item->headers) curl_slist_free_all(item->headers); - } virMutexDestroy(&item->lock); }) @@ -129,19 +125,16 @@ esxVI_CURL_ReadString(char *data, size_t size, size_t nmemb, void *userdata) size_t available = 0; size_t requested = size * nmemb; - if (!content) { + if (!content) return 0; - } available = strlen(content); - if (available == 0) { + if (available == 0) return 0; - } - if (requested > available) { + if (requested > available) requested = available; - } memcpy(data, content, requested); @@ -162,9 +155,8 @@ esxVI_CURL_WriteBuffer(char *data, size_t size, size_t nmemb, void *userdata) * are meant to download small things such as VMX files, VMDK metadata * files and SOAP responses. */ - if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer)) { + if (size * nmemb > INT32_MAX / 2 - virBufferUse(buffer)) return 0; - } virBufferAdd(buffer, data, size * nmemb); @@ -193,9 +185,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type, * To handle this properly in order to pass the info string to VIR_DEBUG * a zero terminated copy of the info string has to be allocated. */ - if (VIR_ALLOC_N(buffer, size + 1) < 0) { + if (VIR_ALLOC_N(buffer, size + 1) < 0) return 0; - } if (!virStrncpy(buffer, info, size, size + 1)) { VIR_FREE(buffer); @@ -204,9 +195,8 @@ esxVI_CURL_Debug(CURL *curl ATTRIBUTE_UNUSED, curl_infotype type, switch (type) { case CURLINFO_TEXT: - if (size > 0 && buffer[size - 1] == '\n') { + if (size > 0 && buffer[size - 1] == '\n') buffer[size - 1] = '\0'; - } VIR_DEBUG("CURLINFO_TEXT [[[[%s]]]]", buffer); break; @@ -430,9 +420,8 @@ esxVI_CURL_Download(esxVI_CURL *curl, const char *url, char **content, if (virBufferCheckError(&buffer) < 0) goto cleanup; - if (length) { + if (length) *length = virBufferUse(&buffer); - } *content = virBufferContentAndReset(&buffer); @@ -557,13 +546,11 @@ ESX_VI__TEMPLATE__FREE(SharedCURL, return; } - if (item->handle) { + if (item->handle) curl_share_cleanup(item->handle); - } - for (i = 0; i < ARRAY_CARDINALITY(item->locks); ++i) { + for (i = 0; i < ARRAY_CARDINALITY(item->locks); ++i) virMutexDestroy(&item->locks[i]); - } }) int @@ -735,9 +722,8 @@ ESX_VI__TEMPLATE__FREE(MultiCURL, return; } - if (item->handle) { + if (item->handle) curl_multi_cleanup(item->handle); - } #if ESX_EMULATE_CURL_MULTI_WAIT VIR_FREE(item->pollfds); @@ -856,9 +842,8 @@ esxVI_MultiCURL_Wait(esxVI_MultiCURL *multi, int *runningHandles) curl_multi_timeout(multi->handle, &timeout); - if (timeout < 0) { + if (timeout < 0) timeout = 1000; /* default to 1 sec timeout */ - } do { rc = poll(multi->pollfds, multi->npollfds, timeout); @@ -980,9 +965,8 @@ ESX_VI__TEMPLATE__ALLOC(Context) /* esxVI_Context_Free */ ESX_VI__TEMPLATE__FREE(Context, { - if (item->sessionLock) { + if (item->sessionLock) virMutexDestroy(item->sessionLock); - } esxVI_CURL_Free(&item->curl); VIR_FREE(item->url); @@ -1023,9 +1007,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, VIR_STRDUP(ctx->url, url) < 0 || VIR_STRDUP(ctx->ipAddress, ipAddress) < 0 || VIR_STRDUP(ctx->username, username) < 0 || - VIR_STRDUP(ctx->password, password) < 0) { + VIR_STRDUP(ctx->password, password) < 0) return -1; - } if (VIR_ALLOC(ctx->sessionLock) < 0) return -1; @@ -1036,9 +1019,8 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, return -1; } - if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0) { + if (esxVI_RetrieveServiceContent(ctx, &ctx->service) < 0) return -1; - } if (STREQ(ctx->service->about->apiType, "HostAgent") || STREQ(ctx->service->about->apiType, "VirtualCenter")) { @@ -1142,14 +1124,12 @@ esxVI_Context_Connect(esxVI_Context *ctx, const char *url, ctx->hasQueryVirtualDiskUuid = true; } - if (ctx->productVersion & esxVI_ProductVersion_VPX) { + if (ctx->productVersion & esxVI_ProductVersion_VPX) ctx->hasSessionIsActive = true; - } if (esxVI_Login(ctx, username, password, NULL, &ctx->session) < 0 || - esxVI_BuildSelectSetCollection(ctx) < 0) { + esxVI_BuildSelectSetCollection(ctx) < 0) return -1; - } return 0; } @@ -1160,9 +1140,8 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx) /* Lookup Datacenter */ if (esxVI_LookupDatacenter(ctx, NULL, ctx->service->rootFolder, NULL, &ctx->datacenter, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return -1; - } if (VIR_STRDUP(ctx->datacenterPath, ctx->datacenter->name) < 0) return -1; @@ -1170,9 +1149,8 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx) /* Lookup (Cluster)ComputeResource */ if (esxVI_LookupComputeResource(ctx, NULL, ctx->datacenter->hostFolder, NULL, &ctx->computeResource, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return -1; - } if (!ctx->computeResource->resourcePool) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1186,9 +1164,8 @@ esxVI_Context_LookupManagedObjects(esxVI_Context *ctx) /* Lookup HostSystem */ if (esxVI_LookupHostSystem(ctx, NULL, ctx->computeResource->_reference, NULL, &ctx->hostSystem, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) return -1; - } if (VIR_STRDUP(ctx->hostSystemName, ctx->hostSystem->name) < 0) return -1; @@ -1227,30 +1204,26 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path) /* Try to lookup item as a folder */ if (esxVI_LookupFolder(ctx, item, root, NULL, &folder, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (folder) { /* It's a folder, use it as new lookup root */ - if (root != ctx->service->rootFolder) { + if (root != ctx->service->rootFolder) esxVI_ManagedObjectReference_Free(&root); - } root = folder->_reference; folder->_reference = NULL; } else { /* Try to lookup item as a datacenter */ if (esxVI_LookupDatacenter(ctx, item, root, NULL, &ctx->datacenter, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } } /* Build datacenter path */ - if (virBufferUse(&buffer) > 0) { + if (virBufferUse(&buffer) > 0) virBufferAddChar(&buffer, '/'); - } virBufferAdd(&buffer, item, -1); @@ -1276,9 +1249,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path) goto cleanup; } - if (root != ctx->service->rootFolder) { + if (root != ctx->service->rootFolder) esxVI_ManagedObjectReference_Free(&root); - } root = ctx->datacenter->hostFolder; @@ -1287,15 +1259,13 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path) /* Try to lookup item as a folder */ if (esxVI_LookupFolder(ctx, item, root, NULL, &folder, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (folder) { /* It's a folder, use it as new lookup root */ - if (root != ctx->datacenter->hostFolder) { + if (root != ctx->datacenter->hostFolder) esxVI_ManagedObjectReference_Free(&root); - } root = folder->_reference; folder->_reference = NULL; @@ -1303,15 +1273,13 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path) /* Try to lookup item as a compute resource */ if (esxVI_LookupComputeResource(ctx, item, root, NULL, &ctx->computeResource, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } } /* Build compute resource path */ - if (virBufferUse(&buffer) > 0) { + if (virBufferUse(&buffer) > 0) virBufferAddChar(&buffer, '/'); - } virBufferAdd(&buffer, item, -1); @@ -1363,9 +1331,8 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path) if (esxVI_LookupHostSystem(ctx, ctx->hostSystemName, ctx->computeResource->_reference, NULL, &ctx->hostSystem, - esxVI_Occurrence_OptionalItem) < 0) { + esxVI_Occurrence_OptionalItem) < 0) goto cleanup; - } if (!ctx->hostSystem) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1376,14 +1343,12 @@ esxVI_Context_LookupManagedObjectsByPath(esxVI_Context *ctx, const char *path) result = 0; cleanup: - if (result < 0) { + if (result < 0) virBufferFreeAndReset(&buffer); - } if (root != ctx->service->rootFolder && - (!ctx->datacenter || root != ctx->datacenter->hostFolder)) { + (!ctx->datacenter || root != ctx->datacenter->hostFolder)) esxVI_ManagedObjectReference_Free(&root); - } VIR_FREE(tmp); esxVI_Folder_Free(&folder); @@ -1403,16 +1368,14 @@ esxVI_Context_LookupManagedObjectsByHostSystemIp(esxVI_Context *ctx, &managedObjectReference) < 0 || esxVI_LookupHostSystem(ctx, NULL, managedObjectReference, NULL, &ctx->hostSystem, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* Lookup (Cluster)ComputeResource */ if (esxVI_LookupComputeResource(ctx, NULL, ctx->hostSystem->_reference, NULL, &ctx->computeResource, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (!ctx->computeResource->resourcePool) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -1423,9 +1386,8 @@ esxVI_Context_LookupManagedObjectsByHostSystemIp(esxVI_Context *ctx, /* Lookup Datacenter */ if (esxVI_LookupDatacenter(ctx, NULL, ctx->computeResource->_reference, NULL, &ctx->datacenter, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } result = 0; @@ -1452,9 +1414,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, return -1; } - if (esxVI_Response_Alloc(response) < 0) { + if (esxVI_Response_Alloc(response) < 0) return -1; - } virMutexLock(&ctx->curl->lock); @@ -1469,9 +1430,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, virMutexUnlock(&ctx->curl->lock); - if ((*response)->responseCode < 0) { + if ((*response)->responseCode < 0) goto cleanup; - } if (virBufferCheckError(&buffer) < 0) goto cleanup; @@ -1483,9 +1443,8 @@ esxVI_Context_Execute(esxVI_Context *ctx, const char *methodName, _("(esx execute response)"), &xpathContext); - if (!(*response)->document) { + if (!(*response)->document) goto cleanup; - } xmlXPathRegisterNs(xpathContext, BAD_CAST "soapenv", BAD_CAST "http://schemas.xmlsoap.org/soap/envelope/"); @@ -1731,9 +1690,8 @@ esxVI_Enumeration_Deserialize(const esxVI_Enumeration *enumeration, *value = 0; /* undefined */ - if (esxVI_String_DeserializeValue(node, &name) < 0) { + if (esxVI_String_DeserializeValue(node, &name) < 0) return -1; - } for (i = 0; enumeration->values[i].name; ++i) { if (STREQ(name, enumeration->values[i].name)) { @@ -1776,9 +1734,8 @@ esxVI_List_Append(esxVI_List **list, esxVI_List *item) next = *list; - while (next->_next) { + while (next->_next) next = next->_next; - } next->_next = item; @@ -1800,9 +1757,8 @@ esxVI_List_DeepCopy(esxVI_List **destList, esxVI_List *srcList, for (src = srcList; src; src = src->_next) { if (deepCopyFunc(&dest, src) < 0 || - esxVI_List_Append(destList, dest) < 0) { + esxVI_List_Append(destList, dest) < 0) goto failure; - } dest = NULL; } @@ -1831,9 +1787,8 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List **list, return -1; } - if (!anyType) { + if (!anyType) return 0; - } if (! STRPREFIX(anyType->other, "ArrayOf")) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1854,9 +1809,8 @@ esxVI_List_CastFromAnyType(esxVI_AnyType *anyType, esxVI_List **list, if (esxVI_AnyType_Deserialize(childNode, &childAnyType) < 0 || castFromAnyTypeFunc(childAnyType, &item) < 0 || - esxVI_List_Append(list, item) < 0) { + esxVI_List_Append(list, item) < 0) goto cleanup; - } item = NULL; } @@ -1886,14 +1840,12 @@ esxVI_List_Serialize(esxVI_List *list, const char *element, return -1; } - if (!list) { + if (!list) return 0; - } for (item = list; item; item = item->_next) { - if (serializeFunc(item, element, output) < 0) { + if (serializeFunc(item, element, output) < 0) return -1; - } } return 0; @@ -1911,9 +1863,8 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list, return -1; } - if (!node) { + if (!node) return 0; - } for (; node; node = node->next) { if (node->type != XML_ELEMENT_NODE) { @@ -1923,9 +1874,8 @@ esxVI_List_Deserialize(xmlNodePtr node, esxVI_List **list, } if (deserializeFunc(node, &item) < 0 || - esxVI_List_Append(list, item) < 0) { + esxVI_List_Append(list, item) < 0) goto failure; - } item = NULL; } @@ -1970,9 +1920,8 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet, if (esxVI_TraversalSpec_Alloc(&traversalSpec) < 0 || VIR_STRDUP(traversalSpec->name, name) < 0 || VIR_STRDUP(traversalSpec->type, type) < 0 || - VIR_STRDUP(traversalSpec->path, path) < 0) { + VIR_STRDUP(traversalSpec->path, path) < 0) goto failure; - } traversalSpec->skip = esxVI_Boolean_False; @@ -1983,9 +1932,8 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet, if (esxVI_SelectionSpec_Alloc(&selectionSpec) < 0 || VIR_STRDUP(selectionSpec->name, currentSelectSetName) < 0 || esxVI_SelectionSpec_AppendToList(&traversalSpec->selectSet, - selectionSpec) < 0) { + selectionSpec) < 0) goto failure; - } selectionSpec = NULL; currentSelectSetName += strlen(currentSelectSetName) + 1; @@ -1994,9 +1942,8 @@ esxVI_BuildSelectSet(esxVI_SelectionSpec **selectSet, if (esxVI_SelectionSpec_AppendToList(selectSet, esxVI_SelectionSpec_DynamicCast - (traversalSpec)) < 0) { + (traversalSpec)) < 0) goto failure; - } return 0; @@ -2015,16 +1962,14 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx) /* Folder -> childEntity (ManagedEntity) */ if (esxVI_BuildSelectSet(&ctx->selectSet_folderToChildEntity, "folderToChildEntity", - "Folder", "childEntity", NULL) < 0) { + "Folder", "childEntity", NULL) < 0) return -1; - } /* ComputeResource -> host (HostSystem) */ if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToHost, "computeResourceToHost", - "ComputeResource", "host", NULL) < 0) { + "ComputeResource", "host", NULL) < 0) return -1; - } /* ComputeResource -> datastore (Datastore) *//* if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToDatastore, @@ -2052,45 +1997,39 @@ esxVI_BuildSelectSetCollection(esxVI_Context *ctx) /* HostSystem -> parent (ComputeResource) */ if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToParent, "hostSystemToParent", - "HostSystem", "parent", NULL) < 0) { + "HostSystem", "parent", NULL) < 0) return -1; - } /* HostSystem -> vm (VirtualMachine) */ if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToVm, "hostSystemToVm", - "HostSystem", "vm", NULL) < 0) { + "HostSystem", "vm", NULL) < 0) return -1; - } /* HostSystem -> datastore (Datastore) */ if (esxVI_BuildSelectSet(&ctx->selectSet_hostSystemToDatastore, "hostSystemToDatastore", - "HostSystem", "datastore", NULL) < 0) { + "HostSystem", "datastore", NULL) < 0) return -1; - } /* Folder -> parent (Folder, Datacenter) */ if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToParentToParent, "managedEntityToParent", - "ManagedEntity", "parent", NULL) < 0) { + "ManagedEntity", "parent", NULL) < 0) return -1; - } /* ComputeResource -> parent (Folder) */ if (esxVI_BuildSelectSet(&ctx->selectSet_computeResourceToParentToParent, "computeResourceToParent", "ComputeResource", "parent", - "managedEntityToParent\0") < 0) { + "managedEntityToParent\0") < 0) return -1; - } /* Datacenter -> network (Network) */ if (esxVI_BuildSelectSet(&ctx->selectSet_datacenterToNetwork, "datacenterToNetwork", - "Datacenter", "network", NULL) < 0) { + "Datacenter", "network", NULL) < 0) return -1; - } return 0; } @@ -2125,17 +2064,15 @@ esxVI_EnsureSession(esxVI_Context *ctx) * connection, and re-login if there isn't. */ if (esxVI_SessionIsActive(ctx, ctx->session->key, - ctx->session->userName, &active) < 0) { + ctx->session->userName, &active) < 0) goto cleanup; - } if (active != esxVI_Boolean_True) { esxVI_UserSession_Free(&ctx->session); if (esxVI_Login(ctx, ctx->username, ctx->password, NULL, - &ctx->session) < 0) { + &ctx->session) < 0) goto cleanup; - } } } else { /* @@ -2147,17 +2084,15 @@ esxVI_EnsureSession(esxVI_Context *ctx) esxVI_LookupObjectContentByType(ctx, ctx->service->sessionManager, "SessionManager", propertyNameList, &sessionManager, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = sessionManager->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "currentSession")) { if (esxVI_UserSession_CastFromAnyType(dynamicProperty->val, - ¤tSession) < 0) { + ¤tSession) < 0) goto cleanup; - } break; } else { @@ -2169,9 +2104,8 @@ esxVI_EnsureSession(esxVI_Context *ctx) esxVI_UserSession_Free(&ctx->session); if (esxVI_Login(ctx, ctx->username, ctx->password, NULL, - &ctx->session) < 0) { + &ctx->session) < 0) goto cleanup; - } } else if (STRNEQ(ctx->session->key, currentSession->key)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Key of the current session differs from the key at " @@ -2214,9 +2148,8 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, return -1; } - if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) { + if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) return -1; - } objectSpec->obj = root; objectSpec->skip = esxVI_Boolean_False; @@ -2275,32 +2208,28 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, } } - if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) { + if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) goto cleanup; - } propertySpec->type = (char *)type; propertySpec->pathSet = propertyNameList; if (esxVI_PropertyFilterSpec_Alloc(&propertyFilterSpec) < 0 || esxVI_PropertySpec_AppendToList(&propertyFilterSpec->propSet, - propertySpec) < 0) { + propertySpec) < 0) goto cleanup; - } propertySpec_isAppended = true; if (esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet, - objectSpec) < 0) { + objectSpec) < 0) goto cleanup; - } objectSpec_isAppended = true; if (esxVI_RetrieveProperties(ctx, propertyFilterSpec, - objectContentList) < 0) { + objectContentList) < 0) goto cleanup; - } if (!(*objectContentList)) { switch (occurrence) { @@ -2346,13 +2275,11 @@ esxVI_LookupObjectContentByType(esxVI_Context *ctx, propertySpec->pathSet = NULL; } - if (!objectSpec_isAppended) { + if (!objectSpec_isAppended) esxVI_ObjectSpec_Free(&objectSpec); - } - if (!propertySpec_isAppended) { + if (!propertySpec_isAppended) esxVI_PropertySpec_Free(&propertySpec); - } esxVI_PropertyFilterSpec_Free(&propertyFilterSpec); @@ -2423,9 +2350,8 @@ esxVI_GetVirtualMachineQuestionInfo dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "runtime.question")) { if (esxVI_VirtualMachineQuestionInfo_CastFromAnyType - (dynamicProperty->val, questionInfo) < 0) { + (dynamicProperty->val, questionInfo) < 0) return -1; - } } } @@ -2449,9 +2375,8 @@ esxVI_GetBoolean(esxVI_ObjectContent *objectContent, const char *propertyName, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, propertyName)) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_Boolean) < 0) { + esxVI_Type_Boolean) < 0) return -1; - } *value = dynamicProperty->val->boolean; break; @@ -2484,9 +2409,8 @@ esxVI_GetLong(esxVI_ObjectContent *objectContent, const char *propertyName, for (dynamicProperty = objectContent->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, propertyName)) { - if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0) { + if (esxVI_Long_CastFromAnyType(dynamicProperty->val, value) < 0) return -1; - } break; } @@ -2519,9 +2443,8 @@ esxVI_GetStringValue(esxVI_ObjectContent *objectContent, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, propertyName)) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) return -1; - } *value = dynamicProperty->val->string; break; @@ -2556,9 +2479,8 @@ esxVI_GetManagedObjectReference(esxVI_ObjectContent *objectContent, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, propertyName)) { if (esxVI_ManagedObjectReference_CastFromAnyType - (dynamicProperty->val, value) < 0) { + (dynamicProperty->val, value) < 0) return -1; - } break; } @@ -2591,9 +2513,8 @@ esxVI_LookupNumberOfDomainsByPowerState(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.powerState") < 0 || esxVI_LookupVirtualMachineList(ctx, propertyNameList, - &virtualMachineList) < 0) { + &virtualMachineList) < 0) goto cleanup; - } for (virtualMachine = virtualMachineList; virtualMachine; virtualMachine = virtualMachine->_next) { @@ -2602,14 +2523,12 @@ esxVI_LookupNumberOfDomainsByPowerState(esxVI_Context *ctx, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "runtime.powerState")) { if (esxVI_VirtualMachinePowerState_CastFromAnyType - (dynamicProperty->val, &powerState_) < 0) { + (dynamicProperty->val, &powerState_) < 0) goto cleanup; - } if ((!inverse && powerState_ == powerState) || - (inverse && powerState_ != powerState)) { + (inverse && powerState_ != powerState)) count++; - } } else { VIR_WARN("Unexpected '%s' property", dynamicProperty->name); } @@ -2662,9 +2581,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "name")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) goto failure; - } if (VIR_STRDUP(*name, dynamicProperty->val->string) < 0) goto failure; @@ -2688,9 +2606,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine, if (uuid) { if (esxVI_GetManagedEntityStatus(virtualMachine, "configStatus", - &configStatus) < 0) { + &configStatus) < 0) goto failure; - } if (configStatus == esxVI_ManagedEntityStatus_Green) { for (dynamicProperty = virtualMachine->propSet; @@ -2698,9 +2615,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.uuid")) { if (esxVI_AnyType_ExpectType(dynamicProperty->val, - esxVI_Type_String) < 0) { + esxVI_Type_String) < 0) goto failure; - } uuid_string = dynamicProperty->val->string; break; @@ -2730,9 +2646,8 @@ esxVI_GetVirtualMachineIdentity(esxVI_ObjectContent *virtualMachine, return 0; failure: - if (name) { + if (name) VIR_FREE(*name); - } return -1; } @@ -2781,9 +2696,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, count++; } - if (count >= nameslen) { + if (count >= nameslen) break; - } if (recurse) { result = esxVI_GetSnapshotTreeNames(snapshotTree->childSnapshotList, @@ -2791,9 +2705,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, nameslen - count, true, leaves); - if (result < 0) { + if (result < 0) goto failure; - } count += result; } @@ -2802,9 +2715,8 @@ esxVI_GetSnapshotTreeNames(esxVI_VirtualMachineSnapshotTree *snapshotTreeList, return count; failure: - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } return -1; } @@ -2838,9 +2750,8 @@ esxVI_GetSnapshotTreeByName if (esxVI_GetSnapshotTreeByName(candidate->childSnapshotList, name, snapshotTree, snapshotTreeParent, occurrence) > 0) { - if (snapshotTreeParent && !(*snapshotTreeParent)) { + if (snapshotTreeParent && !(*snapshotTreeParent)) *snapshotTreeParent = candidate; - } return 1; } @@ -2879,9 +2790,8 @@ esxVI_GetSnapshotTreeBySnapshot } if (esxVI_GetSnapshotTreeBySnapshot(candidate->childSnapshotList, - snapshot, snapshotTree) >= 0) { + snapshot, snapshotTree) >= 0) return 0; - } } virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, @@ -2940,9 +2850,8 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned char *uuid, if (esxVI_FindByUuid(ctx, ctx->datacenter->_reference, uuid_string, esxVI_Boolean_True, esxVI_Boolean_Undefined, - &managedObjectReference) < 0) { + &managedObjectReference) < 0) return -1; - } if (!managedObjectReference) { if (occurrence == esxVI_Occurrence_OptionalItem) { @@ -2960,9 +2869,8 @@ esxVI_LookupVirtualMachineByUuid(esxVI_Context *ctx, const unsigned char *uuid, if (esxVI_LookupObjectContentByType(ctx, managedObjectReference, "VirtualMachine", propertyNameList, virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } result = 0; @@ -2995,26 +2903,22 @@ esxVI_LookupVirtualMachineByName(esxVI_Context *ctx, const char *name, propertyNameList) < 0 || esxVI_String_AppendValueToList(&completePropertyNameList, "name") < 0 || esxVI_LookupVirtualMachineList(ctx, completePropertyNameList, - &virtualMachineList) < 0) { + &virtualMachineList) < 0) goto cleanup; - } for (candidate = virtualMachineList; candidate; candidate = candidate->_next) { VIR_FREE(name_candidate); if (esxVI_GetVirtualMachineIdentity(candidate, NULL, &name_candidate, - NULL) < 0) { + NULL) < 0) goto cleanup; - } - if (STRNEQ(name, name_candidate)) { + if (STRNEQ(name, name_candidate)) continue; - } - if (esxVI_ObjectContent_DeepCopy(virtualMachine, candidate) < 0) { + if (esxVI_ObjectContent_DeepCopy(virtualMachine, candidate) < 0) goto cleanup; - } break; } @@ -3066,16 +2970,14 @@ esxVI_LookupVirtualMachineByUuidAndPrepareForTask esxVI_GetVirtualMachineQuestionInfo(*virtualMachine, &questionInfo) < 0 || esxVI_LookupPendingTaskInfoListByVirtualMachine - (ctx, *virtualMachine, &pendingTaskInfoList) < 0) { + (ctx, *virtualMachine, &pendingTaskInfoList) < 0) goto cleanup; - } if (questionInfo && esxVI_HandleVirtualMachineQuestion(ctx, (*virtualMachine)->obj, questionInfo, autoAnswer, - &blocked) < 0) { + &blocked) < 0) goto cleanup; - } if (pendingTaskInfoList) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -3132,9 +3034,8 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name, esxVI_String_AppendValueToList(&completePropertyNameList, "summary.name") < 0 || esxVI_LookupDatastoreList(ctx, completePropertyNameList, - &datastoreList) < 0) { + &datastoreList) < 0) goto cleanup; - } /* Search for a matching datastore */ for (candidate = datastoreList; candidate; @@ -3142,14 +3043,12 @@ esxVI_LookupDatastoreByName(esxVI_Context *ctx, const char *name, name_candidate = NULL; if (esxVI_GetStringValue(candidate, "summary.name", &name_candidate, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (STREQ(name_candidate, name)) { - if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) { + if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) goto cleanup; - } /* Found datastore with matching name */ result = 0; @@ -3199,9 +3098,8 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx, propertyNameList) < 0 || esxVI_String_AppendValueToList(&completePropertyNameList, "host") < 0 || esxVI_LookupDatastoreList(ctx, completePropertyNameList, - &datastoreList) < 0) { + &datastoreList) < 0) goto cleanup; - } /* Search for a matching datastore */ for (candidate = datastoreList; candidate; @@ -3212,30 +3110,26 @@ esxVI_LookupDatastoreByAbsolutePath(esxVI_Context *ctx, dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "host")) { if (esxVI_DatastoreHostMount_CastListFromAnyType - (dynamicProperty->val, &datastoreHostMountList) < 0) { + (dynamicProperty->val, &datastoreHostMountList) < 0) goto cleanup; - } break; } } - if (!datastoreHostMountList) { + if (!datastoreHostMountList) continue; - } for (datastoreHostMount = datastoreHostMountList; datastoreHostMount; datastoreHostMount = datastoreHostMount->_next) { if (STRNEQ(ctx->hostSystem->_reference->value, - datastoreHostMount->key->value)) { + datastoreHostMount->key->value)) continue; - } if (STRPREFIX(absolutePath, datastoreHostMount->mountInfo->path)) { - if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) { + if (esxVI_ObjectContent_DeepCopy(datastore, candidate) < 0) goto cleanup; - } /* Found datastore with matching mount path */ result = 0; @@ -3285,17 +3179,15 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "host") < 0 || esxVI_LookupObjectContentByType(ctx, datastore, "Datastore", propertyNameList, &objectContent, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = objectContent->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "host")) { if (esxVI_DatastoreHostMount_CastListFromAnyType - (dynamicProperty->val, &hostMountList) < 0) { + (dynamicProperty->val, &hostMountList) < 0) goto cleanup; - } break; } else { @@ -3305,13 +3197,11 @@ esxVI_LookupDatastoreHostMount(esxVI_Context *ctx, for (candidate = hostMountList; candidate; candidate = candidate->_next) { - if (STRNEQ(ctx->hostSystem->_reference->value, candidate->key->value)) { + if (STRNEQ(ctx->hostSystem->_reference->value, candidate->key->value)) continue; - } - if (esxVI_DatastoreHostMount_DeepCopy(hostMount, candidate) < 0) { + if (esxVI_DatastoreHostMount_DeepCopy(hostMount, candidate) < 0) goto cleanup; - } break; } @@ -3351,17 +3241,15 @@ esxVI_LookupTaskInfoByTask(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "info") < 0 || esxVI_LookupObjectContentByType(ctx, task, "Task", propertyNameList, &objectContent, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = objectContent->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "info")) { if (esxVI_TaskInfo_CastFromAnyType(dynamicProperty->val, - taskInfo) < 0) { + taskInfo) < 0) goto cleanup; - } break; } else { @@ -3402,9 +3290,8 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "recentTask")) { if (esxVI_ManagedObjectReference_CastListFromAnyType - (dynamicProperty->val, &recentTaskList) < 0) { + (dynamicProperty->val, &recentTaskList) < 0) goto cleanup; - } break; } @@ -3413,16 +3300,14 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine /* Lookup task info for each task */ for (recentTask = recentTaskList; recentTask; recentTask = recentTask->_next) { - if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0) { + if (esxVI_LookupTaskInfoByTask(ctx, recentTask, &taskInfo) < 0) goto cleanup; - } if (taskInfo->state == esxVI_TaskInfoState_Queued || taskInfo->state == esxVI_TaskInfoState_Running) { if (esxVI_TaskInfo_AppendToList(pendingTaskInfoList, - taskInfo) < 0) { + taskInfo) < 0) goto cleanup; - } taskInfo = NULL; } else { @@ -3433,9 +3318,8 @@ esxVI_LookupPendingTaskInfoListByVirtualMachine result = 0; cleanup: - if (result < 0) { + if (result < 0) esxVI_TaskInfo_Free(pendingTaskInfoList); - } esxVI_String_Free(&propertyNameList); esxVI_ManagedObjectReference_Free(&recentTaskList); @@ -3460,22 +3344,19 @@ esxVI_LookupAndHandleVirtualMachineQuestion(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "runtime.question") < 0 || esxVI_LookupVirtualMachineByUuid(ctx, uuid, propertyNameList, - &virtualMachine, occurrence) < 0) { + &virtualMachine, occurrence) < 0) goto cleanup; - } if (virtualMachine) { if (esxVI_GetVirtualMachineQuestionInfo(virtualMachine, - &questionInfo) < 0) { + &questionInfo) < 0) goto cleanup; - } if (questionInfo && esxVI_HandleVirtualMachineQuestion(ctx, virtualMachine->obj, questionInfo, autoAnswer, - blocked) < 0) { + blocked) < 0) goto cleanup; - } } result = 0; @@ -3509,17 +3390,15 @@ esxVI_LookupRootSnapshotTreeList "snapshot.rootSnapshotList") < 0 || esxVI_LookupVirtualMachineByUuid(ctx, virtualMachineUuid, propertyNameList, &virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = virtualMachine->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "snapshot.rootSnapshotList")) { if (esxVI_VirtualMachineSnapshotTree_CastListFromAnyType - (dynamicProperty->val, rootSnapshotTreeList) < 0) { + (dynamicProperty->val, rootSnapshotTreeList) < 0) goto cleanup; - } break; } else { @@ -3530,9 +3409,8 @@ esxVI_LookupRootSnapshotTreeList result = 0; cleanup: - if (result < 0) { + if (result < 0) esxVI_VirtualMachineSnapshotTree_Free(rootSnapshotTreeList); - } esxVI_String_Free(&propertyNameList); esxVI_ObjectContent_Free(&virtualMachine); @@ -3566,22 +3444,19 @@ esxVI_LookupCurrentSnapshotTree "snapshot.rootSnapshotList\0") < 0 || esxVI_LookupVirtualMachineByUuid(ctx, virtualMachineUuid, propertyNameList, &virtualMachine, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = virtualMachine->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "snapshot.currentSnapshot")) { if (esxVI_ManagedObjectReference_CastFromAnyType - (dynamicProperty->val, ¤tSnapshot) < 0) { + (dynamicProperty->val, ¤tSnapshot) < 0) goto cleanup; - } } else if (STREQ(dynamicProperty->name, "snapshot.rootSnapshotList")) { if (esxVI_VirtualMachineSnapshotTree_CastListFromAnyType - (dynamicProperty->val, &rootSnapshotTreeList) < 0) { + (dynamicProperty->val, &rootSnapshotTreeList) < 0) goto cleanup; - } } else { VIR_WARN("Unexpected '%s' property", dynamicProperty->name); } @@ -3608,9 +3483,8 @@ esxVI_LookupCurrentSnapshotTree if (esxVI_GetSnapshotTreeBySnapshot(rootSnapshotTreeList, currentSnapshot, &snapshotTree) < 0 || esxVI_VirtualMachineSnapshotTree_DeepCopy(currentSnapshotTree, - snapshotTree) < 0) { + snapshotTree) < 0) goto cleanup; - } result = 0; @@ -3659,9 +3533,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, } if (esxUtil_ParseDatastorePath(datastorePath, &datastoreName, - &directoryName, &directoryAndFileName) < 0) { + &directoryName, &directoryAndFileName) < 0) goto cleanup; - } if (STREQ(directoryName, directoryAndFileName)) { /* @@ -3672,9 +3545,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, datastoreName) < 0) goto cleanup; - if (VIR_STRDUP(fileName, directoryAndFileName) < 0) { + if (VIR_STRDUP(fileName, directoryAndFileName) < 0) goto cleanup; - } } else { if (virAsprintf(&datastorePathWithoutFileName, "[%s] %s", datastoreName, directoryName) < 0) @@ -3690,9 +3562,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, goto cleanup; } - if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0) { + if (VIR_STRDUP(fileName, directoryAndFileName + length + 1) < 0) goto cleanup; - } } /* Lookup HostDatastoreBrowser */ @@ -3702,15 +3573,13 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetManagedObjectReference(datastore, "browser", &hostDatastoreBrowser, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* Build HostDatastoreBrowserSearchSpec */ if (esxVI_HostDatastoreBrowserSearchSpec_Alloc(&searchSpec) < 0 || - esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0) { + esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0) goto cleanup; - } searchSpec->details->fileType = esxVI_Boolean_True; searchSpec->details->fileSize = esxVI_Boolean_True; @@ -3720,18 +3589,16 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, if (esxVI_FolderFileQuery_Alloc(&folderFileQuery) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(folderFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(folderFileQuery)) < 0) goto cleanup; - } folderFileQuery = NULL; } else { if (esxVI_VmDiskFileQuery_Alloc(&vmDiskFileQuery) < 0 || esxVI_VmDiskFileQueryFlags_Alloc(&vmDiskFileQuery->details) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) goto cleanup; - } vmDiskFileQuery->details->diskType = esxVI_Boolean_False; vmDiskFileQuery->details->capacityKb = esxVI_Boolean_True; @@ -3743,23 +3610,20 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, if (esxVI_IsoImageFileQuery_Alloc(&isoImageFileQuery) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0) goto cleanup; - } isoImageFileQuery = NULL; if (esxVI_FloppyImageFileQuery_Alloc(&floppyImageFileQuery) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0) goto cleanup; - } floppyImageFileQuery = NULL; } - if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0) { + if (esxVI_String_Alloc(&searchSpec->matchPattern) < 0) goto cleanup; - } searchSpec->matchPattern->value = fileName; @@ -3769,9 +3633,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, &task) < 0 || esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None, false, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3782,9 +3645,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo) < 0 || esxVI_HostDatastoreBrowserSearchResults_CastFromAnyType - (taskInfo->result, &searchResults) < 0) { + (taskInfo->result, &searchResults) < 0) goto cleanup; - } /* Interpret search result */ if (!searchResults->file) { @@ -3807,9 +3669,8 @@ esxVI_LookupFileInfoByDatastorePath(esxVI_Context *ctx, cleanup: /* Don't double free fileName */ - if (searchSpec && searchSpec->matchPattern) { + if (searchSpec && searchSpec->matchPattern) searchSpec->matchPattern->value = NULL; - } VIR_FREE(datastoreName); VIR_FREE(directoryName); @@ -3865,15 +3726,13 @@ esxVI_LookupDatastoreContentByDatastoreName esxVI_Occurrence_RequiredItem) < 0 || esxVI_GetManagedObjectReference(datastore, "browser", &hostDatastoreBrowser, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } /* Build HostDatastoreBrowserSearchSpec */ if (esxVI_HostDatastoreBrowserSearchSpec_Alloc(&searchSpec) < 0 || - esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0) { + esxVI_FileQueryFlags_Alloc(&searchSpec->details) < 0) goto cleanup; - } searchSpec->details->fileType = esxVI_Boolean_True; searchSpec->details->fileSize = esxVI_Boolean_True; @@ -3883,9 +3742,8 @@ esxVI_LookupDatastoreContentByDatastoreName esxVI_VmDiskFileQueryFlags_Alloc(&vmDiskFileQuery->details) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(vmDiskFileQuery)) < 0) goto cleanup; - } vmDiskFileQuery->details->diskType = esxVI_Boolean_False; vmDiskFileQuery->details->capacityKb = esxVI_Boolean_True; @@ -3897,17 +3755,15 @@ esxVI_LookupDatastoreContentByDatastoreName if (esxVI_IsoImageFileQuery_Alloc(&isoImageFileQuery) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(isoImageFileQuery)) < 0) goto cleanup; - } isoImageFileQuery = NULL; if (esxVI_FloppyImageFileQuery_Alloc(&floppyImageFileQuery) < 0 || esxVI_FileQuery_AppendToList (&searchSpec->query, - esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0) { + esxVI_FileQuery_DynamicCast(floppyImageFileQuery)) < 0) goto cleanup; - } floppyImageFileQuery = NULL; /* Search datastore for files */ @@ -3919,9 +3775,8 @@ esxVI_LookupDatastoreContentByDatastoreName &task) < 0 || esxVI_WaitForTaskCompletion(ctx, task, NULL, esxVI_Occurrence_None, false, &taskInfoState, - &taskInfoErrorMessage) < 0) { + &taskInfoErrorMessage) < 0) goto cleanup; - } if (taskInfoState != esxVI_TaskInfoState_Success) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3932,9 +3787,8 @@ esxVI_LookupDatastoreContentByDatastoreName if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo) < 0 || esxVI_HostDatastoreBrowserSearchResults_CastListFromAnyType - (taskInfo->result, searchResultsList) < 0) { + (taskInfo->result, searchResultsList) < 0) goto cleanup; - } result = 0; @@ -3973,32 +3827,28 @@ esxVI_LookupStorageVolumeKeyByDatastorePath(esxVI_Context *ctx, if (ctx->hasQueryVirtualDiskUuid) { if (esxVI_LookupFileInfoByDatastorePath (ctx, datastorePath, false, &fileInfo, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (esxVI_VmDiskFileInfo_DynamicCast(fileInfo)) { /* VirtualDisks have a UUID, use it as key */ if (esxVI_QueryVirtualDiskUuid(ctx, datastorePath, ctx->datacenter->_reference, - &uuid_string) < 0) { + &uuid_string) < 0) goto cleanup; - } if (VIR_ALLOC_N(*key, VIR_UUID_STRING_BUFLEN) < 0) goto cleanup; - if (esxUtil_ReformatUuid(uuid_string, *key) < 0) { + if (esxUtil_ReformatUuid(uuid_string, *key) < 0) goto cleanup; - } } } if (!(*key)) { /* Other files don't have a UUID, fall back to the path as key */ - if (VIR_STRDUP(*key, datastorePath) < 0) { + if (VIR_STRDUP(*key, datastorePath) < 0) goto cleanup; - } } result = 0; @@ -4036,17 +3886,15 @@ esxVI_LookupAutoStartDefaults(esxVI_Context *ctx, esxVI_LookupObjectContentByType (ctx, ctx->hostSystem->configManager->autoStartManager, "HostAutoStartManager", propertyNameList, - &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0) { + &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = hostAutoStartManager->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.defaults")) { if (esxVI_AutoStartDefaults_CastFromAnyType(dynamicProperty->val, - defaults) < 0) { + defaults) < 0) goto cleanup; - } break; } @@ -4093,17 +3941,15 @@ esxVI_LookupAutoStartPowerInfoList(esxVI_Context *ctx, esxVI_LookupObjectContentByType (ctx, ctx->hostSystem->configManager->autoStartManager, "HostAutoStartManager", propertyNameList, - &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0) { + &hostAutoStartManager, esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } for (dynamicProperty = hostAutoStartManager->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.powerInfo")) { if (esxVI_AutoStartPowerInfo_CastListFromAnyType - (dynamicProperty->val, powerInfoList) < 0) { + (dynamicProperty->val, powerInfoList) < 0) goto cleanup; - } break; } @@ -4137,17 +3983,15 @@ esxVI_LookupPhysicalNicList(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "config.network.pnic") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.network.pnic")) { if (esxVI_PhysicalNic_CastListFromAnyType(dynamicProperty->val, - physicalNicList) < 0) { + physicalNicList) < 0) goto cleanup; - } } else { VIR_WARN("Unexpected '%s' property", dynamicProperty->name); } @@ -4178,17 +4022,15 @@ esxVI_LookupPhysicalNicByName(esxVI_Context *ctx, const char *name, return -1; } - if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) { + if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) goto cleanup; - } /* Search for a matching physical NIC */ for (candidate = physicalNicList; candidate; candidate = candidate->_next) { if (STRCASEEQ(candidate->device, name)) { - if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) { + if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) goto cleanup; - } /* Found physical NIC with matching name */ result = 0; @@ -4227,17 +4069,15 @@ esxVI_LookupPhysicalNicByMACAddress(esxVI_Context *ctx, const char *mac, return -1; } - if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) { + if (esxVI_LookupPhysicalNicList(ctx, &physicalNicList) < 0) goto cleanup; - } /* Search for a matching physical NIC */ for (candidate = physicalNicList; candidate; candidate = candidate->_next) { if (STRCASEEQ(candidate->mac, mac)) { - if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) { + if (esxVI_PhysicalNic_DeepCopy(physicalNic, candidate) < 0) goto cleanup; - } /* Found physical NIC with matching MAC address */ result = 0; @@ -4279,17 +4119,15 @@ esxVI_LookupHostVirtualSwitchList(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "config.network.vswitch") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.network.vswitch")) { if (esxVI_HostVirtualSwitch_CastListFromAnyType - (dynamicProperty->val, hostVirtualSwitchList) < 0) { + (dynamicProperty->val, hostVirtualSwitchList) < 0) goto cleanup; - } } else { VIR_WARN("Unexpected '%s' property", dynamicProperty->name); } @@ -4320,18 +4158,16 @@ esxVI_LookupHostVirtualSwitchByName(esxVI_Context *ctx, const char *name, return -1; } - if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0) { + if (esxVI_LookupHostVirtualSwitchList(ctx, &hostVirtualSwitchList) < 0) goto cleanup; - } /* Search for a matching HostVirtualSwitch */ for (candidate = hostVirtualSwitchList; candidate; candidate = candidate->_next) { if (STREQ(candidate->name, name)) { if (esxVI_HostVirtualSwitch_DeepCopy(hostVirtualSwitch, - candidate) < 0) { + candidate) < 0) goto cleanup; - } /* Found HostVirtualSwitch with matching name */ result = 0; @@ -4375,17 +4211,15 @@ esxVI_LookupHostPortGroupList(esxVI_Context *ctx, if (esxVI_String_AppendValueToList(&propertyNameList, "config.network.portgroup") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.network.portgroup")) { if (esxVI_HostPortGroup_CastListFromAnyType - (dynamicProperty->val, hostPortGroupList) < 0) { + (dynamicProperty->val, hostPortGroupList) < 0) goto cleanup; - } break; } else { @@ -4442,15 +4276,13 @@ esxVI_HandleVirtualMachineQuestion elementDescription = elementDescription->_next) { virBufferAsprintf(&buffer, "'%s'", elementDescription->label); - if (elementDescription->_next) { + if (elementDescription->_next) virBufferAddLit(&buffer, ", "); - } if (!answerChoice && questionInfo->choice->defaultIndex && - questionInfo->choice->defaultIndex->value == answerIndex) { + questionInfo->choice->defaultIndex->value == answerIndex) answerChoice = elementDescription; - } ++answerIndex; } @@ -4487,9 +4319,8 @@ esxVI_HandleVirtualMachineQuestion possibleAnswers, answerChoice->label); if (esxVI_AnswerVM(ctx, virtualMachine, questionInfo->id, - answerChoice->key) < 0) { + answerChoice->key) < 0) goto cleanup; - } } else { if (possibleAnswers) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -4510,9 +4341,8 @@ esxVI_HandleVirtualMachineQuestion result = 0; cleanup: - if (result < 0) { + if (result < 0) virBufferFreeAndReset(&buffer); - } VIR_FREE(possibleAnswers); @@ -4554,16 +4384,14 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, if (VIR_STRDUP(version, "") < 0) return -1; - if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) { + if (esxVI_ObjectSpec_Alloc(&objectSpec) < 0) goto cleanup; - } objectSpec->obj = task; objectSpec->skip = esxVI_Boolean_False; - if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) { + if (esxVI_PropertySpec_Alloc(&propertySpec) < 0) goto cleanup; - } propertySpec->type = task->type; @@ -4571,23 +4399,20 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, "info.state") < 0 || esxVI_PropertyFilterSpec_Alloc(&propertyFilterSpec) < 0 || esxVI_PropertySpec_AppendToList(&propertyFilterSpec->propSet, - propertySpec) < 0) { + propertySpec) < 0) goto cleanup; - } propertySpec_isAppended = true; if (esxVI_ObjectSpec_AppendToList(&propertyFilterSpec->objectSet, - objectSpec) < 0) { + objectSpec) < 0) goto cleanup; - } objectSpec_isAppended = true; if (esxVI_CreateFilter(ctx, propertyFilterSpec, esxVI_Boolean_True, - &propertyFilter) < 0) { + &propertyFilter) < 0) goto cleanup; - } while (state != esxVI_TaskInfoState_Success && state != esxVI_TaskInfoState_Error) { @@ -4602,9 +4427,8 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, * esxVI_LookupTaskInfoByTask() and esxVI_CancelTask() * don't overwrite the actual error */ - if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) { + if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) goto cleanup; - } if (taskInfo->cancelable == esxVI_Boolean_True) { if (esxVI_CancelTask(ctx, task) < 0 && blocked) { @@ -4623,17 +4447,15 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, } } - if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0) { + if (esxVI_WaitForUpdates(ctx, version, &updateSet) < 0) goto cleanup; - } VIR_FREE(version); if (VIR_STRDUP(version, updateSet->version) < 0) goto cleanup; - if (!updateSet->filterSet) { + if (!updateSet->filterSet) continue; - } for (propertyFilterUpdate = updateSet->filterSet; propertyFilterUpdate; @@ -4655,27 +4477,22 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, } } - if (!propertyValue) { + if (!propertyValue) continue; - } - if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, &state) < 0) { + if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, &state) < 0) goto cleanup; - } } - if (esxVI_DestroyPropertyFilter(ctx, propertyFilter) < 0) { + if (esxVI_DestroyPropertyFilter(ctx, propertyFilter) < 0) VIR_DEBUG("DestroyPropertyFilter failed"); - } - if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, finalState) < 0) { + if (esxVI_TaskInfoState_CastFromAnyType(propertyValue, finalState) < 0) goto cleanup; - } if (*finalState != esxVI_TaskInfoState_Success) { - if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) { + if (esxVI_LookupTaskInfoByTask(ctx, task, &taskInfo)) goto cleanup; - } if (!taskInfo->error) { if (VIR_STRDUP(*errorMessage, _("Unknown error")) < 0) @@ -4698,21 +4515,17 @@ esxVI_WaitForTaskCompletion(esxVI_Context *ctx, * Remove values given by the caller from the data structures to prevent * them from being freed by the call to esxVI_PropertyFilterSpec_Free(). */ - if (objectSpec) { + if (objectSpec) objectSpec->obj = NULL; - } - if (propertySpec) { + if (propertySpec) propertySpec->type = NULL; - } - if (!objectSpec_isAppended) { + if (!objectSpec_isAppended) esxVI_ObjectSpec_Free(&objectSpec); - } - if (!propertySpec_isAppended) { + if (!propertySpec_isAppended) esxVI_PropertySpec_Free(&propertySpec); - } esxVI_PropertyFilterSpec_Free(&propertyFilterSpec); esxVI_ManagedObjectReference_Free(&propertyFilter); @@ -4842,9 +4655,8 @@ esxVI_LookupHostInternetScsiHbaStaticTargetByName for (candidate = hostInternetScsiHba->configuredStaticTarget; candidate; candidate = candidate->_next) { - if (STREQ(candidate->iScsiName, name)) { + if (STREQ(candidate->iScsiName, name)) break; - } } if (!candidate) { @@ -4856,9 +4668,8 @@ esxVI_LookupHostInternetScsiHbaStaticTargetByName goto cleanup; } - if (esxVI_HostInternetScsiHbaStaticTarget_DeepCopy(target, candidate) < 0) { + if (esxVI_HostInternetScsiHbaStaticTarget_DeepCopy(target, candidate) < 0) goto cleanup; - } result = 0; @@ -4884,9 +4695,8 @@ esxVI_LookupHostInternetScsiHba(esxVI_Context *ctx, if (esxVI_String_AppendValueToList (&propertyNameList, "config.storageDevice.hostBusAdapter") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { @@ -4894,9 +4704,8 @@ esxVI_LookupHostInternetScsiHba(esxVI_Context *ctx, "config.storageDevice.hostBusAdapter")) { if (esxVI_HostHostBusAdapter_CastListFromAnyType (dynamicProperty->val, &hostHostBusAdapterList) < 0 || - !hostHostBusAdapterList) { + !hostHostBusAdapterList) goto cleanup; - } } else { VIR_WARN("Unexpected '%s' property", dynamicProperty->name); } @@ -4911,9 +4720,8 @@ esxVI_LookupHostInternetScsiHba(esxVI_Context *ctx, if (candidate) { if (esxVI_HostInternetScsiHba_DeepCopy(hostInternetScsiHba, - candidate) < 0) { + candidate) < 0) goto cleanup; - } break; } } @@ -4941,17 +4749,15 @@ esxVI_LookupScsiLunList(esxVI_Context *ctx, esxVI_ScsiLun **scsiLunList) if (esxVI_String_AppendValueToList(&propertyNameList, "config.storageDevice.scsiLun") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { if (STREQ(dynamicProperty->name, "config.storageDevice.scsiLun")) { if (esxVI_ScsiLun_CastListFromAnyType(dynamicProperty->val, - scsiLunList) < 0) { + scsiLunList) < 0) goto cleanup; - } break; } else { @@ -4994,9 +4800,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName (&propertyNameList, "config.storageDevice.scsiTopology.adapter") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { @@ -5005,9 +4810,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName esxVI_HostScsiTopologyInterface_Free(&hostScsiInterfaceList); if (esxVI_HostScsiTopologyInterface_CastListFromAnyType - (dynamicProperty->val, &hostScsiInterfaceList) < 0) { + (dynamicProperty->val, &hostScsiInterfaceList) < 0) goto cleanup; - } break; } else { @@ -5037,9 +4841,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName } } - if (!found || !hostScsiTopologyTarget) { + if (!found || !hostScsiTopologyTarget) goto cleanup; - } if (!hostScsiTopologyTarget->lun) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -5048,9 +4851,8 @@ esxVI_LookupHostScsiTopologyLunListByTargetName } if (esxVI_HostScsiTopologyLun_DeepCopyList(hostScsiTopologyLunList, - hostScsiTopologyTarget->lun) < 0) { + hostScsiTopologyTarget->lun) < 0) goto cleanup; - } result = 0; @@ -5089,9 +4891,8 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx, (&propertyNameList, "config.storageDevice.scsiTopology.adapter") < 0 || esxVI_LookupHostSystemProperties(ctx, propertyNameList, - &hostSystem) < 0) { + &hostSystem) < 0) goto cleanup; - } for (dynamicProperty = hostSystem->propSet; dynamicProperty; dynamicProperty = dynamicProperty->_next) { @@ -5100,9 +4901,8 @@ esxVI_LookupStoragePoolNameByScsiLunKey(esxVI_Context *ctx, esxVI_HostScsiTopologyInterface_Free(&hostScsiInterfaceList); if (esxVI_HostScsiTopologyInterface_CastListFromAnyType - (dynamicProperty->val, &hostScsiInterfaceList) < 0) { + (dynamicProperty->val, &hostScsiInterfaceList) < 0) goto cleanup; - } break; } else { @@ -5305,9 +5105,8 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx, if (esxVI_LookupObjectContentByType(ctx, root, type, propertyNameList, objectContentList, - esxVI_Occurrence_OptionalList) < 0) { + esxVI_Occurrence_OptionalList) < 0) goto cleanup; - } /* Search for a matching item */ if (name) { @@ -5316,9 +5115,8 @@ esxVI_LookupManagedObjectHelper(esxVI_Context *ctx, name_candidate = NULL; if (esxVI_GetStringValue(candidate, "name", &name_candidate, - esxVI_Occurrence_RequiredItem) < 0) { + esxVI_Occurrence_RequiredItem) < 0) goto cleanup; - } if (STREQ(name_candidate, name)) { /* Found item with matching name */ diff --git a/src/esx/esx_vi_methods.c b/src/esx/esx_vi_methods.c index 184b01f..7fbb652 100644 --- a/src/esx/esx_vi_methods.c +++ b/src/esx/esx_vi_methods.c @@ -239,9 +239,8 @@ esxVI_RetrieveServiceContent(esxVI_Context *ctx, if (esxVI_Context_Execute(ctx, "RetrieveServiceContent", request, &response, esxVI_Occurrence_RequiredItem) < 0 || - esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0) { + esxVI_ServiceContent_Deserialize(response->node, serviceContent) < 0) goto cleanup; - } result = 0; diff --git a/src/esx/esx_vi_types.c b/src/esx/esx_vi_types.c index 4c7dc30..e815f74 100644 --- a/src/esx/esx_vi_types.c +++ b/src/esx/esx_vi_types.c @@ -944,13 +944,11 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) return -1; } - if (!src) { + if (!src) return 0; - } - if (esxVI_AnyType_Alloc(dest) < 0) { + if (esxVI_AnyType_Alloc(dest) < 0) goto failure; - } (*dest)->_type = src->_type; (*dest)->node = xmlCopyNode(src->node, 1); @@ -964,9 +962,8 @@ esxVI_AnyType_DeepCopy(esxVI_AnyType **dest, esxVI_AnyType *src) (*dest)->type = src->type; if (VIR_STRDUP((*dest)->other, src->other) < 0 || - VIR_STRDUP((*dest)->value, src->value) < 0) { + VIR_STRDUP((*dest)->value, src->value) < 0) goto failure; - } switch (src->type) { case esxVI_Type_Boolean: @@ -1015,9 +1012,8 @@ esxVI_AnyType_Deserialize(xmlNodePtr node, esxVI_AnyType **anyType) return -1; } - if (esxVI_AnyType_Alloc(anyType) < 0) { + if (esxVI_AnyType_Alloc(anyType) < 0) return -1; - } (*anyType)->node = xmlCopyNode(node, 1); @@ -1151,9 +1147,8 @@ esxVI_String_ListContainsValue(esxVI_String *stringList, const char *value) esxVI_String *string; for (string = stringList; string; string = string->_next) { - if (STREQ(string->value, value)) { + if (STREQ(string->value, value)) return true; - } } return false; @@ -1167,16 +1162,14 @@ esxVI_String_AppendValueToList(esxVI_String **stringList, const char *value) { esxVI_String *string = NULL; - if (esxVI_String_Alloc(&string) < 0) { + if (esxVI_String_Alloc(&string) < 0) return -1; - } if (VIR_STRDUP(string->value, value) < 0) goto failure; - if (esxVI_String_AppendToList(stringList, string) < 0) { + if (esxVI_String_AppendToList(stringList, string) < 0) goto failure; - } return 0; @@ -1194,16 +1187,14 @@ esxVI_String_AppendValueListToList(esxVI_String **stringList, const char *value = valueList; while (value && *value != '\0') { - if (esxVI_String_AppendValueToList(&stringListToAppend, value) < 0) { + if (esxVI_String_AppendValueToList(&stringListToAppend, value) < 0) goto failure; - } value += strlen(value) + 1; } - if (esxVI_String_AppendToList(stringList, stringListToAppend) < 0) { + if (esxVI_String_AppendToList(stringList, stringListToAppend) < 0) goto failure; - } return 0; @@ -1230,9 +1221,8 @@ esxVI_String_DeepCopyValue(char **dest, const char *src) return -1; } - if (!src) { + if (!src) return 0; - } return VIR_STRDUP(*dest, src); } @@ -1263,9 +1253,8 @@ esxVI_String_SerializeValue(const char *value, const char *element, return -1; } - if (!value) { + if (!value) return 0; - } ESV_VI__XML_TAG__OPEN(output, element, "xsd:string"); @@ -1285,9 +1274,8 @@ esxVI_String_Deserialize(xmlNodePtr node, esxVI_String **string) } if (esxVI_String_Alloc(string) < 0 || - esxVI_String_DeserializeValue(node, &(*string)->value) < 0) { + esxVI_String_DeserializeValue(node, &(*string)->value) < 0) goto failure; - } return 0; @@ -1483,9 +1471,8 @@ esxVI_DateTime_Deserialize(xmlNodePtr node, esxVI_DateTime **dateTime) return -1; } - if (esxVI_DateTime_Alloc(dateTime) < 0) { + if (esxVI_DateTime_Alloc(dateTime) < 0) return -1; - } (*dateTime)->value = (char *)xmlNodeListGetString(node->doc, node->children, 1); @@ -1577,9 +1564,8 @@ esxVI_DateTime_ConvertToCalendarTime(esxVI_DateTime *dateTime, tz_offset = tz_hours * 60 * 60 + tz_minutes * 60; - if (sign == '-') { + if (sign == '-') tz_offset = -tz_offset; - } } else if (STREQ(tmp, "Z")) { /* Z refers to UTC. tz_offset is already initialized to zero */ } else { @@ -1657,9 +1643,8 @@ esxVI_MethodFault_Deserialize(xmlNodePtr node, esxVI_MethodFault **methodFault) return -1; } - if (esxVI_MethodFault_Alloc(methodFault) < 0) { + if (esxVI_MethodFault_Alloc(methodFault) < 0) return -1; - } (*methodFault)->_actualType = (char *)xmlGetNsProp(node, BAD_CAST "type", @@ -1723,9 +1708,8 @@ esxVI_ManagedObjectReference_Serialize return -1; } - if (!managedObjectReference) { + if (!managedObjectReference) return 0; - } virBufferAddLit(output, "<"); virBufferAdd(output, element, -1); @@ -1753,9 +1737,8 @@ esxVI_ManagedObjectReference_Deserialize return -1; } - if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0) { + if (esxVI_ManagedObjectReference_Alloc(managedObjectReference) < 0) return -1; - } (*managedObjectReference)->type = (char *)xmlGetNoNsProp(node, BAD_CAST "type"); @@ -1767,9 +1750,8 @@ esxVI_ManagedObjectReference_Deserialize } if (esxVI_String_DeserializeValue(node, - &(*managedObjectReference)->value) < 0) { + &(*managedObjectReference)->value) < 0) goto failure; - } return 0; -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/hyperv/hyperv_device_monitor.c | 3 +- src/hyperv/hyperv_driver.c | 132 ++++++++++++----------------------- src/hyperv/hyperv_interface_driver.c | 3 +- src/hyperv/hyperv_network_driver.c | 3 +- src/hyperv/hyperv_nwfilter_driver.c | 3 +- src/hyperv/hyperv_secret_driver.c | 3 +- src/hyperv/hyperv_storage_driver.c | 3 +- src/hyperv/hyperv_util.c | 6 +- src/hyperv/hyperv_wmi.c | 45 ++++-------- 9 files changed, 67 insertions(+), 134 deletions(-) diff --git a/src/hyperv/hyperv_device_monitor.c b/src/hyperv/hyperv_device_monitor.c index 5332eb2..88f81bf 100644 --- a/src/hyperv/hyperv_device_monitor.c +++ b/src/hyperv/hyperv_device_monitor.c @@ -40,9 +40,8 @@ hypervNodeDeviceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } conn->nodeDevicePrivateData = conn->privateData; diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 5ffcb85..9ff08af 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -49,9 +49,8 @@ VIR_LOG_INIT("hyperv.hyperv_driver"); static void hypervFreePrivate(hypervPrivate **priv) { - if (priv == NULL || *priv == NULL) { + if (priv == NULL || *priv == NULL) return; - } if ((*priv)->client != NULL) { /* FIXME: This leaks memory due to bugs in openwsman <= 2.2.6 */ @@ -78,22 +77,19 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); /* Decline if the URI is NULL or the scheme is NULL */ - if (conn->uri == NULL || conn->uri->scheme == NULL) { + if (conn->uri == NULL || conn->uri->scheme == NULL) return VIR_DRV_OPEN_DECLINED; - } /* Decline if the scheme is not hyperv */ plus = strchr(conn->uri->scheme, '+'); if (plus == NULL) { - if (STRCASENEQ(conn->uri->scheme, "hyperv")) { + if (STRCASENEQ(conn->uri->scheme, "hyperv")) return VIR_DRV_OPEN_DECLINED; - } } else { if (plus - conn->uri->scheme != 6 || - STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) { + STRCASENEQLEN(conn->uri->scheme, "hyperv", 6)) return VIR_DRV_OPEN_DECLINED; - } virReportError(VIR_ERR_INVALID_ARG, _("Transport '%s' in URI scheme is not supported, try again " @@ -119,9 +115,8 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags if (VIR_ALLOC(priv) < 0) goto cleanup; - if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) { + if (hypervParseUri(&priv->parsedUri, conn->uri) < 0) goto cleanup; - } /* Set the port dependent on the transport protocol if no port is * specified. This allows us to rely on the port parameter being @@ -182,9 +177,8 @@ hypervConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, unsigned int flags virBufferAddLit(&query, "where "); virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_PHYSICAL); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -239,9 +233,8 @@ hypervConnectGetHostname(virConnectPtr conn) virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT); - if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -276,9 +269,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) virBufferAddLit(&query, WIN32_COMPUTERSYSTEM_WQL_SELECT); /* Get Win32_ComputerSystem */ - if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetWin32ComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -295,9 +287,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) "ResultClass = Win32_Processor", computerSystem->data->Name); - if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0) { + if (hypervGetWin32ProcessorList(priv, &query, &processorList) < 0) goto cleanup; - } if (processorList == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -339,9 +330,8 @@ hypervNodeGetInfo(virConnectPtr conn, virNodeInfoPtr info) info->sockets = 0; for (processor = processorList; processor != NULL; - processor = processor->next) { + processor = processor->next) ++info->sockets; - } info->cores = processorList->data->NumberOfCores; info->threads = info->cores / processorList->data->NumberOfLogicalProcessors; @@ -368,9 +358,8 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids) Msvm_ComputerSystem *computerSystem = NULL; int count = 0; - if (maxids == 0) { + if (maxids == 0) return 0; - } virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); virBufferAddLit(&query, "where "); @@ -379,17 +368,15 @@ hypervConnectListDomains(virConnectPtr conn, int *ids, int maxids) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_ACTIVE); if (hypervGetMsvmComputerSystemList(priv, &query, - &computerSystemList) < 0) { + &computerSystemList) < 0) goto cleanup; - } for (computerSystem = computerSystemList; computerSystem != NULL; computerSystem = computerSystem->next) { ids[count++] = computerSystem->data->ProcessID; - if (count >= maxids) { + if (count >= maxids) break; - } } success = true; @@ -419,14 +406,12 @@ hypervConnectNumOfDomains(virConnectPtr conn) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_ACTIVE); if (hypervGetMsvmComputerSystemList(priv, &query, - &computerSystemList) < 0) { + &computerSystemList) < 0) goto cleanup; - } for (computerSystem = computerSystemList; computerSystem != NULL; - computerSystem = computerSystem->next) { + computerSystem = computerSystem->next) ++count; - } success = true; @@ -451,9 +436,8 @@ hypervDomainLookupByID(virConnectPtr conn, int id) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and ProcessID = %d", id); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, _("No domain with ID %d"), id); @@ -486,9 +470,8 @@ hypervDomainLookupByUUID(virConnectPtr conn, const unsigned char *uuid) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, @@ -519,9 +502,8 @@ hypervDomainLookupByName(virConnectPtr conn, const char *name) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and ElementName = \"%s\"", name); - if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, &computerSystem) < 0) goto cleanup; - } if (computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, @@ -546,9 +528,8 @@ hypervDomainSuspend(virDomainPtr domain) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_ENABLED) { @@ -575,9 +556,8 @@ hypervDomainResume(virDomainPtr domain) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSED) { @@ -607,9 +587,8 @@ hypervDomainDestroyFlags(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) || in_transition) { @@ -665,9 +644,8 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) virUUIDFormat(domain->uuid, uuid_string); /* Get Msvm_ComputerSystem */ - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } /* Get Msvm_VirtualSystemSettingData */ virBufferAsprintf(&query, @@ -679,9 +657,8 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) uuid_string); if (hypervGetMsvmVirtualSystemSettingDataList(priv, &query, - &virtualSystemSettingData) < 0) { + &virtualSystemSettingData) < 0) goto cleanup; - } if (virtualSystemSettingData == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -700,9 +677,8 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) virtualSystemSettingData->data->InstanceID); if (hypervGetMsvmProcessorSettingDataList(priv, &query, - &processorSettingData) < 0) { + &processorSettingData) < 0) goto cleanup; - } if (processorSettingData == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -721,9 +697,8 @@ hypervDomainGetInfo(virDomainPtr domain, virDomainInfoPtr info) virtualSystemSettingData->data->InstanceID); if (hypervGetMsvmMemorySettingDataList(priv, &query, - &memorySettingData) < 0) { + &memorySettingData) < 0) goto cleanup; - } if (memorySettingData == NULL) { @@ -764,15 +739,13 @@ hypervDomainGetState(virDomainPtr domain, int *state, int *reason, virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } *state = hypervMsvmComputerSystemEnabledStateToDomainState(computerSystem); - if (reason != NULL) { + if (reason != NULL) *reason = 0; - } result = 0; @@ -805,9 +778,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) virUUIDFormat(domain->uuid, uuid_string); /* Get Msvm_ComputerSystem */ - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } /* Get Msvm_VirtualSystemSettingData */ virBufferAsprintf(&query, @@ -819,9 +791,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) uuid_string); if (hypervGetMsvmVirtualSystemSettingDataList(priv, &query, - &virtualSystemSettingData) < 0) { + &virtualSystemSettingData) < 0) goto cleanup; - } if (virtualSystemSettingData == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -840,9 +811,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) virtualSystemSettingData->data->InstanceID); if (hypervGetMsvmProcessorSettingDataList(priv, &query, - &processorSettingData) < 0) { + &processorSettingData) < 0) goto cleanup; - } if (processorSettingData == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -861,9 +831,8 @@ hypervDomainGetXMLDesc(virDomainPtr domain, unsigned int flags) virtualSystemSettingData->data->InstanceID); if (hypervGetMsvmMemorySettingDataList(priv, &query, - &memorySettingData) < 0) { + &memorySettingData) < 0) goto cleanup; - } if (memorySettingData == NULL) { @@ -932,9 +901,8 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn int count = 0; size_t i; - if (maxnames == 0) { + if (maxnames == 0) return 0; - } virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_SELECT); virBufferAddLit(&query, "where "); @@ -943,9 +911,8 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_INACTIVE); if (hypervGetMsvmComputerSystemList(priv, &query, - &computerSystemList) < 0) { + &computerSystemList) < 0) goto cleanup; - } for (computerSystem = computerSystemList; computerSystem != NULL; computerSystem = computerSystem->next) { @@ -954,18 +921,16 @@ hypervConnectListDefinedDomains(virConnectPtr conn, char **const names, int maxn ++count; - if (count >= maxnames) { + if (count >= maxnames) break; - } } success = true; cleanup: if (!success) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) VIR_FREE(names[i]); - } count = -1; } @@ -994,14 +959,12 @@ hypervConnectNumOfDefinedDomains(virConnectPtr conn) virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_INACTIVE); if (hypervGetMsvmComputerSystemList(priv, &query, - &computerSystemList) < 0) { + &computerSystemList) < 0) goto cleanup; - } for (computerSystem = computerSystemList; computerSystem != NULL; - computerSystem = computerSystem->next) { + computerSystem = computerSystem->next) ++count; - } success = true; @@ -1022,9 +985,8 @@ hypervDomainCreateWithFlags(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { virReportError(VIR_ERR_OPERATION_INVALID, "%s", @@ -1103,9 +1065,8 @@ hypervDomainIsActive(virDomainPtr domain) hypervPrivate *priv = domain->conn->privateData; Msvm_ComputerSystem *computerSystem = NULL; - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } result = hypervIsMsvmComputerSystemActive(computerSystem, NULL) ? 1 : 0; @@ -1144,9 +1105,8 @@ hypervDomainManagedSave(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (!hypervIsMsvmComputerSystemActive(computerSystem, &in_transition) || in_transition) { @@ -1175,9 +1135,8 @@ hypervDomainHasManagedSaveImage(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } result = computerSystem->data->EnabledState == MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED ? 1 : 0; @@ -1199,9 +1158,8 @@ hypervDomainManagedSaveRemove(virDomainPtr domain, unsigned int flags) virCheckFlags(0, -1); - if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) { + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) goto cleanup; - } if (computerSystem->data->EnabledState != MSVM_COMPUTERSYSTEM_ENABLEDSTATE_SUSPENDED) { @@ -1338,9 +1296,8 @@ hypervConnectListAllDomains(virConnectPtr conn, cleanup: if (doms) { - for (i = 0; i < count; ++i) { + for (i = 0; i < count; ++i) virDomainFree(doms[i]); - } VIR_FREE(doms); } @@ -1424,9 +1381,8 @@ hypervRegister(void) hypervStorageRegister() < 0 || hypervDeviceRegister() < 0 || hypervSecretRegister() < 0 || - hypervNWFilterRegister() < 0) { + hypervNWFilterRegister() < 0) return -1; - } /* Forward openwsman errors and warnings to libvirt's logging */ debug_add_handler(hypervDebugHandler, DEBUG_LEVEL_WARNING, NULL); diff --git a/src/hyperv/hyperv_interface_driver.c b/src/hyperv/hyperv_interface_driver.c index b93cf30..a70b49e 100644 --- a/src/hyperv/hyperv_interface_driver.c +++ b/src/hyperv/hyperv_interface_driver.c @@ -40,9 +40,8 @@ hypervInterfaceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } conn->interfacePrivateData = conn->privateData; diff --git a/src/hyperv/hyperv_network_driver.c b/src/hyperv/hyperv_network_driver.c index 6f54f44..f9131c9 100644 --- a/src/hyperv/hyperv_network_driver.c +++ b/src/hyperv/hyperv_network_driver.c @@ -40,9 +40,8 @@ hypervNetworkOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } conn->networkPrivateData = conn->privateData; diff --git a/src/hyperv/hyperv_nwfilter_driver.c b/src/hyperv/hyperv_nwfilter_driver.c index a82db92..aa4934a 100644 --- a/src/hyperv/hyperv_nwfilter_driver.c +++ b/src/hyperv/hyperv_nwfilter_driver.c @@ -40,9 +40,8 @@ hypervNWFilterOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } conn->nwfilterPrivateData = conn->privateData; diff --git a/src/hyperv/hyperv_secret_driver.c b/src/hyperv/hyperv_secret_driver.c index 8176484..c503a11 100644 --- a/src/hyperv/hyperv_secret_driver.c +++ b/src/hyperv/hyperv_secret_driver.c @@ -40,9 +40,8 @@ hypervSecretOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } conn->secretPrivateData = conn->privateData; diff --git a/src/hyperv/hyperv_storage_driver.c b/src/hyperv/hyperv_storage_driver.c index af3cca4..035adcf 100644 --- a/src/hyperv/hyperv_storage_driver.c +++ b/src/hyperv/hyperv_storage_driver.c @@ -40,9 +40,8 @@ hypervStorageOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (conn->driver->no != VIR_DRV_HYPERV) { + if (conn->driver->no != VIR_DRV_HYPERV) return VIR_DRV_OPEN_DECLINED; - } conn->storagePrivateData = conn->privateData; diff --git a/src/hyperv/hyperv_util.c b/src/hyperv/hyperv_util.c index ebf9eac..73b3269 100644 --- a/src/hyperv/hyperv_util.c +++ b/src/hyperv/hyperv_util.c @@ -78,9 +78,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) result = 0; cleanup: - if (result < 0) { + if (result < 0) hypervFreeParsedUri(parsedUri); - } return result; } @@ -90,9 +89,8 @@ hypervParseUri(hypervParsedUri **parsedUri, virURIPtr uri) void hypervFreeParsedUri(hypervParsedUri **parsedUri) { - if (parsedUri == NULL || *parsedUri == NULL) { + if (parsedUri == NULL || *parsedUri == NULL) return; - } VIR_FREE((*parsedUri)->transport); diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 3027601..537ac86 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -157,9 +157,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, response = wsmc_action_enumerate(priv->client, root, options, filter); - if (hyperyVerifyResponse(priv->client, response, "enumeration") < 0) { + if (hyperyVerifyResponse(priv->client, response, "enumeration") < 0) goto cleanup; - } enumContext = wsmc_get_enum_context(response); @@ -170,9 +169,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, response = wsmc_action_pull(priv->client, resourceUri, options, filter, enumContext); - if (hyperyVerifyResponse(priv->client, response, "pull") < 0) { + if (hyperyVerifyResponse(priv->client, response, "pull") < 0) goto cleanup; - } node = ws_xml_get_soap_body(response); @@ -198,9 +196,8 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, goto cleanup; } - if (ws_xml_get_child(node, 0, resourceUri, className) == NULL) { + if (ws_xml_get_child(node, 0, resourceUri, className) == NULL) break; - } data = ws_deserialize(serializerContext, node, serializerInfo, className, resourceUri, NULL, 0, 0); @@ -240,22 +237,19 @@ hypervEnumAndPull(hypervPrivate *priv, virBufferPtr query, const char *root, result = 0; cleanup: - if (options != NULL) { + if (options != NULL) wsmc_options_destroy(options); - } - if (filter != NULL) { + if (filter != NULL) filter_destroy(filter); - } if (data != NULL) { #if WS_SERIALIZER_FREE_MEM_WORKS /* FIXME: ws_serializer_free_mem is broken in openwsman <= 2.2.6, * see hypervFreeObject for a detailed explanation. */ if (ws_serializer_free_mem(serializerContext, data, - serializerInfo) < 0) { + serializerInfo) < 0) VIR_ERROR(_("Could not free deserialized data")); - } #endif } @@ -275,9 +269,8 @@ hypervFreeObject(hypervPrivate *priv ATTRIBUTE_UNUSED, hypervObject *object) WsSerializerContextH serializerContext; #endif - if (object == NULL) { + if (object == NULL) return; - } #if WS_SERIALIZER_FREE_MEM_WORKS serializerContext = wsmc_get_serialization_context(priv->client); @@ -294,9 +287,8 @@ hypervFreeObject(hypervPrivate *priv ATTRIBUTE_UNUSED, hypervObject *object) * memory leak, but just in piling up unused memory until * the connection is closed. */ if (ws_serializer_free_mem(serializerContext, object->data, - object->serializerInfo) < 0) { + object->serializerInfo) < 0) VIR_ERROR(_("Could not free deserialized data")); - } #endif VIR_FREE(object); @@ -431,9 +423,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, response = wsmc_action_invoke(priv->client, MSVM_COMPUTERSYSTEM_RESOURCE_URI, options, "RequestStateChange", NULL); - if (hyperyVerifyResponse(priv->client, response, "invocation") < 0) { + if (hyperyVerifyResponse(priv->client, response, "invocation") < 0) goto cleanup; - } /* Check return value */ returnValue = ws_xml_get_xpath_value(response, (char *)"/s:Envelope/s:Body/p:RequestStateChange_OUTPUT/p:ReturnValue"); @@ -468,9 +459,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, virBufferAddLit(&query, MSVM_CONCRETEJOB_WQL_SELECT); virBufferAsprintf(&query, "where InstanceID = \"%s\"", instanceID); - if (hypervGetMsvmConcreteJobList(priv, &query, &concreteJob) < 0) { + if (hypervGetMsvmConcreteJobList(priv, &query, &concreteJob) < 0) goto cleanup; - } if (concreteJob == NULL) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -521,9 +511,8 @@ hypervInvokeMsvmComputerSystemRequestStateChange(virDomainPtr domain, result = 0; cleanup: - if (options != NULL) { + if (options != NULL) wsmc_options_destroy(options); - } ws_xml_destroy_doc(response); VIR_FREE(selector); @@ -576,9 +565,8 @@ bool hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *computerSystem, bool *in_transition) { - if (in_transition != NULL) { + if (in_transition != NULL) *in_transition = false; - } switch (computerSystem->data->EnabledState) { case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_UNKNOWN: @@ -602,9 +590,8 @@ hypervIsMsvmComputerSystemActive(Msvm_ComputerSystem *computerSystem, case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_STOPPING: case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_PAUSING: case MSVM_COMPUTERSYSTEM_ENABLEDSTATE_RESUMING: - if (in_transition != NULL) { + if (in_transition != NULL) *in_transition = true; - } return true; @@ -634,9 +621,8 @@ hypervMsvmComputerSystemToDomain(virConnectPtr conn, *domain = virGetDomain(conn, computerSystem->data->ElementName, uuid); - if (*domain == NULL) { + if (*domain == NULL) return -1; - } if (hypervIsMsvmComputerSystemActive(computerSystem, NULL)) { (*domain)->id = computerSystem->data->ProcessID; @@ -667,9 +653,8 @@ hypervMsvmComputerSystemFromDomain(virDomainPtr domain, virBufferAddLit(&query, MSVM_COMPUTERSYSTEM_WQL_VIRTUAL); virBufferAsprintf(&query, "and Name = \"%s\"", uuid_string); - if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0) { + if (hypervGetMsvmComputerSystemList(priv, &query, computerSystem) < 0) return -1; - } if (*computerSystem == NULL) { virReportError(VIR_ERR_NO_DOMAIN, -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/node_device/node_device_driver.c | 33 ++---- src/node_device/node_device_hal.c | 6 +- src/node_device/node_device_udev.c | 222 ++++++++++++----------------------- 3 files changed, 87 insertions(+), 174 deletions(-) diff --git a/src/node_device/node_device_driver.c b/src/node_device/node_device_driver.c index 5d58ca7..f564be7 100644 --- a/src/node_device/node_device_driver.c +++ b/src/node_device/node_device_driver.c @@ -48,9 +48,8 @@ static int update_caps(virNodeDeviceObjPtr dev) virNodeDevCapsDefPtr cap = dev->def->caps; while (cap) { - if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) { + if (cap->type == VIR_NODE_DEV_CAP_SCSI_HOST) detect_scsi_host_caps(&dev->def->caps->data); - } if (cap->type == VIR_NODE_DEV_CAP_NET && virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0) return -1; @@ -494,14 +493,12 @@ find_new_device(virConnectPtr conn, const char *wwnn, const char *wwpn) dev = nodeDeviceLookupSCSIHostByWWN(conn, wwnn, wwpn, 0); - if (dev != NULL) { + if (dev != NULL) break; - } sleep(5); - if (get_time(&now) == -1) { + if (get_time(&now) == -1) break; - } } nodeDeviceLock(driver); @@ -527,38 +524,33 @@ nodeDeviceCreateXML(virConnectPtr conn, nodeDeviceLock(driver); def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, virt_type); - if (def == NULL) { + if (def == NULL) goto cleanup; - } if (virNodeDeviceCreateXMLEnsureACL(conn, def) < 0) goto cleanup; - if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) { + if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) goto cleanup; - } if (virNodeDeviceGetParentHost(&driver->devs, def->name, def->parent, - &parent_host) == -1) { + &parent_host) == -1) goto cleanup; - } if (virManageVport(parent_host, wwpn, wwnn, - VPORT_CREATE) == -1) { + VPORT_CREATE) == -1) goto cleanup; - } dev = find_new_device(conn, wwnn, wwpn); /* We don't check the return value, because one way or another, * we're returning what we get... */ - if (dev == NULL) { + if (dev == NULL) virReportError(VIR_ERR_NO_NODE_DEVICE, NULL); - } cleanup: nodeDeviceUnlock(driver); @@ -590,9 +582,8 @@ nodeDeviceDestroy(virNodeDevicePtr dev) if (virNodeDeviceDestroyEnsureACL(dev->conn, obj->def) < 0) goto out; - if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) { + if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) goto out; - } /* virNodeDeviceGetParentHost will cause the device object's lock to be @@ -610,16 +601,14 @@ nodeDeviceDestroy(virNodeDevicePtr dev) if (virNodeDeviceGetParentHost(&driver->devs, dev->name, parent_name, - &parent_host) == -1) { + &parent_host) == -1) goto out; - } if (virManageVport(parent_host, wwpn, wwnn, - VPORT_DELETE) == -1) { + VPORT_DELETE) == -1) goto out; - } ret = 0; out: diff --git a/src/node_device/node_device_hal.c b/src/node_device/node_device_hal.c index ec37223..c32b1fe 100644 --- a/src/node_device/node_device_hal.c +++ b/src/node_device/node_device_hal.c @@ -255,9 +255,8 @@ gather_scsi_host_cap(LibHalContext *ctx, const char *udi, retval = detect_scsi_host_caps(d); - if (retval == -1) { + if (retval == -1) goto out; - } out: return retval; @@ -551,9 +550,8 @@ dev_refresh(const char *udi) } nodeDeviceUnlock(driverState); - if (dev) { + if (dev) dev_create(udi); - } } static void diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c index f580a9b..7b47be8 100644 --- a/src/node_device/node_device_udev.c +++ b/src/node_device/node_device_udev.c @@ -166,9 +166,8 @@ static int udevGetIntProperty(struct udev_device *udev_device, ret = udevGetDeviceProperty(udev_device, property_key, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_i(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_i(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -187,9 +186,8 @@ static int udevGetUintProperty(struct udev_device *udev_device, ret = udevGetDeviceProperty(udev_device, property_key, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -266,9 +264,8 @@ static int udevGetIntSysfsAttr(struct udev_device *udev_device, ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_i(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_i(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -287,9 +284,8 @@ static int udevGetUintSysfsAttr(struct udev_device *udev_device, ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) { + if (udevStrToLong_ui(udev_value, NULL, base, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -307,9 +303,8 @@ static int udevGetUint64SysfsAttr(struct udev_device *udev_device, ret = udevGetDeviceSysfsAttr(udev_device, attr_name, &udev_value); if (ret == PROPERTY_FOUND) { - if (udevStrToLong_ull(udev_value, NULL, 0, value) != 0) { + if (udevStrToLong_ull(udev_value, NULL, 0, value) != 0) ret = PROPERTY_ERROR; - } } VIR_FREE(udev_value); @@ -329,9 +324,8 @@ static int udevGenerateDeviceName(struct udev_device *device, udev_device_get_subsystem(device), udev_device_get_sysname(device)); - if (s != NULL) { + if (s != NULL) virBufferAsprintf(&buf, "_%s", s); - } if (virBufferCheckError(&buf) < 0) return -1; @@ -339,9 +333,8 @@ static int udevGenerateDeviceName(struct udev_device *device, def->name = virBufferContentAndReset(&buf); for (i = 0; i < strlen(def->name); i++) { - if (!(c_isalnum(*(def->name + i)))) { + if (!(c_isalnum(*(def->name + i)))) *(def->name + i) = '_'; - } } return ret; @@ -435,64 +428,55 @@ static int udevProcessPCI(struct udev_device *device, if (udevGetUintProperty(device, "PCI_CLASS", &data->pci_dev.class, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } p = strrchr(syspath, '/'); if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 16, - &data->pci_dev.domain) == -1)) { + &data->pci_dev.domain) == -1)) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 16, - &data->pci_dev.bus) == -1)) { + &data->pci_dev.bus) == -1)) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 16, - &data->pci_dev.slot) == -1)) { + &data->pci_dev.slot) == -1)) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 16, - &data->pci_dev.function) == -1)) { + &data->pci_dev.function) == -1)) goto out; - } if (udevGetUintSysfsAttr(device, "vendor", &data->pci_dev.vendor, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } if (udevGetUintSysfsAttr(device, "device", &data->pci_dev.product, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } if (udevTranslatePCIIds(data->pci_dev.vendor, data->pci_dev.product, &data->pci_dev.vendor_name, - &data->pci_dev.product_name) != 0) { + &data->pci_dev.product_name) != 0) goto out; - } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } rc = udevGetIntSysfsAttr(device, "numa_node", @@ -585,23 +569,20 @@ static int udevProcessUSBDevice(struct udev_device *device, if (udevGetUintProperty(device, "BUSNUM", &data->usb_dev.bus, - 10) == PROPERTY_ERROR) { + 10) == PROPERTY_ERROR) goto out; - } if (udevGetUintProperty(device, "DEVNUM", &data->usb_dev.device, - 10) == PROPERTY_ERROR) { + 10) == PROPERTY_ERROR) goto out; - } if (udevGetUintProperty(device, "ID_VENDOR_ID", &data->usb_dev.vendor, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } err = udevGetStringProperty(device, "ID_VENDOR_FROM_DATABASE", @@ -611,17 +592,15 @@ static int udevProcessUSBDevice(struct udev_device *device, if (err == PROPERTY_MISSING) { if (udevGetStringSysfsAttr(device, "manufacturer", - &data->usb_dev.vendor_name) == PROPERTY_ERROR) { + &data->usb_dev.vendor_name) == PROPERTY_ERROR) goto out; - } } if (udevGetUintProperty(device, "ID_MODEL_ID", &data->usb_dev.product, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } err = udevGetStringProperty(device, "ID_MODEL_FROM_DATABASE", @@ -631,14 +610,12 @@ static int udevProcessUSBDevice(struct udev_device *device, if (err == PROPERTY_MISSING) { if (udevGetStringSysfsAttr(device, "product", - &data->usb_dev.product_name) == PROPERTY_ERROR) { + &data->usb_dev.product_name) == PROPERTY_ERROR) goto out; - } } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -656,34 +633,29 @@ static int udevProcessUSBInterface(struct udev_device *device, if (udevGetUintSysfsAttr(device, "bInterfaceNumber", &data->usb_if.number, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } if (udevGetUintSysfsAttr(device, "bInterfaceClass", &data->usb_if._class, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } if (udevGetUintSysfsAttr(device, "bInterfaceSubClass", &data->usb_if.subclass, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } if (udevGetUintSysfsAttr(device, "bInterfaceProtocol", &data->usb_if.protocol, - 16) == PROPERTY_ERROR) { + 16) == PROPERTY_ERROR) goto out; - } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -707,26 +679,22 @@ static int udevProcessNetworkInterface(struct udev_device *device, if (udevGetStringProperty(device, "INTERFACE", - &data->net.ifname) == PROPERTY_ERROR) { + &data->net.ifname) == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "address", - &data->net.address) == PROPERTY_ERROR) { + &data->net.address) == PROPERTY_ERROR) goto out; - } if (udevGetUintSysfsAttr(device, "addr_len", &data->net.address_len, - 0) == PROPERTY_ERROR) { + 0) == PROPERTY_ERROR) goto out; - } - if (udevGenerateDeviceName(device, def, data->net.address) != 0) { + if (udevGenerateDeviceName(device, def, data->net.address) != 0) goto out; - } if (virNetDevGetLinkInfo(data->net.ifname, &data->net.lnk) < 0) goto out; @@ -756,15 +724,13 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED, if (udevStrToLong_ui(filename + strlen("host"), NULL, 0, - &data->scsi_host.host) == -1) { + &data->scsi_host.host) == -1) goto out; - } detect_scsi_host_caps(&def->caps->data); - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -785,9 +751,8 @@ static int udevProcessSCSITarget(struct udev_device *device ATTRIBUTE_UNUSED, if (VIR_STRDUP(data->scsi_target.name, sysname) < 0) goto out; - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -864,36 +829,31 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, filename = last_component(def->sysfs_path); - if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1) { + if (udevStrToLong_ui(filename, &p, 10, &data->scsi.host) == -1) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 10, - &data->scsi.bus) == -1)) { + &data->scsi.bus) == -1)) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 10, - &data->scsi.target) == -1)) { + &data->scsi.target) == -1)) goto out; - } if ((p == NULL) || (udevStrToLong_ui(p+1, &p, 10, - &data->scsi.lun) == -1)) { + &data->scsi.lun) == -1)) goto out; - } switch (udevGetUintSysfsAttr(device, "type", &tmp, 0)) { case PROPERTY_FOUND: - if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1) { + if (udevGetSCSIType(def, tmp, &data->scsi.type) == -1) goto out; - } break; case PROPERTY_MISSING: break; /* No type is not an error */ @@ -903,9 +863,8 @@ static int udevProcessSCSIDevice(struct udev_device *device ATTRIBUTE_UNUSED, break; } - if (udevGenerateDeviceName(device, def, NULL) != 0) { + if (udevGenerateDeviceName(device, def, NULL) != 0) goto out; - } ret = 0; @@ -926,16 +885,14 @@ static int udevProcessDisk(struct udev_device *device, if (udevGetUint64SysfsAttr(device, "size", - &data->storage.num_blocks) == PROPERTY_ERROR) { + &data->storage.num_blocks) == PROPERTY_ERROR) goto out; - } if (udevGetUint64SysfsAttr(device, "queue/logical_block_size", &data->storage.logical_block_size) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } data->storage.size = data->storage.num_blocks * data->storage.logical_block_size; @@ -953,9 +910,8 @@ static int udevProcessRemoveableMedia(struct udev_device *device, int tmp_int = 0, ret = 0; if ((udevGetIntSysfsAttr(device, "removable", &tmp_int, 0) == PROPERTY_FOUND) && - (tmp_int == 1)) { + (tmp_int == 1)) def->caps->data.storage.flags |= VIR_NODE_DEV_CAP_STORAGE_REMOVABLE; - } if (has_media) { @@ -963,21 +919,18 @@ static int udevProcessRemoveableMedia(struct udev_device *device, VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE; if (udevGetStringProperty(device, "ID_FS_LABEL", - &data->storage.media_label) == PROPERTY_ERROR) { + &data->storage.media_label) == PROPERTY_ERROR) goto out; - } if (udevGetUint64SysfsAttr(device, "size", - &data->storage.num_blocks) == PROPERTY_ERROR) { + &data->storage.num_blocks) == PROPERTY_ERROR) goto out; - } if (udevGetUint64SysfsAttr(device, "queue/logical_block_size", - &data->storage.logical_block_size) == PROPERTY_ERROR) { + &data->storage.logical_block_size) == PROPERTY_ERROR) goto out; - } /* XXX This calculation is wrong for the qemu virtual cdrom * which reports the size in 512 byte blocks, but the logical @@ -1046,16 +999,14 @@ static int udevProcessSD(struct udev_device *device, if (udevGetUint64SysfsAttr(device, "size", - &data->storage.num_blocks) == PROPERTY_ERROR) { + &data->storage.num_blocks) == PROPERTY_ERROR) goto out; - } if (udevGetUint64SysfsAttr(device, "queue/logical_block_size", &data->storage.logical_block_size) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } data->storage.size = data->storage.num_blocks * data->storage.logical_block_size; @@ -1099,9 +1050,8 @@ static int udevKludgeStorageType(virNodeDeviceDefPtr def) static void udevStripSpaces(char *s) { - if (s == NULL) { + if (s == NULL) return; - } while (virFileStripSuffix(s, " ")) { /* do nothing */ @@ -1130,25 +1080,21 @@ static int udevProcessStorage(struct udev_device *device, if (udevGetStringProperty(device, "ID_BUS", - &data->storage.bus) == PROPERTY_ERROR) { + &data->storage.bus) == PROPERTY_ERROR) goto out; - } if (udevGetStringProperty(device, "ID_SERIAL", - &data->storage.serial) == PROPERTY_ERROR) { + &data->storage.serial) == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "device/vendor", - &data->storage.vendor) == PROPERTY_ERROR) { + &data->storage.vendor) == PROPERTY_ERROR) goto out; - } udevStripSpaces(def->caps->data.storage.vendor); if (udevGetStringSysfsAttr(device, "device/model", - &data->storage.model) == PROPERTY_ERROR) { + &data->storage.model) == PROPERTY_ERROR) goto out; - } udevStripSpaces(def->caps->data.storage.model); /* There is no equivalent of the hotpluggable property in libudev, * but storage is going toward a world in which hotpluggable is @@ -1184,9 +1130,8 @@ static int udevProcessStorage(struct udev_device *device, } else { /* If udev doesn't have it, perhaps we can guess it. */ - if (udevKludgeStorageType(def) != 0) { + if (udevKludgeStorageType(def) != 0) goto out; - } } } @@ -1204,9 +1149,8 @@ static int udevProcessStorage(struct udev_device *device, goto out; } - if (udevGenerateDeviceName(device, def, data->storage.serial) != 0) { + if (udevGenerateDeviceName(device, def, data->storage.serial) != 0) goto out; - } out: VIR_DEBUG("Storage ret=%d", ret); @@ -1376,9 +1320,8 @@ static int udevSetParent(struct udev_device *device, do { parent_device = udev_device_get_parent(parent_device); - if (parent_device == NULL) { + if (parent_device == NULL) break; - } parent_sysfs_path = udev_device_get_syspath(parent_device); if (parent_sysfs_path == NULL) { @@ -1427,24 +1370,20 @@ static int udevAddOneDevice(struct udev_device *device) if (udevGetStringProperty(device, "DRIVER", - &def->driver) == PROPERTY_ERROR) { + &def->driver) == PROPERTY_ERROR) goto out; - } if (VIR_ALLOC(def->caps) != 0) goto out; - if (udevGetDeviceType(device, &def->caps->type) != 0) { + if (udevGetDeviceType(device, &def->caps->type) != 0) goto out; - } - if (udevGetDeviceDetails(device, def) != 0) { + if (udevGetDeviceDetails(device, def) != 0) goto out; - } - if (udevSetParent(device, def) != 0) { + if (udevSetParent(device, def) != 0) goto out; - } /* If this is a device change, the old definition will be freed * and the current definition will take its place. */ @@ -1544,9 +1483,8 @@ static int nodeStateCleanup(void) udev_monitor_unref(udev_monitor); } - if (udev != NULL) { + if (udev != NULL) udev_unref(udev); - } virNodeDeviceObjListFree(&driverState->devs); nodeDeviceUnlock(driverState); @@ -1635,27 +1573,23 @@ udevGetDMIData(union _virNodeDevCapData *data) if (udevGetStringSysfsAttr(device, "product_name", - &data->system.product_name) == PROPERTY_ERROR) { + &data->system.product_name) == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "sys_vendor", &data->system.hardware.vendor_name) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "product_version", &data->system.hardware.version) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "product_serial", &data->system.hardware.serial) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } if (virGetHostUUID(data->system.hardware.uuid)) goto out; @@ -1663,27 +1597,23 @@ udevGetDMIData(union _virNodeDevCapData *data) if (udevGetStringSysfsAttr(device, "bios_vendor", &data->system.firmware.vendor_name) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "bios_version", &data->system.firmware.version) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } if (udevGetStringSysfsAttr(device, "bios_date", &data->system.firmware.release_date) - == PROPERTY_ERROR) { + == PROPERTY_ERROR) goto out; - } out: VIR_FREE(tmp); - if (device != NULL) { + if (device != NULL) udev_device_unref(device); - } return; } #endif @@ -1719,9 +1649,8 @@ static int udevSetupSystemDev(void) ret = 0; out: - if (ret == -1) { + if (ret == -1) virNodeDeviceDefFree(def); - } return ret; } @@ -1834,9 +1763,8 @@ static int nodeStateInitialize(bool privileged, nodeDeviceUnlock(driverState); out: - if (ret == -1) { + if (ret == -1) nodeStateCleanup(); - } return ret; } @@ -1853,9 +1781,8 @@ static virDrvOpenStatus nodeDeviceOpen(virConnectPtr conn, { virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); - if (driverState == NULL) { + if (driverState == NULL) return VIR_DRV_OPEN_DECLINED; - } conn->nodeDevicePrivateData = driverState; @@ -1896,9 +1823,8 @@ int udevNodeRegister(void) { VIR_DEBUG("Registering udev node device backend"); - if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) { + if (virRegisterNodeDeviceDriver(&udevNodeDeviceDriver) < 0) return -1; - } return virRegisterStateDriver(&udevStateDriver); } -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/qemu/qemu_agent.c | 3 +-- src/qemu/qemu_capabilities.c | 15 ++++-------- src/qemu/qemu_cgroup.c | 12 ++++------ src/qemu/qemu_command.c | 42 +++++++++++--------------------- src/qemu/qemu_conf.c | 3 +-- src/qemu/qemu_domain.c | 9 +++---- src/qemu/qemu_driver.c | 57 +++++++++++++++----------------------------- src/qemu/qemu_hotplug.c | 42 +++++++++++--------------------- src/qemu/qemu_migration.c | 18 +++++--------- src/qemu/qemu_monitor_json.c | 30 ++++++++--------------- src/qemu/qemu_monitor_text.c | 9 +++---- src/qemu/qemu_process.c | 36 ++++++++++------------------ 12 files changed, 92 insertions(+), 184 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 9f673bf..8df1330 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -381,9 +381,8 @@ static int qemuAgentIOProcessData(qemuAgentPtr mon, int got = nl - (data + used); for (i = 0; i < strlen(LINE_ENDING); i++) data[used + got + i] = '\0'; - if (qemuAgentIOProcessLine(mon, data + used, msg) < 0) { + if (qemuAgentIOProcessLine(mon, data + used, msg) < 0) return -1; - } used += got + strlen(LINE_ENDING); } else { break; diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index ec6614a..3937870 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -872,9 +872,8 @@ virQEMUCapsInitGuestFromBinary(virCapsPtr caps, kvmbin ? kvmbin : binary, NULL, nmachines, - machines)) == NULL) { + machines)) == NULL) goto cleanup; - } machines = NULL; nmachines = 0; @@ -1178,9 +1177,8 @@ virQEMUCapsComputeCmdFlags(const char *help, if (is_kvm && (version >= 10000 || kvm_version >= 74)) virQEMUCapsSet(qemuCaps, QEMU_CAPS_VNET_HDR); - if (strstr(help, ",vhost=")) { + if (strstr(help, ",vhost=")) virQEMUCapsSet(qemuCaps, QEMU_CAPS_VHOST_NET); - } /* Do not use -no-shutdown if qemu doesn't support it or SIGTERM handling * is most likely buggy when used with -no-shutdown (which applies for qemu @@ -1936,9 +1934,8 @@ void virQEMUCapsDispose(void *obj) VIR_FREE(qemuCaps->machineAliases); VIR_FREE(qemuCaps->machineMaxCpus); - for (i = 0; i < qemuCaps->ncpuDefinitions; i++) { + for (i = 0; i < qemuCaps->ncpuDefinitions; i++) VIR_FREE(qemuCaps->cpuDefinitions[i]); - } VIR_FREE(qemuCaps->cpuDefinitions); virBitmapFree(qemuCaps->flags); @@ -2825,9 +2822,8 @@ virQEMUCapsReset(virQEMUCapsPtr qemuCaps) qemuCaps->arch = VIR_ARCH_NONE; qemuCaps->usedQMP = false; - for (i = 0; i < qemuCaps->ncpuDefinitions; i++) { + for (i = 0; i < qemuCaps->ncpuDefinitions; i++) VIR_FREE(qemuCaps->cpuDefinitions[i]); - } VIR_FREE(qemuCaps->cpuDefinitions); qemuCaps->ncpuDefinitions = 0; @@ -2981,9 +2977,8 @@ virQEMUCapsInitHelp(virQEMUCapsPtr qemuCaps, uid_t runUid, gid_t runGid) if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE) && strstr(help, "-device driver,?") && virQEMUCapsExtractDeviceStr(qemuCaps->binary, - qemuCaps, runUid, runGid) < 0) { + qemuCaps, runUid, runGid) < 0) goto cleanup; - } if (virQEMUCapsProbeCPUModels(qemuCaps, runUid, runGid) < 0) goto cleanup; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index b5bdb36..4b19786 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -294,17 +294,15 @@ qemuSetupHostdevCGroup(virDomainObjPtr vm, if (dev->missing) break; if ((usb = virUSBDeviceNew(usbsrc->bus, usbsrc->device, - NULL)) == NULL) { + NULL)) == NULL) goto cleanup; - } /* oddly, qemuSetupHostUSBDeviceCgroup doesn't ever * reference the usb object we just created */ if (virUSBDeviceFileIterate(usb, qemuSetupHostUSBDeviceCgroup, - vm) < 0) { + vm) < 0) goto cleanup; - } break; case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: { @@ -912,9 +910,8 @@ qemuSetupCgroupVcpuPin(virCgroupPtr cgroup, size_t i; for (i = 0; i < nvcpupin; i++) { - if (vcpuid == vcpupin[i]->vcpuid) { + if (vcpuid == vcpupin[i]->vcpuid) return qemuSetupCgroupEmulatorPin(cgroup, vcpupin[i]->cpumask); - } } return -1; @@ -929,9 +926,8 @@ qemuSetupCgroupIOThreadsPin(virCgroupPtr cgroup, size_t i; for (i = 0; i < niothreadspin; i++) { - if (iothreadid == iothreadspin[i]->vcpuid) { + if (iothreadid == iothreadspin[i]->vcpuid) return qemuSetupCgroupEmulatorPin(cgroup, iothreadspin[i]->cpumask); - } } return -1; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b148d45..51331aa 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -337,9 +337,8 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VNET_HDR) && - net->model && STREQ(net->model, "virtio")) { + net->model && STREQ(net->model, "virtio")) tap_create_flags |= VIR_NETDEV_TAP_CREATE_VNET_HDR; - } if (cfg->privileged) { if (virNetDevTapCreateInBridgePort(brname, &net->ifname, &net->mac, @@ -378,9 +377,8 @@ qemuNetworkIfaceConnect(virDomainDefPtr def, goto cleanup; if (net->filter && - virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) { + virDomainConfNWFilterInstantiate(conn, def->uuid, net) < 0) goto cleanup; - } ret = 0; @@ -973,9 +971,8 @@ qemuAssignDeviceAliases(virDomainDefPtr def, virQEMUCapsPtr qemuCaps) */ if (virDomainNetGetActualType(def->nets[i]) != VIR_DOMAIN_NET_TYPE_HOSTDEV && - qemuAssignDeviceNetAlias(def, def->nets[i], i) < 0) { + qemuAssignDeviceNetAlias(def, def->nets[i], i) < 0) return -1; - } } } @@ -1078,9 +1075,8 @@ qemuDomainPrimeVirtioDeviceAddresses(virDomainDefPtr def, for (i = 0; i < def->nnets; i++) { if (STREQ(def->nets[i]->model, "virtio") && - def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) { + def->nets[i]->info.type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE) def->nets[i]->info.type = type; - } } for (i = 0; i < def->ncontrollers; i++) { @@ -2010,14 +2006,12 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, STRPREFIX(def->os.machine, "pc-i440") || STREQ(def->os.machine, "pc") || STRPREFIX(def->os.machine, "rhel")) && - qemuValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) { + qemuValidateDevicePCISlotsPIIX3(def, qemuCaps, addrs) < 0) goto error; - } if (qemuDomainMachineIsQ35(def) && - qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) { + qemuDomainValidateDevicePCISlotsQ35(def, qemuCaps, addrs) < 0) goto error; - } /* PCI controllers */ for (i = 0; i < def->ncontrollers; i++) { @@ -2073,9 +2067,8 @@ qemuAssignDevicePCISlots(virDomainDefPtr def, * instead of here. */ if ((def->nets[i]->type == VIR_DOMAIN_NET_TYPE_HOSTDEV) || - (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) { + (def->nets[i]->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE)) continue; - } if (virDomainPCIAddressReserveNextSlot(addrs, &def->nets[i]->info, flags) < 0) goto error; @@ -8162,9 +8155,8 @@ qemuBuildCommandLine(virConnectPtr conn, } } if (def->clock.offset == VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE && - def->clock.data.timezone) { + def->clock.data.timezone) virCommandAddEnvPair(cmd, "TZ", def->clock.data.timezone); - } for (i = 0; i < def->clock.ntimers; i++) { switch ((virDomainTimerNameType) def->clock.timers[i]->name) { @@ -8290,9 +8282,8 @@ qemuBuildCommandLine(virConnectPtr conn, * watch for this event and do a soft/warm reboot. */ if (monitor_json && allowReboot && - virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) { + virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_SHUTDOWN)) virCommandAddArg(cmd, "-no-shutdown"); - } if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_NO_ACPI)) { if (def->features[VIR_DOMAIN_FEATURE_ACPI] != VIR_TRISTATE_SWITCH_ON) @@ -8341,9 +8332,8 @@ qemuBuildCommandLine(virConnectPtr conn, emitBootindex = true; } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && (def->os.bootmenu != VIR_TRISTATE_BOOL_YES || - !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) { + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) emitBootindex = true; - } if (!emitBootindex) { char boot[VIR_DOMAIN_BOOT_LAST+1]; @@ -8542,9 +8532,8 @@ qemuBuildCommandLine(virConnectPtr conn, /* Skip pci-root/pcie-root */ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_PCI && (cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCI_ROOT || - cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) { + cont->model == VIR_DOMAIN_CONTROLLER_MODEL_PCIE_ROOT)) continue; - } /* Only recent QEMU implements a SATA (AHCI) controller */ if (cont->type == VIR_DOMAIN_CONTROLLER_TYPE_SATA) { @@ -8799,9 +8788,8 @@ qemuBuildCommandLine(virConnectPtr conn, _("network disks are only supported with -drive")); goto error; } else { - if (VIR_STRDUP(file, disk->src->path) < 0) { + if (VIR_STRDUP(file, disk->src->path) < 0) goto error; - } } /* Don't start with source if the tray is open for @@ -9492,9 +9480,8 @@ qemuBuildCommandLine(virConnectPtr conn, virCommandAddArg(cmd, "-chardev"); if (!(devstr = qemuBuildChrChardevStr(&redirdev->source.chr, redirdev->info.alias, - qemuCaps))) { + qemuCaps))) goto error; - } virCommandAddArg(cmd, devstr); VIR_FREE(devstr); @@ -10081,9 +10068,8 @@ static int qemuStringToArgvEnv(const char *args, start = curr; /* accept a space in CEPH_ARGS */ - if (STRPREFIX(curr, "CEPH_ARGS=-m ")) { + if (STRPREFIX(curr, "CEPH_ARGS=-m ")) start += strlen("CEPH_ARGS=-m "); - } if (*start == '\'') { if (start == curr) curr++; diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 1ae90ff..4764bef 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1018,9 +1018,8 @@ qemuSharedDeviceEntryFree(void *payload, const void *name ATTRIBUTE_UNUSED) if (!entry) return; - for (i = 0; i < entry->ref; i++) { + for (i = 0; i < entry->ref; i++) VIR_FREE(entry->domains[i]); - } VIR_FREE(entry->domains); VIR_FREE(entry); } diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0caf1c0..613b735 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -495,9 +495,8 @@ qemuDomainObjPrivateXMLFormat(virBufferPtr buf, void *data) size_t i; virBufferAddLit(buf, "<vcpus>\n"); virBufferAdjustIndent(buf, 2); - for (i = 0; i < priv->nvcpupids; i++) { + for (i = 0; i < priv->nvcpupids; i++) virBufferAsprintf(buf, "<vcpu pid='%d'/>\n", priv->vcpupids[i]); - } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</vcpus>\n"); } @@ -1025,9 +1024,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, VIR_DOMAIN_CONTROLLER_MODEL_DMI_TO_PCI_BRIDGE) < 0 || virDomainDefMaybeAddController( def, VIR_DOMAIN_CONTROLLER_TYPE_PCI, 2, - VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE) < 0) { + VIR_DOMAIN_CONTROLLER_MODEL_PCI_BRIDGE) < 0) return -1; - } } if (addDefaultMemballoon && !def->memballoon) { @@ -1317,9 +1315,8 @@ qemuDomainObjBeginJobInternal(virQEMUDriverPtr driver, retry: if (cfg->maxQueuedJobs && - priv->jobs_queued > cfg->maxQueuedJobs) { + priv->jobs_queued > cfg->maxQueuedJobs) goto error; - } while (!nested && !qemuDomainNestedJobAllowed(priv, job)) { VIR_DEBUG("Waiting for async job (vm=%p name=%s)", obj, obj->def->name); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 6e47c8a..0ba8ab1 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -994,9 +994,8 @@ qemuStateStop(void) for (i = 0; i < numDomains; i++) { flags[i] = VIR_DOMAIN_SAVE_RUNNING; if (virDomainGetState(domains[i], &state, NULL, 0) == 0) { - if (state == VIR_DOMAIN_PAUSED) { + if (state == VIR_DOMAIN_PAUSED) flags[i] = VIR_DOMAIN_SAVE_PAUSED; - } } virDomainSuspend(domains[i]); } @@ -1839,9 +1838,8 @@ static int qemuDomainSuspend(virDomainPtr dom) "%s", _("domain is pmsuspended")); goto endjob; } else if (state != VIR_DOMAIN_PAUSED) { - if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0) { + if (qemuProcessStopCPUs(driver, vm, reason, QEMU_ASYNC_JOB_NONE) < 0) goto endjob; - } if (eventDetail >= 0) { event = virDomainEventLifecycleNewFromObj(vm, @@ -3221,9 +3219,8 @@ qemuDomainSaveInternal(virQEMUDriverPtr driver, virDomainPtr dom, if (!(def = virDomainDefParseString(xmlin, caps, driver->xmlopt, QEMU_EXPECTED_VIRT_TYPES, - VIR_DOMAIN_XML_INACTIVE))) { + VIR_DOMAIN_XML_INACTIVE))) goto endjob; - } if (!qemuDomainDefCheckABIStability(driver, vm->def, def)) { virDomainDefFree(def); goto endjob; @@ -3980,9 +3977,8 @@ doCoreDumpToAutoDumpPath(virQEMUDriverPtr driver, goto cleanup; if (qemuDomainObjBeginAsyncJob(driver, vm, - QEMU_ASYNC_JOB_DUMP) < 0) { + QEMU_ASYNC_JOB_DUMP) < 0) goto cleanup; - } if (!virDomainObjIsActive(vm)) { virReportError(VIR_ERR_OPERATION_INVALID, @@ -4042,9 +4038,8 @@ processGuestPanicEvent(virQEMUDriverPtr driver, switch (action) { case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_DESTROY: - if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) { + if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) goto cleanup; - } /* fall through */ case VIR_DOMAIN_LIFECYCLE_CRASH_DESTROY: @@ -4073,15 +4068,13 @@ processGuestPanicEvent(virQEMUDriverPtr driver, virDomainAuditStop(vm, "destroyed"); - if (!vm->persistent) { + if (!vm->persistent) qemuDomainRemoveInactive(driver, vm); - } break; case VIR_DOMAIN_LIFECYCLE_CRASH_COREDUMP_RESTART: - if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) { + if (doCoreDumpToAutoDumpPath(driver, vm, VIR_DUMP_MEMORY_ONLY) < 0) goto cleanup; - } /* fall through */ case VIR_DOMAIN_LIFECYCLE_CRASH_RESTART: @@ -4854,9 +4847,8 @@ qemuDomainPinVcpuFlags(virDomainPtr dom, goto cleanup; if (snprintf(paramField, VIR_TYPED_PARAM_FIELD_LENGTH, - VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) { + VIR_DOMAIN_TUNABLE_CPU_VCPUPIN, vcpu) < 0) goto cleanup; - } str = virBitmapFormat(pcpumap); if (virTypedParamsAddString(&eventParams, &eventNparams, @@ -4954,9 +4946,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, &targetDef) < 0) goto cleanup; - if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (flags & VIR_DOMAIN_AFFECT_LIVE) targetDef = vm->def; - } /* Coverity didn't realize that targetDef must be set if we got here. */ sa_assert(targetDef); @@ -4972,9 +4963,8 @@ qemuDomainGetVcpuPinInfo(virDomainPtr dom, if (ncpumaps > targetDef->vcpus) ncpumaps = targetDef->vcpus; - if (ncpumaps < 1) { + if (ncpumaps < 1) goto cleanup; - } /* initialize cpumaps */ memset(cpumaps, 0xff, maplen * ncpumaps); @@ -5232,9 +5222,8 @@ qemuDomainGetEmulatorPinInfo(virDomainPtr dom, /* initialize cpumaps */ memset(cpumaps, 0xff, maplen); - if (maxcpu % 8) { + if (maxcpu % 8) cpumaps[maplen - 1] &= (1 << maxcpu % 8) - 1; - } if (targetDef->cputune.emulatorpin) { cpumask = targetDef->cputune.emulatorpin->cpumask; @@ -9522,9 +9511,8 @@ qemuSetEmulatorBandwidthLive(virDomainObjPtr vm, virCgroupPtr cgroup, if (period == 0 && quota == 0) return 0; - if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid) { + if (priv->nvcpupids == 0 || priv->vcpupids[0] == vm->pid) return 0; - } if (virCgroupNewEmulator(cgroup, false, &cgroup_emulator) < 0) goto cleanup; @@ -10500,12 +10488,10 @@ qemuDomainSetInterfaceParameters(virDomainPtr dom, /* average is mandatory, peak and burst are optional. So if no * average is given, we free inbound/outbound here which causes * inbound/outbound to not be set. */ - if (!bandwidth->in->average) { + if (!bandwidth->in->average) VIR_FREE(bandwidth->in); - } - if (!bandwidth->out->average) { + if (!bandwidth->out->average) VIR_FREE(bandwidth->out); - } if (flags & VIR_DOMAIN_AFFECT_LIVE) { if (VIR_ALLOC(newBandwidth) < 0) @@ -13212,9 +13198,8 @@ qemuDomainSnapshotPrepare(virConnectPtr conn, if (dom_disk->src->type == VIR_STORAGE_TYPE_NETWORK && (dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_SHEEPDOG || - dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) { + dom_disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD)) break; - } if (vm->def->disks[i]->src->format > 0 && vm->def->disks[i]->src->format != VIR_STORAGE_FILE_QCOW2) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, @@ -14847,9 +14832,8 @@ qemuDomainSnapshotReparentChildren(void *payload, virDomainSnapshotObjPtr snap = payload; virQEMUSnapReparentPtr rep = data; - if (rep->err < 0) { + if (rep->err < 0) return; - } VIR_FREE(snap->def->parent); snap->parent = rep->parent; @@ -15023,9 +15007,8 @@ static int qemuDomainQemuMonitorCommand(virDomainPtr domain, const char *cmd, qemuDomainObjExitMonitor(driver, vm); endjob: - if (!qemuDomainObjEndJob(driver, vm)) { + if (!qemuDomainObjEndJob(driver, vm)) vm = NULL; - } cleanup: if (vm) @@ -15892,9 +15875,8 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } device = qemuDiskPathToAlias(vm, path, &idx); - if (!device) { + if (!device) goto endjob; - } disk = vm->def->disks[idx]; if (disk->mirror) { virReportError(VIR_ERR_BLOCK_COPY_ACTIVE, @@ -16888,9 +16870,8 @@ qemuDomainGetBlockIoTune(virDomainPtr dom, goto endjob; device = qemuDiskPathToAlias(vm, disk, NULL); - if (!device) { + if (!device) goto endjob; - } if (flags & VIR_DOMAIN_AFFECT_LIVE) { priv = vm->privateData; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 13bcd88..b98ad5e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -284,9 +284,8 @@ qemuDomainCheckEjectableMedia(virQEMUDriverPtr driver, struct qemuDomainDiskInfo *info; if (disk->device == VIR_DOMAIN_DISK_DEVICE_DISK || - disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) { + disk->device == VIR_DOMAIN_DISK_DEVICE_LUN) continue; - } info = qemuMonitorBlockInfoLookup(table, disk->info.alias); if (!info) @@ -468,9 +467,8 @@ int qemuDomainAttachControllerDevice(virQEMUDriverPtr driver, goto cleanup; } - if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL))) { + if (!(devstr = qemuBuildControllerDevStr(vm->def, controller, priv->qemuCaps, NULL))) goto cleanup; - } } if (VIR_REALLOC_N(vm->def->controllers, vm->def->ncontrollers+1) < 0) @@ -970,9 +968,8 @@ int qemuDomainAttachNetDevice(virConnectPtr conn, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("virtio-s390 net device cannot be hotplugged.")); } else if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_DEVICE) && - virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) { + virDomainPCIAddressEnsureAddr(priv->pciaddrs, &net->info) < 0) goto cleanup; - } releaseaddr = true; @@ -2002,9 +1999,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, /* virtPortProfile: will be examined later, after allocating new actualdev */ if (olddev->tune.sndbuf_specified != newdev->tune.sndbuf_specified || - olddev->tune.sndbuf != newdev->tune.sndbuf) { + olddev->tune.sndbuf != newdev->tune.sndbuf) needReconnect = true; - } if (STRNEQ_NULLABLE(olddev->script, newdev->script)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -2029,9 +2025,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, */ if (!virDomainDeviceAddressIsValid(&newdev->info, VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) && - virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) { + virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) goto cleanup; - } if (!virDevicePCIAddressEqual(&olddev->info.addr.pci, &newdev->info.addr.pci)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -2065,9 +2060,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, /* (end of device info checks) */ if (STRNEQ_NULLABLE(olddev->filter, newdev->filter) || - !virNWFilterHashTableEqual(olddev->filterparams, newdev->filterparams)) { + !virNWFilterHashTableEqual(olddev->filterparams, newdev->filterparams)) needFilterChange = true; - } /* bandwidth can be modified, and will be checked later */ /* vlan can be modified, and will be checked later */ @@ -2077,9 +2071,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, * free it if we fail for any reason */ if (newdev->type == VIR_DOMAIN_NET_TYPE_NETWORK && - networkAllocateActualDevice(vm->def, newdev) < 0) { + networkAllocateActualDevice(vm->def, newdev) < 0) goto cleanup; - } newType = virDomainNetGetActualType(newdev); @@ -2102,9 +2095,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, if (STRNEQ_NULLABLE(olddev->data.ethernet.dev, newdev->data.ethernet.dev) || STRNEQ_NULLABLE(olddev->data.ethernet.ipaddr, - newdev->data.ethernet.ipaddr)) { + newdev->data.ethernet.ipaddr)) needReconnect = true; - } break; case VIR_DOMAIN_NET_TYPE_SERVER: @@ -2112,9 +2104,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, case VIR_DOMAIN_NET_TYPE_MCAST: if (STRNEQ_NULLABLE(olddev->data.socket.address, newdev->data.socket.address) || - olddev->data.socket.port != newdev->data.socket.port) { + olddev->data.socket.port != newdev->data.socket.port) needReconnect = true; - } break; case VIR_DOMAIN_NET_TYPE_NETWORK: @@ -2133,9 +2124,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, case VIR_DOMAIN_NET_TYPE_INTERNAL: if (STRNEQ_NULLABLE(olddev->data.internal.name, - newdev->data.internal.name)) { + newdev->data.internal.name)) needReconnect = true; - } break; case VIR_DOMAIN_NET_TYPE_DIRECT: @@ -2202,9 +2192,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, !virNetDevVPortProfileEqual(virDomainNetGetActualVirtPortProfile(olddev), virDomainNetGetActualVirtPortProfile(newdev)) || !virNetDevVlanEqual(virDomainNetGetActualVlan(olddev), - virDomainNetGetActualVlan(newdev))) { + virDomainNetGetActualVlan(newdev))) needReconnect = true; - } if (olddev->linkstate != newdev->linkstate) needLinkStateChange = true; @@ -2249,9 +2238,8 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, } if (needLinkStateChange && - qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate) < 0) { + qemuDomainChangeNetLinkState(driver, vm, olddev, newdev->linkstate) < 0) goto cleanup; - } if (needReplaceDevDef) { /* the changes above warrant replacing olddev with newdev in @@ -2696,9 +2684,8 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver, VIR_WARN("Failed to remove host device cgroup ACL"); if (virSecurityManagerRestoreHostdevLabel(driver->securityManager, - vm->def, hostdev, NULL) < 0) { + vm->def, hostdev, NULL) < 0) VIR_WARN("Failed to restore host device labelling"); - } virDomainHostdevDefFree(hostdev); @@ -3095,9 +3082,8 @@ qemuFindDisk(virDomainDefPtr def, const char *dst) size_t i; for (i = 0; i < def->ndisks; i++) { - if (STREQ(def->disks[i]->dst, dst)) { + if (STREQ(def->disks[i]->dst, dst)) return i; - } } return -1; diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index c797206..3d4b75a 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1206,9 +1206,8 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig, return -1; if (flags & QEMU_MIGRATION_COOKIE_NETWORK && - qemuMigrationCookieAddNetwork(mig, driver, dom) < 0) { + qemuMigrationCookieAddNetwork(mig, driver, dom) < 0) return -1; - } if ((flags & QEMU_MIGRATION_COOKIE_NBD) && qemuMigrationCookieAddNBD(mig, driver, dom) < 0) @@ -1562,9 +1561,8 @@ qemuMigrationDriveMirror(virQEMUDriverPtr driver, if (qemuDomainObjEnterMonitorAsync(driver, vm, QEMU_ASYNC_JOB_MIGRATION_OUT) == 0) { if (qemuMonitorBlockJob(priv->mon, diskAlias, NULL, NULL, 0, - BLOCK_JOB_ABORT, true) < 0) { + BLOCK_JOB_ABORT, true) < 0) VIR_WARN("Unable to cancel block-job on '%s'", diskAlias); - } qemuDomainObjExitMonitor(driver, vm); } else { VIR_WARN("Unable to enter monitor. No block job cancelled"); @@ -1762,9 +1760,8 @@ qemuMigrationIsSafe(virDomainDefPtr def) else if (rc == 1) continue; } else if (disk->src->type == VIR_STORAGE_TYPE_NETWORK && - disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) { + disk->src->protocol == VIR_STORAGE_NET_PROTOCOL_RBD) continue; - } virReportError(VIR_ERR_MIGRATE_UNSAFE, "%s", _("Migration may lead to data corruption if disks" @@ -2740,9 +2737,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, goto stop; if (STREQ(protocol, "rdma") && - virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) { + virProcessSetMaxMemLock(vm->pid, vm->def->mem.hard_limit << 10) < 0) goto stop; - } if (flags & VIR_MIGRATE_RDMA_PIN_ALL && qemuMigrationSetPinAll(driver, vm, QEMU_ASYNC_JOB_MIGRATION_IN) < 0) @@ -2833,9 +2829,8 @@ qemuMigrationPrepareAny(virQEMUDriverPtr driver, qemuProcessStop(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED, 0); endjob: - if (!qemuMigrationJobFinish(driver, vm)) { + if (!qemuMigrationJobFinish(driver, vm)) vm = NULL; - } goto cleanup; } @@ -3733,9 +3728,8 @@ qemuMigrationRun(virQEMUDriverPtr driver, cookieFlags |= QEMU_MIGRATION_COOKIE_PERSISTENT; if (ret == 0 && qemuMigrationBakeCookie(mig, driver, vm, cookieout, - cookieoutlen, cookieFlags) < 0) { + cookieoutlen, cookieFlags) < 0) VIR_WARN("Unable to encode migration cookie"); - } qemuMigrationCookieFree(mig); diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 7870664..7306d7b 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -565,9 +565,8 @@ static void qemuMonitorJSONHandleWatchdog(qemuMonitorPtr mon, virJSONValuePtr da { const char *action; int actionID; - if (!(action = virJSONValueObjectGetString(data, "action"))) { + if (!(action = virJSONValueObjectGetString(data, "action"))) VIR_WARN("missing action in watchdog event"); - } if (action) { if ((actionID = qemuMonitorWatchdogActionTypeFromString(action)) < 0) { VIR_WARN("unknown action %s in watchdog event", action); @@ -602,9 +601,8 @@ qemuMonitorJSONHandleIOError(qemuMonitorPtr mon, virJSONValuePtr data) action = "ignore"; } - if ((device = virJSONValueObjectGetString(data, "device")) == NULL) { + if ((device = virJSONValueObjectGetString(data, "device")) == NULL) VIR_WARN("missing device in disk io error event"); - } if (virJSONValueObjectGetBoolean(data, "nospace", &nospc) == 0 && nospc) reason = "enospc"; @@ -1476,9 +1474,8 @@ qemuMonitorJSONSetMemoryStatsPeriod(qemuMonitorPtr mon, prop.val.iv = period; if (qemuMonitorJSONSetObjectProperty(mon, balloonpath, "guest-stats-polling-interval", - &prop) < 0) { + &prop) < 0) return -1; - } return 0; } @@ -1654,19 +1651,16 @@ qemuMonitorJSONDevGetBlockExtent(virJSONValuePtr dev, virJSONValuePtr parent; if ((parent = virJSONValueObjectGet(dev, "parent")) == NULL || - parent->type != VIR_JSON_TYPE_OBJECT) { + parent->type != VIR_JSON_TYPE_OBJECT) return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOPARENT; - } if ((stats = virJSONValueObjectGet(parent, "stats")) == NULL || - stats->type != VIR_JSON_TYPE_OBJECT) { + stats->type != VIR_JSON_TYPE_OBJECT) return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOSTATS; - } if (virJSONValueObjectGetNumberUlong(stats, "wr_highest_offset", - extent) < 0) { + extent) < 0) return QEMU_MONITOR_BLOCK_EXTENT_ERROR_NOOFFSET; - } return QEMU_MONITOR_BLOCK_EXTENT_ERROR_OK; } @@ -4411,9 +4405,8 @@ int qemuMonitorJSONGetBlockIoThrottle(qemuMonitorPtr mon, virJSONValuePtr result = NULL; cmd = qemuMonitorJSONMakeCommand("query-block", NULL); - if (!cmd) { + if (!cmd) return -1; - } ret = qemuMonitorJSONCommand(mon, cmd, &result); @@ -4445,9 +4438,8 @@ int qemuMonitorJSONSystemWakeup(qemuMonitorPtr mon) virJSONValuePtr reply = NULL; cmd = qemuMonitorJSONMakeCommand("system_wakeup", NULL); - if (!cmd) { + if (!cmd) return -1; - } ret = qemuMonitorJSONCommand(mon, cmd, &reply); @@ -5368,9 +5360,8 @@ int qemuMonitorJSONGetObjectProps(qemuMonitorPtr mon, ret = qemuMonitorJSONCommand(mon, cmd, &reply); if (ret == 0 && - qemuMonitorJSONHasError(reply, "DeviceNotFound")) { + qemuMonitorJSONHasError(reply, "DeviceNotFound")) goto cleanup; - } if (ret == 0) ret = qemuMonitorJSONCheckError(cmd, reply); @@ -5841,9 +5832,8 @@ qemuMonitorJSONAttachCharDevCommand(const char *chrID, bool telnet; if (!(backend = virJSONValueNewObject()) || - !(data = virJSONValueNewObject())) { + !(data = virJSONValueNewObject())) goto error; - } switch ((virDomainChrType) chr->type) { case VIR_DOMAIN_CHR_TYPE_NULL: diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c index 46d2782..95736be 100644 --- a/src/qemu/qemu_monitor_text.c +++ b/src/qemu/qemu_monitor_text.c @@ -123,9 +123,8 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED, */ if (msg->txLength > 0) { char *tmp; - if ((tmp = strchr(msg->txBuffer, '\r'))) { + if ((tmp = strchr(msg->txBuffer, '\r'))) *tmp = '\0'; - } } /* QEMU echos the command back to us, full of control @@ -144,9 +143,8 @@ int qemuMonitorTextIOProcess(qemuMonitorPtr mon ATTRIBUTE_UNUSED, skip = strstr(data + used, msg->txBuffer); /* After the junk we should have a line ending... */ - if (skip) { + if (skip) start = strstr(skip + strlen(msg->txBuffer), LINE_ENDING); - } /* ... then our command reply data, following by a (qemu) prompt */ if (start) { @@ -634,9 +632,8 @@ static int qemuMonitorParseBalloonInfo(char *text, * loop. */ if (parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, - "actual=", &stats[nr_stats_found]) == 1) { + "actual=", &stats[nr_stats_found]) == 1) nr_stats_found++; - } while (*p && nr_stats_found < nr_stats) { if (parseMemoryStat(&p, VIR_DOMAIN_MEMORY_STAT_SWAP_IN, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 24e5f0f..e0693f8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -626,9 +626,8 @@ qemuProcessFakeReboot(void *opaque) cleanup: if (vm) { - if (ret == -1) { + if (ret == -1) ignore_value(qemuProcessKill(vm, VIR_QEMU_PROCESS_KILL_FORCE)); - } if (virObjectUnref(vm)) virObjectUnlock(vm); } @@ -1829,9 +1828,8 @@ qemuProcessExtractTTYPath(const char *haystack, VIR_FREE(*path); /* First look for our magic string */ - if (!(tmp = strstr(haystack + *offset, needle))) { + if (!(tmp = strstr(haystack + *offset, needle))) return 1; - } tmp += sizeof(needle); dev = tmp; @@ -2363,9 +2361,8 @@ qemuProcessSetVcpuAffinities(virDomainObjPtr vm) continue; if (virProcessSetAffinity(priv->vcpupids[n], - pininfo->cpumask) < 0) { + pininfo->cpumask) < 0) goto cleanup; - } } ret = 0; @@ -3203,9 +3200,8 @@ qemuProcessRecoverMigration(virQEMUDriverPtr driver, vm->def->name); if (qemuProcessStartCPUs(driver, vm, conn, VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + QEMU_ASYNC_JOB_NONE) < 0) VIR_WARN("Could not resume domain %s", vm->def->name); - } break; case QEMU_MIGRATION_PHASE_FINISH3: @@ -3244,9 +3240,8 @@ qemuProcessRecoverMigration(virQEMUDriverPtr driver, reason == VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, conn, VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + QEMU_ASYNC_JOB_NONE) < 0) VIR_WARN("Could not resume domain %s", vm->def->name); - } } break; @@ -3265,9 +3260,8 @@ qemuProcessRecoverMigration(virQEMUDriverPtr driver, reason == VIR_DOMAIN_PAUSED_UNKNOWN)) { if (qemuProcessStartCPUs(driver, vm, conn, VIR_DOMAIN_RUNNING_UNPAUSED, - QEMU_ASYNC_JOB_NONE) < 0) { + QEMU_ASYNC_JOB_NONE) < 0) VIR_WARN("Could not resume domain %s", vm->def->name); - } } break; @@ -3467,9 +3461,8 @@ qemuProcessReconnect(void *opaque) priv->agentError = true; } - if (qemuUpdateActivePCIHostdevs(driver, obj->def) < 0) { + if (qemuUpdateActivePCIHostdevs(driver, obj->def) < 0) goto error; - } if (qemuUpdateActiveUSBHostdevs(driver, obj->def) < 0) goto error; @@ -4209,9 +4202,8 @@ int qemuProcessStart(virConnectPtr conn, !graphics->data.vnc.autoport) { if (virPortAllocatorSetUsed(driver->remotePorts, graphics->data.vnc.port, - true) < 0) { + true) < 0) goto cleanup; - } graphics->data.vnc.portReserved = true; @@ -4474,9 +4466,8 @@ int qemuProcessStart(virConnectPtr conn, VIR_DEBUG("Setting up security labelling"); if (virSecurityManagerSetChildProcessLabel(driver->securityManager, - vm->def, cmd) < 0) { + vm->def, cmd) < 0) goto cleanup; - } virCommandSetOutputFD(cmd, &logfile); virCommandSetErrorFD(cmd, &logfile); @@ -4505,9 +4496,8 @@ int qemuProcessStart(virConnectPtr conn, } VIR_DEBUG("Writing early domain status to disk"); - if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) { + if (virDomainSaveStatus(driver->xmlopt, cfg->stateDir, vm) < 0) goto cleanup; - } VIR_DEBUG("Waiting for handshake from child"); if (virCommandHandshakeWait(cmd) < 0) { @@ -4556,9 +4546,8 @@ int qemuProcessStart(virConnectPtr conn, } VIR_DEBUG("Labelling done, completing handshake to child"); - if (virCommandHandshakeNotify(cmd) < 0) { + if (virCommandHandshakeNotify(cmd) < 0) goto cleanup; - } VIR_DEBUG("Handshake complete, child running"); if (migrateFrom) @@ -4923,9 +4912,8 @@ void qemuProcessStop(virQEMUDriverPtr driver, /* Clear out dynamically assigned labels */ for (i = 0; i < vm->def->nseclabels; i++) { - if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) { + if (vm->def->seclabels[i]->type == VIR_DOMAIN_SECLABEL_DYNAMIC) VIR_FREE(vm->def->seclabels[i]->label); - } VIR_FREE(vm->def->seclabels[i]->imagelabel); } -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/util/virauth.c | 21 +++++++-------------- src/util/virbitmap.c | 6 ++---- src/util/virbuffer.c | 3 +-- src/util/vircgroup.c | 3 +-- src/util/vircommand.c | 12 ++++-------- src/util/virconf.c | 15 +++++---------- src/util/virdbus.c | 6 ++---- src/util/virdnsmasq.c | 6 ++---- src/util/vireventpoll.c | 12 ++++-------- src/util/virfile.c | 9 +++------ src/util/virfirewall.c | 6 ++---- src/util/virhostdev.c | 6 ++---- src/util/viriscsi.c | 12 ++++-------- src/util/virjson.c | 3 +-- src/util/virlockspace.c | 6 ++---- src/util/virlog.c | 6 ++---- src/util/virnetdev.c | 12 ++++-------- src/util/virnetdevbridge.c | 3 +-- src/util/virnetdevmacvlan.c | 15 +++++---------- src/util/virnetdevtap.c | 9 +++------ src/util/virnetdevvlan.c | 3 +-- src/util/virnetdevvportprofile.c | 6 ++---- src/util/virpci.c | 33 +++++++++++---------------------- src/util/virsexpr.c | 30 ++++++++++-------------------- src/util/virstorageencryption.c | 3 +-- src/util/virstoragefile.c | 6 ++---- src/util/virsysinfo.c | 3 +-- src/util/virthreadpool.c | 9 +++------ src/util/virutil.c | 12 ++++-------- src/util/virxml.c | 18 ++++++------------ 30 files changed, 98 insertions(+), 196 deletions(-) diff --git a/src/util/virauth.c b/src/util/virauth.c index f82e546..737a430 100644 --- a/src/util/virauth.c +++ b/src/util/virauth.c @@ -168,19 +168,16 @@ virAuthGetUsernamePath(const char *path, if (defaultUsername != NULL) { if (virAsprintf(&prompt, _("Enter username for %s [%s]"), hostname, - defaultUsername) < 0) { + defaultUsername) < 0) 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 +186,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; } @@ -244,15 +240,13 @@ virAuthGetPasswordPath(const char *path, memset(&cred, 0, sizeof(virConnectCredential)); if (virAsprintf(&prompt, _("Enter %s's password for %s"), username, - hostname) < 0) { + hostname) < 0) return NULL; - } for (ncred = 0; ncred < auth->ncredtype; ncred++) { if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE && - auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) { + auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) continue; - } cred.type = auth->credtype[ncred]; cred.prompt = prompt; @@ -261,9 +255,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; } diff --git a/src/util/virbitmap.c b/src/util/virbitmap.c index 04a2388..05c50e4 100644 --- a/src/util/virbitmap.c +++ b/src/util/virbitmap.c @@ -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. */ diff --git a/src/util/virbuffer.c b/src/util/virbuffer.c index 52ffa08..16a81e7 100644 --- a/src/util/virbuffer.c +++ b/src/util/virbuffer.c @@ -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], diff --git a/src/util/vircgroup.c b/src/util/vircgroup.c index 9bbe694..df41ec0 100644 --- a/src/util/vircgroup.c +++ b/src/util/vircgroup.c @@ -1246,9 +1246,8 @@ virCgroupSetPartitionSuffix(const char *path, char **res) if (i == 1 && (STREQ(tokens[i], "machine") || STREQ(tokens[i], "system") || - STREQ(tokens[i], "user"))) { + STREQ(tokens[i], "user"))) continue; - } /* If there is no suffix set already, then * add ".partition" */ diff --git a/src/util/vircommand.c b/src/util/vircommand.c index cbe94f8..80b86cf 100644 --- a/src/util/vircommand.c +++ b/src/util/vircommand.c @@ -558,9 +558,8 @@ virExec(virCommandPtr cmd) pid = virFork(); - if (pid < 0) { + if (pid < 0) goto cleanup; - } if (pid) { /* parent */ VIR_FORCE_CLOSE(null); @@ -731,9 +730,8 @@ virExec(virCommandPtr cmd) (int)cmd->uid, (int)cmd->gid, cmd->capabilities); if (virSetUIDGIDWithCaps(cmd->uid, cmd->gid, groups, ngroups, cmd->capabilities, - !!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0) { + !!(cmd->flags & VIR_EXEC_CLEAR_CAPS)) < 0) goto fork_error; - } } if (cmd->pwd) { @@ -3021,9 +3019,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 +3047,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]); - } } } diff --git a/src/util/virconf.c b/src/util/virconf.c index e221fb5..0a17eff 100644 --- a/src/util/virconf.c +++ b/src/util/virconf.c @@ -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; } diff --git a/src/util/virdbus.c b/src/util/virdbus.c index 7c24cbf..0e2739b 100644 --- a/src/util/virdbus.c +++ b/src/util/virdbus.c @@ -73,9 +73,8 @@ static DBusConnection *virDBusBusInit(DBusBusType type, DBusError *dbuserr) virDBusAddWatch, virDBusRemoveWatch, virDBusToggleWatch, - bus, NULL)) { + bus, NULL)) return NULL; - } return bus; } @@ -546,9 +545,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); } diff --git a/src/util/virdnsmasq.c b/src/util/virdnsmasq.c index d2c4aa9..6314258 100644 --- a/src/util/virdnsmasq.c +++ b/src/util/virdnsmasq.c @@ -633,9 +633,8 @@ static int dnsmasqCapsOnceInit(void) if (!(dnsmasqCapsClass = virClassNew(virClassForObject(), "dnsmasqCaps", sizeof(dnsmasqCaps), - dnsmasqCapsDispose))) { + dnsmasqCapsDispose))) return -1; - } return 0; } @@ -726,9 +725,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. diff --git a/src/util/vireventpoll.c b/src/util/vireventpoll.c index 13f40dc..6113741 100644 --- a/src/util/vireventpoll.c +++ b/src/util/vireventpoll.c @@ -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++) { @@ -485,9 +483,8 @@ static int virEventPollDispatchHandles(int nfds, struct pollfd *fds) for (i = 0, n = 0; n < nfds && i < eventLoop.handlesCount; n++) { while (i < eventLoop.handlesCount && (eventLoop.handles[i].fd != fds[n].fd || - eventLoop.handles[i].events == 0)) { + eventLoop.handles[i].events == 0)) i++; - } if (i == eventLoop.handlesCount) break; @@ -643,9 +640,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; diff --git a/src/util/virfile.c b/src/util/virfile.c index 64f0e5b..475aeab 100644 --- a/src/util/virfile.c +++ b/src/util/virfile.c @@ -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); @@ -2273,9 +2271,8 @@ virDirCreate(const char *path, if ((!(flags & VIR_DIR_CREATE_AS_UID)) || (geteuid() != 0) || ((uid == 0) && (gid == 0)) - || ((flags & VIR_DIR_CREATE_ALLOW_EXIST) && (stat(path, &st) >= 0))) { + || ((flags & VIR_DIR_CREATE_ALLOW_EXIST) && (stat(path, &st) >= 0))) return virDirCreateNoFork(path, mode, uid, gid, flags); - } ngroups = virGetGroupList(uid, gid, &groups); if (ngroups < 0) diff --git a/src/util/virfirewall.c b/src/util/virfirewall.c index bab1634..49afb78 100644 --- a/src/util/virfirewall.c +++ b/src/util/virfirewall.c @@ -321,9 +321,8 @@ virFirewallAddRuleFullV(virFirewallPtr firewall, rule->queryOpaque = opaque; rule->ignoreErrors = ignoreErrors; - 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, @@ -529,9 +528,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); diff --git a/src/util/virhostdev.c b/src/util/virhostdev.c index 18ff96b..bea44e6 100644 --- a/src/util/virhostdev.c +++ b/src/util/virhostdev.c @@ -578,9 +578,8 @@ virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr, if (hostdev->parent.type == VIR_DOMAIN_DEVICE_NET && hostdev->parent.data.net) { if (virHostdevNetConfigReplace(hostdev, uuid, - hostdev_mgr->stateDir) < 0) { + hostdev_mgr->stateDir) < 0) goto resetvfnetconfig; - } } last_processed_hostdev_vf = i; } @@ -1491,9 +1490,8 @@ virHostdevPCINodeDeviceDetach(virHostdevManagerPtr hostdev_mgr, virObjectLock(hostdev_mgr->inactivePCIHostdevs); if (virPCIDeviceDetach(pci, hostdev_mgr->activePCIHostdevs, - hostdev_mgr->inactivePCIHostdevs) < 0) { + hostdev_mgr->inactivePCIHostdevs) < 0) goto out; - } ret = 0; out: diff --git a/src/util/viriscsi.c b/src/util/viriscsi.c index 5e29be9..e492ca7 100644 --- a/src/util/viriscsi.c +++ b/src/util/viriscsi.c @@ -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); @@ -298,9 +296,8 @@ virISCSIConnection(const char *portal, break; case IQN_MISSING: if (virStorageBackendCreateIfaceIQN(initiatoriqn, - &ifacename) != 0) { + &ifacename) != 0) goto cleanup; - } break; case IQN_ERROR: default: @@ -451,9 +448,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); } diff --git a/src/util/virjson.c b/src/util/virjson.c index 3ffa19f..b18a642 100644 --- a/src/util/virjson.c +++ b/src/util/virjson.c @@ -1246,9 +1246,8 @@ virJSONParserHandleStartMap(void *ctx) } if (VIR_REALLOC_N(parser->state, - parser->nstate + 1) < 0) { + parser->nstate + 1) < 0) return 0; - } parser->state[parser->nstate].value = value; parser->state[parser->nstate].key = NULL; diff --git a/src/util/virlockspace.c b/src/util/virlockspace.c index 8969ab0..2366a74 100644 --- a/src/util/virlockspace.c +++ b/src/util/virlockspace.c @@ -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) diff --git a/src/util/virlog.c b/src/util/virlog.c index 286ad9e..a7da505 100644 --- a/src/util/virlog.c +++ b/src/util/virlog.c @@ -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) @@ -1025,9 +1024,8 @@ static int virLogAddOutputToJournald(int priority) return -1; } if (virLogDefineOutput(virLogOutputToJournald, virLogCloseJournald, NULL, - priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0) { + priority, VIR_LOG_TO_JOURNALD, NULL, 0) < 0) return -1; - } return 0; } # endif /* USE_JOURNALD */ diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c index 3831009..bea3f13 100644 --- a/src/util/virnetdev.c +++ b/src/util/virnetdev.c @@ -851,9 +851,8 @@ int virNetDevSetIPv4Address(const char *ifname, /* format up a broadcast address if this is IPv4 */ if ((VIR_SOCKET_ADDR_IS_FAMILY(addr, AF_INET)) && ((virSocketAddrBroadcastByPrefix(addr, prefix, &broadcast) < 0) || - !(bcaststr = virSocketAddrFormat(&broadcast)))) { + !(bcaststr = virSocketAddrFormat(&broadcast)))) goto cleanup; - } #ifdef IFCONFIG_PATH cmd = virCommandNew(IFCONFIG_PATH); virCommandAddArg(cmd, ifname); @@ -1185,9 +1184,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; @@ -1449,9 +1447,8 @@ virNetDevLinkDump(const char *ifname, int ifindex, uint32_t ifla_ext_mask = RTEXT_FILTER_VF; if (nla_put(nl_msg, IFLA_EXT_MASK, - sizeof(ifla_ext_mask), &ifla_ext_mask) < 0) { + sizeof(ifla_ext_mask), &ifla_ext_mask) < 0) goto buffer_too_small; - } } # endif @@ -1758,9 +1755,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; diff --git a/src/util/virnetdevbridge.c b/src/util/virnetdevbridge.c index d388358..15434de 100644 --- a/src/util/virnetdevbridge.c +++ b/src/util/virnetdevbridge.c @@ -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: diff --git a/src/util/virnetdevmacvlan.c b/src/util/virnetdevmacvlan.c index c83341c..0b8118b 100644 --- a/src/util/virnetdevmacvlan.c +++ b/src/util/virnetdevmacvlan.c @@ -153,9 +153,8 @@ virNetDevMacVLanCreate(const char *ifname, nla_nest_end(nl_msg, linkinfo); if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0, - NETLINK_ROUTE, 0) < 0) { + NETLINK_ROUTE, 0) < 0) goto cleanup; - } if (recvbuflen < NLMSG_LENGTH(0) || resp == NULL) goto malformed_resp; @@ -239,9 +238,8 @@ int virNetDevMacVLanDelete(const char *ifname) goto buffer_too_small; if (virNetlinkCommand(nl_msg, &resp, &recvbuflen, 0, 0, - NETLINK_ROUTE, 0) < 0) { + NETLINK_ROUTE, 0) < 0) goto cleanup; - } if (recvbuflen < NLMSG_LENGTH(0) || resp == NULL) goto malformed_resp; @@ -682,9 +680,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 +848,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 +979,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, diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c index 3674f9b..57dd044 100644 --- a/src/util/virnetdevtap.c +++ b/src/util/virnetdevtap.c @@ -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; @@ -583,9 +581,8 @@ int virNetDevTapCreateInBridgePort(const char *brname, if (virtPortProfile) { if (virNetDevOpenvswitchAddPort(brname, *ifname, macaddr, vmuuid, - virtPortProfile, virtVlan) < 0) { + virtPortProfile, virtVlan) < 0) goto error; - } } else { if (virNetDevBridgeAddPort(brname, *ifname) < 0) goto error; diff --git a/src/util/virnetdevvlan.c b/src/util/virnetdevvlan.c index 4c8bce5..f1b3e72 100644 --- a/src/util/virnetdevvlan.c +++ b/src/util/virnetdevvlan.c @@ -58,9 +58,8 @@ virNetDevVlanEqual(const virNetDevVlan *a, const virNetDevVlan *b) if (a->trunk != b->trunk || a->nTags != b->nTags || a->nativeMode != b->nativeMode || - a->nativeTag != b->nativeTag) { + a->nativeTag != b->nativeTag) return false; - } for (ai = 0; ai < a->nTags; ai++) { for (bi = 0; bi < b->nTags; bi++) { diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c index 6ee20d3..237fe79 100644 --- a/src/util/virnetdevvportprofile.c +++ b/src/util/virnetdevvportprofile.c @@ -413,9 +413,8 @@ int virNetDevVPortProfileMerge3(virNetDevVPortProfilePtr *result, if ((!fromInterface || (fromInterface->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE)) && (!fromNetwork || (fromNetwork->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE)) && - (!fromPortgroup || (fromPortgroup->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE))) { + (!fromPortgroup || (fromPortgroup->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE))) return 0; - } /* at least one of the source profiles is non-empty */ if (VIR_ALLOC(*result) < 0) @@ -976,9 +975,8 @@ virNetDevVPortProfileOp8021Qbg(const char *ifname, vf = PORT_SELF_VF; if (virNetDevVPortProfileGetPhysdevAndVlan(ifname, &physdev_ifindex, - physdev_ifname, &vlanid) < 0) { + physdev_ifname, &vlanid) < 0) goto cleanup; - } if (vlanid < 0) vlanid = 0; diff --git a/src/util/virpci.c b/src/util/virpci.c index d8e465f..f6531b0 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -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, @@ -1363,9 +1359,8 @@ virPCIDeviceDetach(virPCIDevicePtr dev, * it's not already there. */ if (inactiveDevs && !virPCIDeviceListFind(inactiveDevs, dev) && - virPCIDeviceListAddCopy(inactiveDevs, dev) < 0) { + virPCIDeviceListAddCopy(inactiveDevs, dev) < 0) return -1; - } return 0; } @@ -1505,9 +1500,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) { @@ -1636,9 +1630,8 @@ virPCIDeviceCopy(virPCIDevicePtr dev) if (VIR_STRDUP(copy->path, dev->path) < 0 || VIR_STRDUP(copy->stubDriver, dev->stubDriver) < 0 || VIR_STRDUP(copy->used_by_drvname, dev->used_by_drvname) < 0 || - VIR_STRDUP(copy->used_by_domname, dev->used_by_domname) < 0) { + VIR_STRDUP(copy->used_by_domname, dev->used_by_domname) < 0) goto error; - } return copy; error: @@ -2365,24 +2358,20 @@ virPCIDeviceAddressParse(char *address, int ret = -1; if ((address == NULL) || (logStrToLong_ui(address, &p, 16, - &bdf->domain) == -1)) { + &bdf->domain) == -1)) goto out; - } if ((p == NULL) || (logStrToLong_ui(p+1, &p, 16, - &bdf->bus) == -1)) { + &bdf->bus) == -1)) goto out; - } if ((p == NULL) || (logStrToLong_ui(p+1, &p, 16, - &bdf->slot) == -1)) { + &bdf->slot) == -1)) goto out; - } if ((p == NULL) || (logStrToLong_ui(p+1, &p, 16, - &bdf->function) == -1)) { + &bdf->function) == -1)) goto out; - } ret = 0; diff --git a/src/util/virsexpr.c b/src/util/virsexpr.c index f8a0ccd..f5f1d5d 100644 --- a/src/util/virsexpr.c +++ b/src/util/virsexpr.c @@ -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; @@ -325,9 +322,8 @@ _string2sexpr(const char *buffer, size_t * end) start = ptr; while (*ptr && !c_isspace(*ptr) - && *ptr != ')' && *ptr != '(') { + && *ptr != ')' && *ptr != '(') ptr++; - } if (VIR_STRNDUP(ret->u.value, start, ptr - start) < 0) goto error; @@ -394,13 +390,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; @@ -409,9 +403,8 @@ sexpr_lookup_key(const struct sexpr *sexpr, const char *node) for (i = sexpr; i->kind != SEXPR_NIL; i = i->u.s.cdr) { if (i->kind != SEXPR_CONS || i->u.s.car->kind != SEXPR_CONS || - i->u.s.car->u.s.car->kind != SEXPR_VALUE) { + i->u.s.car->u.s.car->kind != SEXPR_VALUE) continue; - } if (STREQ(i->u.s.car->u.s.car->u.value, token)) { sexpr = i->u.s.car; @@ -419,14 +412,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 +529,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); diff --git a/src/util/virstorageencryption.c b/src/util/virstorageencryption.c index b5fed58..ec4a8cb 100644 --- a/src/util/virstorageencryption.c +++ b/src/util/virstorageencryption.c @@ -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; diff --git a/src/util/virstoragefile.c b/src/util/virstoragefile.c index 8e9d115..aa97f75 100644 --- a/src/util/virstoragefile.c +++ b/src/util/virstoragefile.c @@ -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) diff --git a/src/util/virsysinfo.c b/src/util/virsysinfo.c index 1bb6392..d644dbc 100644 --- a/src/util/virsysinfo.c +++ b/src/util/virsysinfo.c @@ -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); diff --git a/src/util/virthreadpool.c b/src/util/virthreadpool.c index 4c46f28..0d43696 100644 --- a/src/util/virthreadpool.c +++ b/src/util/virthreadpool.c @@ -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; @@ -200,9 +199,8 @@ virThreadPoolPtr virThreadPoolNew(size_t minWorkers, if (virThreadCreate(&pool->workers[i], true, virThreadPoolWorker, - data) < 0) { + data) < 0) goto error; - } pool->nWorkers++; } @@ -222,9 +220,8 @@ virThreadPoolPtr virThreadPoolNew(size_t minWorkers, if (virThreadCreate(&pool->prioWorkers[i], true, virThreadPoolWorker, - data) < 0) { + data) < 0) goto error; - } pool->nPrioWorkers++; } } diff --git a/src/util/virutil.c b/src/util/virutil.c index 1116fda..f35d218 100644 --- a/src/util/virutil.c +++ b/src/util/virutil.c @@ -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; } @@ -1401,9 +1400,8 @@ virSetUIDGIDWithCaps(uid_t uid, gid_t gid, gid_t *groups, int ngroups, # ifdef PR_CAPBSET_DROP /* If newer kernel, we need also need setpcap to change the bounding set */ if ((capBits || need_setgid || need_setuid) && - !capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP)) { + !capng_have_capability(CAPNG_EFFECTIVE, CAP_SETPCAP)) need_setpcap = true; - } if (need_setpcap) capng_update(CAPNG_ADD, CAPNG_EFFECTIVE|CAPNG_PERMITTED, CAP_SETPCAP); # endif @@ -1539,9 +1537,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 +2560,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; diff --git a/src/util/virxml.c b/src/util/virxml.c index 27ecf14..7f591fb 100644 --- a/src/util/virxml.c +++ b/src/util/virxml.c @@ -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); -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/vbox/vbox_MSCOMGlue.c | 33 +++++++++----------------- src/vbox/vbox_XPCOMCGlue.c | 33 +++++++++----------------- src/vbox/vbox_common.c | 54 +++++++++++++++---------------------------- src/vbox/vbox_network.c | 24 +++++++------------ src/vbox/vbox_snapshot_conf.c | 21 ++++++----------- src/vbox/vbox_storage.c | 30 ++++++++---------------- src/vbox/vbox_tmpl.c | 30 ++++++++---------------- 7 files changed, 75 insertions(+), 150 deletions(-) diff --git a/src/vbox/vbox_MSCOMGlue.c b/src/vbox/vbox_MSCOMGlue.c index c1d3ec3..c0596dd 100644 --- a/src/vbox/vbox_MSCOMGlue.c +++ b/src/vbox/vbox_MSCOMGlue.c @@ -385,9 +385,8 @@ vboxLookupRegistryValue(HKEY key, const char *keyName, const char *valueName) goto cleanup; } - if (value[length - 1] != '\0') { + if (value[length - 1] != '\0') value[length] = '\0'; - } cleanup: return value; @@ -421,17 +420,15 @@ vboxLookupVersionInRegistry(void) * the actual version number is in the VersionExt key then. */ value = vboxLookupRegistryValue(key, keyName, "Version"); - if (value == NULL) { + if (value == NULL) goto cleanup; - } if (STREQ(value, "%VER%")) { VIR_FREE(value); value = vboxLookupRegistryValue(key, keyName, "VersionExt"); - if (value == NULL) { + if (value == NULL) goto cleanup; - } } if (virParseVersionString(value, &vboxVersion, false) < 0) { @@ -478,13 +475,11 @@ vboxUtf16ToUtf8(const PRUnichar *pwszString, char **ppszString) int length = WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, NULL, 0, NULL, NULL); - if (length < 1) { + if (length < 1) return -1; - } - if (VIR_ALLOC_N(*ppszString, length) < 0) { + if (VIR_ALLOC_N(*ppszString, length) < 0) return -1; - } return WideCharToMultiByte(CP_UTF8, 0, pwszString, -1, *ppszString, length, NULL, NULL); @@ -495,15 +490,13 @@ vboxUtf8ToUtf16(const char *pszString, PRUnichar **ppwszString) { int length = MultiByteToWideChar(CP_UTF8, 0, pszString, -1, NULL, 0); - if (length < 1) { + if (length < 1) return -1; - } *ppwszString = SysAllocStringLen(NULL, length); - if (*ppwszString == NULL) { + if (*ppwszString == NULL) return -1; - } return MultiByteToWideChar(CP_UTF8, 0, pszString, -1, *ppwszString, length); } @@ -537,9 +530,8 @@ vboxComInitialize_v2(const char *pszVirtualBoxIID, IVirtualBox **ppVirtualBox, goto cleanup; if (vboxUtf8ToUtf16(mbsVirtualBoxIID, &wcsVirtualBoxIID) < 0 || - vboxUtf8ToUtf16(mbsSessionIID, &wcsSessionIID) < 0) { + vboxUtf8ToUtf16(mbsSessionIID, &wcsSessionIID) < 0) goto cleanup; - } hrc = IIDFromString(wcsVirtualBoxIID, &virtualBoxIID); @@ -668,9 +660,8 @@ vboxGetFunctions(unsigned int version) int VBoxCGlueInit(unsigned int *version) { - if (vboxLookupVersionInRegistry() < 0) { + if (vboxLookupVersionInRegistry() < 0) return -1; - } *version = vboxGetVersion(); g_pfnGetFunctions = vboxGetFunctions; @@ -708,9 +699,8 @@ vboxArrayGetHelper(vboxArray *array, HRESULT hrc, SAFEARRAY *safeArray) array->count = 0; array->handle = NULL; - if (FAILED(hrc)) { + if (FAILED(hrc)) return hrc; - } hrc = SafeArrayAccessData(safeArray, (void **)&items); @@ -781,9 +771,8 @@ vboxArrayGetWithUintArg(vboxArray *array, void *self, void *getter, PRUint32 arg void vboxArrayRelease(vboxArray *array) { - if (array->handle == NULL) { + if (array->handle == NULL) return; - } SafeArrayUnaccessData(array->handle); SafeArrayDestroy(array->handle); diff --git a/src/vbox/vbox_XPCOMCGlue.c b/src/vbox/vbox_XPCOMCGlue.c index aaa7c60..944eb95 100644 --- a/src/vbox/vbox_XPCOMCGlue.c +++ b/src/vbox/vbox_XPCOMCGlue.c @@ -99,9 +99,8 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing, return -1; if (!virFileExists(name)) { - if (!ignoreMissing) { + if (!ignoreMissing) VIR_ERROR(_("Library '%s' doesn't exist"), name); - } VIR_FREE(name); return -1; @@ -130,9 +129,8 @@ tryLoadOne(const char *dir, bool setAppHome, bool ignoreMissing, * FIXME: Don't warn in this case as it currently breaks make check * on systems without VirtualBox. */ - if (dir != NULL) { + if (dir != NULL) VIR_WARN("Could not dlopen '%s': %s", name, dlerror()); - } goto cleanup; } @@ -206,29 +204,25 @@ VBoxCGlueInit(unsigned int *version) /* If the user specifies the location, try only that. */ if (home != NULL) { - if (tryLoadOne(home, false, false, version) < 0) { + if (tryLoadOne(home, false, false, version) < 0) return -1; - } } /* Try the additionally configured location. */ if (VBOX_XPCOMC_DIR[0] != '\0') { - if (tryLoadOne(VBOX_XPCOMC_DIR, true, true, version) >= 0) { + if (tryLoadOne(VBOX_XPCOMC_DIR, true, true, version) >= 0) return 0; - } } /* Try the known locations. */ for (i = 0; i < ARRAY_CARDINALITY(knownDirs); ++i) { - if (tryLoadOne(knownDirs[i], true, true, version) >= 0) { + if (tryLoadOne(knownDirs[i], true, true, version) >= 0) return 0; - } } /* Finally try the dynamic linker search path. */ - if (tryLoadOne(NULL, false, true, version) >= 0) { + if (tryLoadOne(NULL, false, true, version) >= 0) return 0; - } /* No luck, return failure. */ return -1; @@ -271,9 +265,8 @@ vboxArrayGetHelper(vboxArray *array, nsresult nsrc, void **items, PRUint32 count array->items = NULL; array->count = 0; - if (NS_FAILED(nsrc)) { + if (NS_FAILED(nsrc)) return nsrc; - } array->items = items; array->count = count; @@ -338,16 +331,14 @@ vboxArrayRelease(vboxArray *array) size_t i; nsISupports *supports; - if (array->items == NULL) { + if (array->items == NULL) return; - } for (i = 0; i < array->count; ++i) { supports = array->items[i]; - if (supports != NULL) { + if (supports != NULL) supports->vtbl->Release(supports); - } } pVBoxFuncs_v2_2->pfnComUnallocMem(array->items); @@ -365,16 +356,14 @@ vboxArrayUnalloc(vboxArray *array) size_t i; void *item; - if (array->items == NULL) { + if (array->items == NULL) return; - } for (i = 0; i < array->count; ++i) { item = array->items[i]; - if (item != NULL) { + if (item != NULL) pVBoxFuncs_v2_2->pfnComUnallocMem(item); - } } pVBoxFuncs_v2_2->pfnComUnallocMem(array->items); diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index cd5b478..6b1c471 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -955,9 +955,8 @@ vboxSetBootDeviceOrder(virDomainDefPtr def, vboxGlobalData *data, } /* Clear the defaults first */ - for (i = 0; i < maxBootPosition; i++) { + for (i = 0; i < maxBootPosition; i++) gVBoxAPI.UIMachine.SetBootOrder(machine, i+1, DeviceType_Null); - } for (i = 0; (i < def->os.nBootDevs) && (i < maxBootPosition); i++) { PRUint32 device = DeviceType_Null; @@ -1849,9 +1848,8 @@ static virDomainPtr vboxDomainDefineXML(virConnectPtr conn, const char *xml) VBOX_IID_INITIALIZE(&mchiid); if (!(def = virDomainDefParseString(xml, data->caps, data->xmlopt, 1 << VIR_DOMAIN_VIRT_VBOX, - VIR_DOMAIN_XML_INACTIVE))) { + VIR_DOMAIN_XML_INACTIVE))) goto cleanup; - } virUUIDFormat(def->uuid, uuidstr); @@ -2115,9 +2113,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion } } - if (STREQ(valueTypeUtf8, "vrdp")) { + if (STREQ(valueTypeUtf8, "vrdp")) vrdpPresent = 1; - } if (!vrdpPresent && !sdlPresent && !guiPresent) { /* if nothing is selected it means either the machine xml @@ -2159,9 +2156,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIIDUnion VBOX_UTF8_TO_UTF16("sdl", &sessionType); } - if (vrdpPresent) { + if (vrdpPresent) VBOX_UTF8_TO_UTF16("vrdp", &sessionType); - } rc = gVBoxAPI.UIMachine.LaunchVMProcess(data, machine, iid, sessionType, env, @@ -2995,9 +2991,8 @@ vboxHostDeviceGetXMLDesc(vboxGlobalData *data, virDomainDefPtr def, IMachine *ma IUSBDeviceFilter *deviceFilter = deviceFilters.items[i]; gVBoxAPI.UIUSBDeviceFilter.GetActive(deviceFilter, &active); - if (active) { + if (active) def->nhostdevs++; - } } if (def->nhostdevs == 0) @@ -3222,9 +3217,8 @@ vboxDumpIDEHDDsNew(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) /* cleanup on error */ if (error) { - for (i = 0; i < def->ndisks; i++) { + for (i = 0; i < def->ndisks; i++) VIR_FREE(def->disks[i]); - } VIR_FREE(def->disks); def->ndisks = 0; } @@ -3393,14 +3387,12 @@ vboxDumpDisplay(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine) } gVBoxAPI.UIVRDxServer.GetAllowMultiConnection(VRDxServer, &allowMultiConnection); - if (allowMultiConnection) { + if (allowMultiConnection) def->graphics[def->ngraphics]->data.rdp.multiUser = true; - } gVBoxAPI.UIVRDxServer.GetReuseSingleConnection(VRDxServer, &reuseSingleConnection); - if (reuseSingleConnection) { + if (reuseSingleConnection) def->graphics[def->ngraphics]->data.rdp.replaceUser = true; - } def->ngraphics++; } else { @@ -3488,9 +3480,8 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR PRBool enabled = PR_FALSE; gVBoxAPI.UINetworkAdapter.GetEnabled(adapter, &enabled); - if (enabled) { + if (enabled) def->nnets++; - } VBOX_RELEASE(adapter); } @@ -3498,9 +3489,8 @@ vboxDumpNetwork(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PR /* Allocate memory for the networkcards which are enabled */ if ((def->nnets > 0) && (VIR_ALLOC_N(def->nets, def->nnets) >= 0)) { - for (i = 0; i < def->nnets; i++) { + for (i = 0; i < def->nnets; i++) ignore_value(VIR_ALLOC(def->nets[i])); - } } /* Now get the details about the network cards here */ @@ -3669,9 +3659,8 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU PRBool enabled = PR_FALSE; gVBoxAPI.UISerialPort.GetEnabled(serialPort, &enabled); - if (enabled) { + if (enabled) def->nserials++; - } VBOX_RELEASE(serialPort); } @@ -3679,9 +3668,8 @@ vboxDumpSerial(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, PRU /* Allocate memory for the serial ports which are enabled */ if ((def->nserials > 0) && (VIR_ALLOC_N(def->serials, def->nserials) >= 0)) { - for (i = 0; i < def->nserials; i++) { + for (i = 0; i < def->nserials; i++) ignore_value(VIR_ALLOC(def->serials[i])); - } } /* Now get the details about the serial ports here */ @@ -3759,9 +3747,8 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P PRBool enabled = PR_FALSE; gVBoxAPI.UIParallelPort.GetEnabled(parallelPort, &enabled); - if (enabled) { + if (enabled) def->nparallels++; - } VBOX_RELEASE(parallelPort); } @@ -3769,9 +3756,8 @@ vboxDumpParallel(virDomainDefPtr def, vboxGlobalData *data, IMachine *machine, P /* Allocate memory for the parallel ports which are enabled */ if ((def->nparallels > 0) && (VIR_ALLOC_N(def->parallels, def->nparallels) >= 0)) { - for (i = 0; i < def->nparallels; i++) { + for (i = 0; i < def->nparallels; i++) ignore_value(VIR_ALLOC(def->parallels[i])); - } } /* Now get the details about the parallel ports here */ @@ -4078,9 +4064,8 @@ static int vboxConnectNumOfDefinedDomains(virConnectPtr conn) continue; gVBoxAPI.UIMachine.GetState(machine, &state); - if (gVBoxAPI.machineStateChecker.Inactive(state)) { + if (gVBoxAPI.machineStateChecker.Inactive(state)) ret++; - } } cleanup: @@ -5765,9 +5750,8 @@ static int vboxSnapshotGetReadWriteDisks(virDomainSnapshotDefPtr def, ret = 0; cleanup: if (ret < 0) { - for (i = 0; i < def->ndisks; i++) { + for (i = 0; i < def->ndisks; i++) VIR_FREE(def->disks[i].src); - } VIR_FREE(def->disks); def->ndisks = 0; } @@ -6053,13 +6037,11 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, def->dom->os.arch = virArchFromHost(); gVBoxAPI.UIMachine.GetCPUCount(machine, &CPUCount); def->dom->maxvcpus = def->dom->vcpus = CPUCount; - if (vboxSnapshotGetReadWriteDisks(def, snapshot) < 0) { + if (vboxSnapshotGetReadWriteDisks(def, snapshot) < 0) VIR_DEBUG("Could not get read write disks for snapshot"); - } - if (vboxSnapshotGetReadOnlyDisks(snapshot, def) < 0) { + if (vboxSnapshotGetReadOnlyDisks(snapshot, def) < 0) VIR_DEBUG("Could not get Readonly disks for snapshot"); - } } rc = gVBoxAPI.UISnapshot.GetDescription(snap, &str16); diff --git a/src/vbox/vbox_network.c b/src/vbox/vbox_network.c index 792e547..472a49d 100644 --- a/src/vbox/vbox_network.c +++ b/src/vbox/vbox_network.c @@ -429,9 +429,8 @@ vboxSocketFormatAddrUtf16(vboxGlobalData *data, virSocketAddrPtr addr) utf8 = virSocketAddrFormat(addr); - if (utf8 == NULL) { + if (utf8 == NULL) return NULL; - } VBOX_UTF8_TO_UTF16(utf8, &utf16); VIR_FREE(utf8); @@ -820,9 +819,8 @@ vboxSocketParseAddrUtf16(vboxGlobalData *data, const PRUnichar *utf16, VBOX_UTF16_TO_UTF8(utf16, &utf8); - if (virSocketAddrParse(addr, utf8, AF_UNSPEC) < 0) { + if (virSocketAddrParse(addr, utf8, AF_UNSPEC) < 0) goto cleanup; - } result = 0; @@ -918,18 +916,16 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) vboxSocketParseAddrUtf16(data, fromIPAddressUtf16, &ipdef->ranges[0].start) < 0 || vboxSocketParseAddrUtf16(data, toIPAddressUtf16, - &ipdef->ranges[0].end) < 0) { + &ipdef->ranges[0].end) < 0) errorOccurred = true; - } VBOX_UTF16_FREE(ipAddressUtf16); VBOX_UTF16_FREE(networkMaskUtf16); VBOX_UTF16_FREE(fromIPAddressUtf16); VBOX_UTF16_FREE(toIPAddressUtf16); - if (errorOccurred) { + if (errorOccurred) goto cleanup; - } } else { ipdef->nranges = 0; } @@ -950,16 +946,14 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) VBOX_UTF16_TO_UTF8(macAddressUtf16, &ipdef->hosts[0].mac); if (vboxSocketParseAddrUtf16(data, ipAddressUtf16, - &ipdef->hosts[0].ip) < 0) { + &ipdef->hosts[0].ip) < 0) errorOccurred = true; - } VBOX_UTF16_FREE(macAddressUtf16); VBOX_UTF16_FREE(ipAddressUtf16); - if (errorOccurred) { + if (errorOccurred) goto cleanup; - } } } else { ipdef->nhosts = 0; @@ -975,16 +969,14 @@ static char *vboxNetworkGetXMLDesc(virNetworkPtr network, unsigned int flags) if (vboxSocketParseAddrUtf16(data, networkMaskUtf16, &ipdef->netmask) < 0 || vboxSocketParseAddrUtf16(data, ipAddressUtf16, - &ipdef->address) < 0) { + &ipdef->address) < 0) errorOccurred = true; - } VBOX_UTF16_FREE(networkMaskUtf16); VBOX_UTF16_FREE(ipAddressUtf16); - if (errorOccurred) { + if (errorOccurred) goto cleanup; - } } DEBUGIID("Network UUID", &vboxnet0IID); diff --git a/src/vbox/vbox_snapshot_conf.c b/src/vbox/vbox_snapshot_conf.c index 7af1231..57df1fd 100644 --- a/src/vbox/vbox_snapshot_conf.c +++ b/src/vbox/vbox_snapshot_conf.c @@ -226,9 +226,8 @@ virVBoxSnapshotConfRetrieveSnapshot(xmlNodePtr snapshotNode, xPathContext->node = snapshotNode; descriptionNode = virXPathNode("./vbox:Description", xPathContext); - if (descriptionNode != NULL) { + if (descriptionNode != NULL) snapshot->description = virXMLNodeToString(descriptionNode->doc, descriptionNode); - } hardwareNode = virXPathNode("./vbox:Hardware", xPathContext); if (hardwareNode == NULL) { @@ -447,9 +446,8 @@ virVBoxSnapshotConfSerializeSnapshot(xmlNodePtr node, for (i = 0; i < snapshot->nchildren; i++) { xmlNodePtr child = xmlNewNode(NULL, BAD_CAST "Snapshot"); xmlAddChild(snapshotsNode, child); - if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->children[i]) < 0) { + if (virVBoxSnapshotConfSerializeSnapshot(child, snapshot->children[i]) < 0) goto cleanup; - } } } result = 0; @@ -850,9 +848,8 @@ virVBoxSnapshotConfAddHardDiskToMediaRegistry(virVBoxSnapshotConfHardDiskPtr har goto cleanup; parentDisk->children[parentDisk->nchildren - 1] = hardDisk; - if (hardDisk->parent == NULL) { + if (hardDisk->parent == NULL) hardDisk->parent = parentDisk; - } ret = 0; cleanup: @@ -915,9 +912,8 @@ virVBoxSnapshotConfRemoveSnapshot(virVBoxSnapshotConfMachinePtr machine, parentSnapshot = snapshot->parent; snapshot->parent = NULL; - while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot) { + while (i < parentSnapshot->nchildren && parentSnapshot->children[i] != snapshot) ++i; - } if (VIR_DELETE_ELEMENT(parentSnapshot->children, i, parentSnapshot->nchildren) < 0) goto cleanup; @@ -975,9 +971,8 @@ virVBoxSnapshotConfRemoveHardDisk(virVBoxSnapshotConfMediaRegistryPtr mediaRegis parentHardDisk = hardDisk->parent; i = 0; - while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk) { + while (i < parentHardDisk->nchildren && parentHardDisk->children[i] != hardDisk) ++i; - } hardDisk->parent = NULL; if (VIR_DELETE_ELEMENT(parentHardDisk->children, i, parentHardDisk->nchildren) < 0) goto cleanup; @@ -1320,9 +1315,8 @@ virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(const char *filePath, xmlNodePtr node = nodes[i]; xPathContext->node = node; xmlNodePtr sourceNode = virXPathNode("./source", xPathContext); - if (sourceNode) { + if (sourceNode) ret[i] = virXMLPropString(sourceNode, "file"); - } } result = 0; @@ -1382,9 +1376,8 @@ virVBoxSnapshotConfGetRODisksPathsFromLibvirtXML(const char *filePath, xmlNodePtr node = nodes[i]; xPathContext->node = node; xmlNodePtr sourceNode = virXPathNode("./source", xPathContext); - if (sourceNode) { + if (sourceNode) ret[i] = virXMLPropString(sourceNode, "file"); - } } result = 0; diff --git a/src/vbox/vbox_storage.c b/src/vbox/vbox_storage.c index 0cf7a33..194484c 100644 --- a/src/vbox/vbox_storage.c +++ b/src/vbox/vbox_storage.c @@ -120,9 +120,8 @@ static int vboxStoragePoolNumOfVolumes(virStoragePoolPtr pool) size_t i; int ret = -1; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj, gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj)); @@ -162,9 +161,8 @@ vboxStoragePoolListVolumes(virStoragePoolPtr pool, char **const names, int nname size_t i; int ret = -1; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } rc = gVBoxAPI.UArray.vboxArrayGet(&hardDisks, data->vboxObj, gVBoxAPI.UArray.handleGetHardDisks(data->vboxObj)); @@ -218,9 +216,8 @@ vboxStorageVolLookupByName(virStoragePoolPtr pool, const char *name) size_t i; virStorageVolPtr ret = NULL; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } if (!name) return ret; @@ -296,9 +293,8 @@ vboxStorageVolLookupByKey(virConnectPtr conn, const char *key) nsresult rc; virStorageVolPtr ret = NULL; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } VBOX_IID_INITIALIZE(&hddIID); if (!key) @@ -366,9 +362,8 @@ vboxStorageVolLookupByPath(virConnectPtr conn, const char *path) nsresult rc; virStorageVolPtr ret = NULL; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } VBOX_IID_INITIALIZE(&hddIID); @@ -449,9 +444,8 @@ vboxStorageVolCreateXML(virStoragePoolPtr pool, resultCodeUnion resultCode; virStorageVolPtr ret = NULL; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } virCheckFlags(0, NULL); @@ -553,9 +547,8 @@ static int vboxStorageVolDelete(virStorageVolPtr vol, unsigned int flags) vboxIIDUnion hddIID; int ret = -1; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } VBOX_IID_INITIALIZE(&hddIID); virCheckFlags(0, -1); @@ -707,9 +700,8 @@ static int vboxStorageVolGetInfo(virStorageVolPtr vol, virStorageVolInfoPtr info nsresult rc; int ret = -1; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } if (!info) return ret; @@ -767,9 +759,8 @@ static char *vboxStorageVolGetXMLDesc(virStorageVolPtr vol, unsigned int flags) nsresult rc; char *ret = NULL; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } virCheckFlags(0, NULL); @@ -856,9 +847,8 @@ static char *vboxStorageVolGetPath(virStorageVolPtr vol) nsresult rc; char *ret = NULL; - if (!data->vboxObj) { + if (!data->vboxObj) return ret; - } if (virUUIDParse(vol->key, uuid) < 0) { virReportError(VIR_ERR_INVALID_ARG, diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index b2e9ef4..de8744d 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -251,9 +251,8 @@ static void nsIDtoChar(unsigned char *uuid, const nsID *iid) uuidstrdst[16] = uuidstrsrc[14]; uuidstrdst[17] = uuidstrsrc[15]; - for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) { + for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) uuidstrdst[i] = uuidstrsrc[i]; - } uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0'; ignore_value(virUUIDParse(uuidstrdst, uuid)); @@ -291,9 +290,8 @@ static void nsIDFromChar(nsID *iid, const unsigned char *uuid) uuidstrdst[16] = uuidstrsrc[14]; uuidstrdst[17] = uuidstrsrc[15]; - for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) { + for (i = 18; i < VIR_UUID_STRING_BUFLEN; i++) uuidstrdst[i] = uuidstrsrc[i]; - } uuidstrdst[VIR_UUID_STRING_BUFLEN-1] = '\0'; ignore_value(virUUIDParse(uuidstrdst, uuidinterim)); @@ -399,13 +397,11 @@ typedef struct _vboxIID_v2_x vboxIID_v2_x; static void vboxIIDUnalloc_v2_x(vboxGlobalData *data, vboxIID_v2_x *iid) { - if (iid->value == NULL) { + if (iid->value == NULL) return; - } - if (iid->value != &iid->backing) { + if (iid->value != &iid->backing) data->pFuncs->pfnComUnallocMem(iid->value); - } iid->value = NULL; } @@ -500,9 +496,8 @@ typedef struct _vboxIID_v3_x vboxIID_v3_x; static void vboxIIDUnalloc_v3_x(vboxGlobalData *data, vboxIID_v3_x *iid) { - if (iid->value != NULL && iid->owner) { + if (iid->value != NULL && iid->owner) data->pFuncs->pfnUtf16Free(iid->value); - } iid->value = NULL; iid->owner = true; @@ -1770,9 +1765,8 @@ vboxConnectDomainEventRegister(virConnectPtr conn, data->vboxCallback = vboxAllocCallbackObj(); if (data->vboxCallback != NULL) { rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); - if (NS_SUCCEEDED(rc)) { + if (NS_SUCCEEDED(rc)) vboxRet = 0; - } } } else { vboxRet = 0; @@ -1809,9 +1803,8 @@ vboxConnectDomainEventRegister(virConnectPtr conn, if (ret >= 0) { return 0; } else { - if (data->vboxObj && data->vboxCallback) { + if (data->vboxObj && data->vboxCallback) data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); - } return -1; } } @@ -1876,9 +1869,8 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, data->vboxCallback = vboxAllocCallbackObj(); if (data->vboxCallback != NULL) { rc = data->vboxObj->vtbl->RegisterCallback(data->vboxObj, data->vboxCallback); - if (NS_SUCCEEDED(rc)) { + if (NS_SUCCEEDED(rc)) vboxRet = 0; - } } } else { vboxRet = 0; @@ -1917,9 +1909,8 @@ static int vboxConnectDomainEventRegisterAny(virConnectPtr conn, if (ret >= 0) { return ret; } else { - if (data->vboxObj && data->vboxCallback) { + if (data->vboxObj && data->vboxCallback) data->vboxObj->vtbl->UnregisterCallback(data->vboxObj, data->vboxCallback); - } return -1; } } @@ -2350,9 +2341,8 @@ _attachDVD(vboxGlobalData *data, IMachine *machine, const char *src) VBOX_UTF8_TO_UTF16(src, &dvdfileUtf16); data->vboxObj->vtbl->FindDVDImage(data->vboxObj, dvdfileUtf16, &dvdImage); - if (!dvdImage) { + if (!dvdImage) data->vboxObj->vtbl->OpenDVDImage(data->vboxObj, dvdfileUtf16, dvdemptyuuid.value, &dvdImage); - } if (!dvdImage) goto cleanup; -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/vmx/vmx.c | 369 ++++++++++++++++++++-------------------------------------- 1 file changed, 123 insertions(+), 246 deletions(-) diff --git a/src/vmx/vmx.c b/src/vmx/vmx.c index 389a012..79a3d11 100644 --- a/src/vmx/vmx.c +++ b/src/vmx/vmx.c @@ -565,9 +565,8 @@ virVMXEscapeHex(const char *string, char escape, const char *special) /* Calculate length of escaped string */ while (*tmp1 != '\0') { - if (*tmp1 == escape || strspn(tmp1, special) > 0) { + if (*tmp1 == escape || strspn(tmp1, special) > 0) length += 2; - } ++tmp1; ++length; @@ -610,9 +609,8 @@ virVMXUnescapeHex(char *string, char escape) /* Unescape from 'cXX' where c is the escape char and X is a hex digit */ while (*tmp1 != '\0') { if (*tmp1 == escape) { - if (!c_isxdigit(tmp1[1]) || !c_isxdigit(tmp1[2])) { + if (!c_isxdigit(tmp1[1]) || !c_isxdigit(tmp1[2])) return -1; - } *tmp2++ = virHexToBin(tmp1[1]) * 16 + virHexToBin(tmp1[2]); tmp1 += 3; @@ -676,9 +674,8 @@ virVMXGetConfigString(virConfPtr conf, const char *name, char **string, value = virConfGetValue(conf, name); if (value == NULL) { - if (optional) { + if (optional) return 0; - } virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing essential config entry '%s'"), name); @@ -692,9 +689,8 @@ virVMXGetConfigString(virConfPtr conf, const char *name, char **string, } if (value->str == NULL) { - if (optional) { + if (optional) return 0; - } virReportError(VIR_ERR_INTERNAL_ERROR, _("Missing essential config entry '%s'"), name); @@ -882,9 +878,8 @@ virVMXSCSIDiskNameToControllerAndUnit(const char *name, int *controller, int *un *unit = idx % 15; /* Skip the controller ifself at unit 7 */ - if (*unit >= 7) { + if (*unit >= 7) ++(*unit); - } return 0; } @@ -1082,17 +1077,15 @@ virVMXHandleLegacySCSIDiskDriverName(virDomainDefPtr def, const char *driver = virDomainDiskGetDriver(disk); char *copy; - if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI || !driver) { + if (disk->bus != VIR_DOMAIN_DISK_BUS_SCSI || !driver) return 0; - } if (VIR_STRDUP(copy, driver) < 0) return -1; tmp = copy; - for (; *tmp != '\0'; ++tmp) { + for (; *tmp != '\0'; ++tmp) *tmp = c_tolower(*tmp); - } model = virDomainControllerModelSCSITypeFromString(copy); VIR_FREE(copy); @@ -1186,9 +1179,8 @@ virVMXGatherSCSIControllers(virVMXContext *ctx, virDomainDefPtr def, disk->info.addr.drive.controller == controller->idx) { if (ctx->autodetectSCSIControllerModel (disk, &autodetectedModels[count], - ctx->opaque) < 0) { + ctx->opaque) < 0) goto cleanup; - } ++count; } @@ -1278,14 +1270,12 @@ virVMXParseConfig(virVMXContext *ctx, conf = virConfReadMem(vmx, strlen(vmx), VIR_CONF_FLAG_VMX_FORMAT); - if (conf == NULL) { + if (conf == NULL) return NULL; - } /* vmx:.encoding */ - if (virVMXGetConfigString(conf, ".encoding", &encoding, true) < 0) { + if (virVMXGetConfigString(conf, ".encoding", &encoding, true) < 0) goto cleanup; - } if (encoding == NULL || STRCASEEQ(encoding, "UTF-8")) { /* nothing */ @@ -1295,17 +1285,15 @@ virVMXParseConfig(virVMXContext *ctx, utf8 = virVMXConvertToUTF8(encoding, vmx); - if (utf8 == NULL) { + if (utf8 == NULL) goto cleanup; - } conf = virConfReadMem(utf8, strlen(utf8), VIR_CONF_FLAG_VMX_FORMAT); VIR_FREE(utf8); - if (conf == NULL) { + if (conf == NULL) goto cleanup; - } } /* Allocate domain def */ @@ -1317,9 +1305,8 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:config.version */ if (virVMXGetConfigLong(conf, "config.version", &config_version, 0, - false) < 0) { + false) < 0) goto cleanup; - } if (config_version != 8) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1330,9 +1317,8 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:virtualHW.version */ if (virVMXGetConfigLong(conf, "virtualHW.version", &virtualHW_version, 0, - false) < 0) { + false) < 0) goto cleanup; - } if (virtualHW_version < 4) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1344,14 +1330,12 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:uuid.bios -> def:uuid */ /* FIXME: Need to handle 'uuid.action = "create"' */ - if (virVMXGetConfigUUID(conf, "uuid.bios", def->uuid, true) < 0) { + if (virVMXGetConfigUUID(conf, "uuid.bios", def->uuid, true) < 0) goto cleanup; - } /* vmx:displayName -> def:name */ - if (virVMXGetConfigString(conf, "displayName", &def->name, true) < 0) { + if (virVMXGetConfigString(conf, "displayName", &def->name, true) < 0) goto cleanup; - } if (def->name != NULL) { if (virVMXUnescapeHexPercent(def->name) < 0 || @@ -1364,9 +1348,8 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:annotation -> def:description */ if (virVMXGetConfigString(conf, "annotation", &def->description, - true) < 0) { + true) < 0) goto cleanup; - } if (def->description != NULL) { if (virVMXUnescapeHexPipe(def->description) < 0) { @@ -1378,9 +1361,8 @@ virVMXParseConfig(virVMXContext *ctx, } /* vmx:memsize -> def:mem.max_balloon */ - if (virVMXGetConfigLong(conf, "memsize", &memsize, 32, true) < 0) { + if (virVMXGetConfigLong(conf, "memsize", &memsize, 32, true) < 0) goto cleanup; - } if (memsize <= 0 || memsize % 4 != 0) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1393,40 +1375,33 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:sched.mem.max -> def:mem.cur_balloon */ if (virVMXGetConfigLong(conf, "sched.mem.max", &sched_mem_max, memsize, - true) < 0) { + true) < 0) goto cleanup; - } - if (sched_mem_max < 0) { + if (sched_mem_max < 0) sched_mem_max = memsize; - } def->mem.cur_balloon = sched_mem_max * 1024; /* Scale from megabytes to kilobytes */ - if (def->mem.cur_balloon > def->mem.max_balloon) { + if (def->mem.cur_balloon > def->mem.max_balloon) def->mem.cur_balloon = def->mem.max_balloon; - } /* vmx:sched.mem.minsize -> def:mem.min_guarantee */ if (virVMXGetConfigLong(conf, "sched.mem.minsize", &sched_mem_minsize, 0, - true) < 0) { + true) < 0) goto cleanup; - } - if (sched_mem_minsize < 0) { + if (sched_mem_minsize < 0) sched_mem_minsize = 0; - } def->mem.min_guarantee = sched_mem_minsize * 1024; /* Scale from megabytes to kilobytes */ - if (def->mem.min_guarantee > def->mem.max_balloon) { + if (def->mem.min_guarantee > def->mem.max_balloon) def->mem.min_guarantee = def->mem.max_balloon; - } /* vmx:numvcpus -> def:vcpus */ - if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0) { + if (virVMXGetConfigLong(conf, "numvcpus", &numvcpus, 1, true) < 0) goto cleanup; - } if (numvcpus <= 0 || (numvcpus % 2 != 0 && numvcpus != 1)) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1440,9 +1415,8 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:sched.cpu.affinity -> def:cpumask */ /* NOTE: maps to VirtualMachine:config.cpuAffinity.affinitySet */ if (virVMXGetConfigString(conf, "sched.cpu.affinity", &sched_cpu_affinity, - true) < 0) { + true) < 0) goto cleanup; - } if (sched_cpu_affinity != NULL && STRCASENEQ(sched_cpu_affinity, "all")) { const char *current = sched_cpu_affinity; @@ -1474,9 +1448,8 @@ virVMXParseConfig(virVMXContext *ctx, goto cleanup; } - if (number + 1 > cpumasklen) { + if (number + 1 > cpumasklen) cpumasklen = number + 1; - } ignore_value(virBitmapSetBit(def->cpumask, number)); ++count; @@ -1509,9 +1482,8 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:sched.cpu.shares -> def:cputune.shares */ if (virVMXGetConfigString(conf, "sched.cpu.shares", &sched_cpu_shares, - true) < 0) { + true) < 0) goto cleanup; - } if (sched_cpu_shares != NULL) { /* See http://www.vmware.com/support/developer/vc-sdk/visdk41pubs/ApiReference/vim.... */ @@ -1542,9 +1514,8 @@ virVMXParseConfig(virVMXContext *ctx, goto cleanup; /* vmx:guestOS -> def:os.arch */ - if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0) { + if (virVMXGetConfigString(conf, "guestOS", &guestOS, true) < 0) goto cleanup; - } if (guestOS != NULL && virFileHasSuffix(guestOS, "-64")) { def->os.arch = VIR_ARCH_X86_64; @@ -1554,13 +1525,11 @@ virVMXParseConfig(virVMXContext *ctx, /* vmx:smbios.reflecthost -> def:os.smbios_mode */ if (virVMXGetConfigBoolean(conf, "smbios.reflecthost", - &smbios_reflecthost, false, true) < 0) { + &smbios_reflecthost, false, true) < 0) goto cleanup; - } - if (smbios_reflecthost) { + if (smbios_reflecthost) def->os.smbios_mode = VIR_DOMAIN_SMBIOS_HOST; - } /* def:features */ /* FIXME */ @@ -1574,13 +1543,11 @@ virVMXParseConfig(virVMXContext *ctx, def->ngraphics = 0; - if (virVMXParseVNC(conf, &def->graphics[def->ngraphics]) < 0) { + if (virVMXParseVNC(conf, &def->graphics[def->ngraphics]) < 0) goto cleanup; - } - if (def->graphics[def->ngraphics] != NULL) { + if (def->graphics[def->ngraphics] != NULL) ++def->ngraphics; - } /* def:disks: 4 * 15 scsi + 2 * 2 ide + 2 floppy = 66 */ if (VIR_ALLOC_N(def->disks, 66) < 0) @@ -1591,13 +1558,11 @@ virVMXParseConfig(virVMXContext *ctx, /* def:disks (scsi) */ for (controller = 0; controller < 4; ++controller) { if (virVMXParseSCSIController(conf, controller, &present, - &scsi_virtualDev[controller]) < 0) { + &scsi_virtualDev[controller]) < 0) goto cleanup; - } - if (! present) { + if (! present) continue; - } for (unit = 0; unit < 16; ++unit) { if (unit == 7) { @@ -1610,9 +1575,8 @@ virVMXParseConfig(virVMXContext *ctx, if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_BUS_SCSI, controller, unit, - &def->disks[def->ndisks]) < 0) { + &def->disks[def->ndisks]) < 0) goto cleanup; - } if (def->disks[def->ndisks] != NULL) { ++def->ndisks; @@ -1621,13 +1585,11 @@ virVMXParseConfig(virVMXContext *ctx, if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, VIR_DOMAIN_DISK_BUS_SCSI, controller, unit, - &def->disks[def->ndisks]) < 0) { + &def->disks[def->ndisks]) < 0) goto cleanup; - } - if (def->disks[def->ndisks] != NULL) { + if (def->disks[def->ndisks] != NULL) ++def->ndisks; - } } } @@ -1636,9 +1598,8 @@ virVMXParseConfig(virVMXContext *ctx, for (unit = 0; unit < 2; ++unit) { if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_DISK, VIR_DOMAIN_DISK_BUS_IDE, bus, unit, - &def->disks[def->ndisks]) < 0) { + &def->disks[def->ndisks]) < 0) goto cleanup; - } if (def->disks[def->ndisks] != NULL) { ++def->ndisks; @@ -1647,13 +1608,11 @@ virVMXParseConfig(virVMXContext *ctx, if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_CDROM, VIR_DOMAIN_DISK_BUS_IDE, bus, unit, - &def->disks[def->ndisks]) < 0) { + &def->disks[def->ndisks]) < 0) goto cleanup; - } - if (def->disks[def->ndisks] != NULL) { + if (def->disks[def->ndisks] != NULL) ++def->ndisks; - } } } @@ -1661,13 +1620,11 @@ virVMXParseConfig(virVMXContext *ctx, for (unit = 0; unit < 2; ++unit) { if (virVMXParseDisk(ctx, xmlopt, conf, VIR_DOMAIN_DISK_DEVICE_FLOPPY, VIR_DOMAIN_DISK_BUS_FDC, 0, unit, - &def->disks[def->ndisks]) < 0) { + &def->disks[def->ndisks]) < 0) goto cleanup; - } - if (def->disks[def->ndisks] != NULL) { + if (def->disks[def->ndisks] != NULL) ++def->ndisks; - } } /* def:controllers */ @@ -1692,15 +1649,13 @@ virVMXParseConfig(virVMXContext *ctx, /* def:fss */ if (virVMXGetConfigBoolean(conf, "isolation.tools.hgfs.disable", - &hgfs_disabled, true, true) < 0) { + &hgfs_disabled, true, true) < 0) goto cleanup; - } if (!hgfs_disabled) { if (virVMXGetConfigLong(conf, "sharedFolder.maxNum", &sharedFolder_maxNum, - 0, true) < 0) { + 0, true) < 0) goto cleanup; - } if (sharedFolder_maxNum > 0) { int number; @@ -1712,13 +1667,11 @@ virVMXParseConfig(virVMXContext *ctx, for (number = 0; number < sharedFolder_maxNum; ++number) { if (virVMXParseFileSystem(conf, number, - &def->fss[def->nfss]) < 0) { + &def->fss[def->nfss]) < 0) goto cleanup; - } - if (def->fss[def->nfss] != NULL) { + if (def->fss[def->nfss] != NULL) ++def->nfss; - } } } } @@ -1731,13 +1684,11 @@ virVMXParseConfig(virVMXContext *ctx, for (controller = 0; controller < 4; ++controller) { if (virVMXParseEthernet(conf, controller, - &def->nets[def->nnets]) < 0) { + &def->nets[def->nnets]) < 0) goto cleanup; - } - if (def->nets[def->nnets] != NULL) { + if (def->nets[def->nnets] != NULL) ++def->nnets; - } } /* def:inputs */ @@ -1749,9 +1700,8 @@ virVMXParseConfig(virVMXContext *ctx, def->nvideos = 0; - if (virVMXParseSVGA(conf, &def->videos[def->nvideos]) < 0) { + if (virVMXParseSVGA(conf, &def->videos[def->nvideos]) < 0) goto cleanup; - } def->nvideos = 1; @@ -1769,13 +1719,11 @@ virVMXParseConfig(virVMXContext *ctx, for (port = 0; port < 4; ++port) { if (virVMXParseSerial(ctx, conf, port, - &def->serials[def->nserials]) < 0) { + &def->serials[def->nserials]) < 0) goto cleanup; - } - if (def->serials[def->nserials] != NULL) { + if (def->serials[def->nserials] != NULL) ++def->nserials; - } } /* def:parallels */ @@ -1786,13 +1734,11 @@ virVMXParseConfig(virVMXContext *ctx, for (port = 0; port < 3; ++port) { if (virVMXParseParallel(ctx, conf, port, - &def->parallels[def->nparallels]) < 0) { + &def->parallels[def->nparallels]) < 0) goto cleanup; - } - if (def->parallels[def->nparallels] != NULL) { + if (def->parallels[def->nparallels] != NULL) ++def->nparallels; - } } success = true; @@ -1827,13 +1773,11 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) } if (virVMXGetConfigBoolean(conf, "RemoteDisplay.vnc.enabled", &enabled, - false, true) < 0) { + false, true) < 0) return -1; - } - if (! enabled) { + if (! enabled) return 0; - } if (VIR_ALLOC(*def) < 0) goto failure; @@ -1847,9 +1791,8 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) virVMXGetConfigString(conf, "RemoteDisplay.vnc.keymap", &(*def)->data.vnc.keymap, true) < 0 || virVMXGetConfigString(conf, "RemoteDisplay.vnc.password", - &(*def)->data.vnc.auth.passwd, true) < 0) { + &(*def)->data.vnc.auth.passwd, true) < 0) goto failure; - } if (listenAddr) { if (virDomainGraphicsListenSetAddress(*def, 0, listenAddr, -1, true) < 0) @@ -1864,9 +1807,8 @@ virVMXParseVNC(virConfPtr conf, virDomainGraphicsDefPtr *def) (*def)->data.vnc.port = 0; (*def)->data.vnc.autoport = true; } else { - if (port < 5900 || port > 5964) { + if (port < 5900 || port > 5964) VIR_WARN("VNC port %lld it out of [5900..5964] range", port); - } (*def)->data.vnc.port = port; (*def)->data.vnc.autoport = false; @@ -1910,9 +1852,8 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, snprintf(virtualDev_name, sizeof(virtualDev_name), "scsi%d.virtualDev", controller); - if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, present_name, present, false, true) < 0) goto cleanup; - } if (! *present) { result = 0; @@ -1920,16 +1861,14 @@ virVMXParseSCSIController(virConfPtr conf, int controller, bool *present, } if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev_string, - true) < 0) { + true) < 0) goto cleanup; - } if (virtualDev_string != NULL) { tmp = virtualDev_string; - for (; *tmp != '\0'; ++tmp) { + for (; *tmp != '\0'; ++tmp) *tmp = c_tolower(*tmp); - } *virtualDev = virVMXControllerModelSCSITypeFromString(virtualDev_string); @@ -2045,9 +1984,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con virIndexToDiskName (controllerOrBus * 15 + (unit < 7 ? unit : unit - 1), "sd"); - if ((*def)->dst == NULL) { + if ((*def)->dst == NULL) goto cleanup; - } } else if (busType == VIR_DOMAIN_DISK_BUS_IDE) { if (controllerOrBus < 0 || controllerOrBus > 1) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -2067,9 +2005,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con (*def)->dst = virIndexToDiskName(controllerOrBus * 2 + unit, "hd"); - if ((*def)->dst == NULL) { + if ((*def)->dst == NULL) goto cleanup; - } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported bus type '%s' for device type '%s'"), @@ -2098,9 +2035,8 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con (*def)->dst = virIndexToDiskName(unit, "fd"); - if ((*def)->dst == NULL) { + if ((*def)->dst == NULL) goto cleanup; - } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported bus type '%s' for device type '%s'"), @@ -2125,36 +2061,30 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con VMX_BUILD_NAME(mode); /* vmx:present */ - if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) goto cleanup; - } /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, - true, true) < 0) { + true, true) < 0) goto cleanup; - } /* FIXME: Need to distiguish between active and inactive domains here */ - if (! present/* && ! startConnected*/) { + if (! present/* && ! startConnected*/) goto ignore; - } /* vmx:deviceType -> def:type */ - if (virVMXGetConfigString(conf, deviceType_name, &deviceType, true) < 0) { + if (virVMXGetConfigString(conf, deviceType_name, &deviceType, true) < 0) goto cleanup; - } /* vmx:clientDevice */ if (virVMXGetConfigBoolean(conf, clientDevice_name, &clientDevice, false, - true) < 0) { + true) < 0) goto cleanup; - } /* vmx:mode -> def:transient */ - if (virVMXGetConfigString(conf, mode_name, &mode, true) < 0) { + if (virVMXGetConfigString(conf, mode_name, &mode, true) < 0) goto cleanup; - } if (clientDevice) { /* @@ -2165,20 +2095,17 @@ virVMXParseDisk(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virConfPtr con } /* vmx:fileType -> def:type */ - if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0) { + if (virVMXGetConfigString(conf, fileType_name, &fileType, true) < 0) goto cleanup; - } /* vmx:fileName -> def:src, def:type */ - if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) { + if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) goto cleanup; - } /* vmx:writeThrough -> def:cachemode */ if (virVMXGetConfigBoolean(conf, writeThrough_name, &writeThrough, false, - true) < 0) { + true) < 0) goto cleanup; - } /* Setup virDomainDiskDef */ if (device == VIR_DOMAIN_DISK_DEVICE_DISK) { @@ -2396,40 +2323,34 @@ int virVMXParseFileSystem(virConfPtr conf, int number, virDomainFSDefPtr *def) VMX_BUILD_NAME(writeAccess); /* vmx:present */ - if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) goto cleanup; - } /* vmx:enabled */ - if (virVMXGetConfigBoolean(conf, enabled_name, &enabled, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, enabled_name, &enabled, false, true) < 0) goto cleanup; - } - if (!(present && enabled)) { + if (!(present && enabled)) goto ignore; - } /* vmx:hostPath */ - if (virVMXGetConfigString(conf, hostPath_name, &hostPath, false) < 0) { + if (virVMXGetConfigString(conf, hostPath_name, &hostPath, false) < 0) goto cleanup; - } (*def)->src = hostPath; hostPath = NULL; /* vmx:guestName */ - if (virVMXGetConfigString(conf, guestName_name, &guestName, false) < 0) { + if (virVMXGetConfigString(conf, guestName_name, &guestName, false) < 0) goto cleanup; - } (*def)->dst = guestName; guestName = NULL; /* vmx:writeAccess */ if (virVMXGetConfigBoolean(conf, writeAccess_name, &writeAccess, false, - true) < 0) { + true) < 0) goto cleanup; - } (*def)->readonly = !writeAccess; @@ -2522,35 +2443,30 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) VMX_BUILD_NAME(vnet); /* vmx:present */ - if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) goto cleanup; - } /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, - true, true) < 0) { + true, true) < 0) goto cleanup; - } /* FIXME: Need to distiguish between active and inactive domains here */ - if (! present/* && ! startConnected*/) { + if (! present/* && ! startConnected*/) goto ignore; - } /* vmx:connectionType -> def:type */ if (virVMXGetConfigString(conf, connectionType_name, &connectionType, - true) < 0) { + true) < 0) goto cleanup; - } /* vmx:addressType, vmx:generatedAddress, vmx:address -> def:mac */ if (virVMXGetConfigString(conf, addressType_name, &addressType, true) < 0 || virVMXGetConfigString(conf, generatedAddress_name, &generatedAddress, true) < 0 || - virVMXGetConfigString(conf, address_name, &address, true) < 0) { + virVMXGetConfigString(conf, address_name, &address, true) < 0) goto cleanup; - } if (addressType == NULL || STRCASEEQ(addressType, "generated") || STRCASEEQ(addressType, "vpx")) { @@ -2581,9 +2497,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) /* vmx:virtualDev, vmx:features -> def:model */ if (virVMXGetConfigString(conf, virtualDev_name, &virtualDev, true) < 0 || - virVMXGetConfigLong(conf, features_name, &features, 0, true) < 0) { + virVMXGetConfigLong(conf, features_name, &features, 0, true) < 0) goto cleanup; - } if (virtualDev != NULL) { if (STRCASENEQ(virtualDev, "vlance") && @@ -2619,9 +2534,8 @@ virVMXParseEthernet(virConfPtr conf, int controller, virDomainNetDefPtr *def) /* vmx:vnet -> def:data.ifname */ if (connectionType != NULL && STRCASEEQ(connectionType, "custom") && - virVMXGetConfigString(conf, vnet_name, &vnet, false) < 0) { + virVMXGetConfigString(conf, vnet_name, &vnet, false) < 0) goto cleanup; - } /* Setup virDomainNetDef */ if (connectionType == NULL || STRCASEEQ(connectionType, "bridged")) { @@ -2736,36 +2650,30 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, VMX_BUILD_NAME_EXTRA(network_endPoint, "network.endPoint"); /* vmx:present */ - if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) goto cleanup; - } /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, - true, true) < 0) { + true, true) < 0) goto cleanup; - } /* FIXME: Need to distiguish between active and inactive domains here */ - if (! present/* && ! startConnected*/) { + if (! present/* && ! startConnected*/) goto ignore; - } /* vmx:fileType -> def:type */ - if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) { + if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) goto cleanup; - } /* vmx:fileName -> def:data.file.path */ - if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0) { + if (virVMXGetConfigString(conf, fileName_name, &fileName, true) < 0) goto cleanup; - } /* vmx:network.endPoint -> def:data.tcp.listen */ if (virVMXGetConfigString(conf, network_endPoint_name, &network_endPoint, - true) < 0) { + true) < 0) goto cleanup; - } /* Setup virDomainChrDef */ if (STRCASEEQ(fileType, "device")) { @@ -2780,9 +2688,8 @@ virVMXParseSerial(virVMXContext *ctx, virConfPtr conf, int port, (*def)->source.data.file.path = ctx->parseFileName(fileName, ctx->opaque); - if ((*def)->source.data.file.path == NULL) { + if ((*def)->source.data.file.path == NULL) goto cleanup; - } } else if (STRCASEEQ(fileType, "pipe")) { /* * FIXME: Differences between client/server and VM/application pipes @@ -2924,30 +2831,25 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port, VMX_BUILD_NAME(fileName); /* vmx:present */ - if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) { + if (virVMXGetConfigBoolean(conf, present_name, &present, false, true) < 0) goto cleanup; - } /* vmx:startConnected */ if (virVMXGetConfigBoolean(conf, startConnected_name, &startConnected, - true, true) < 0) { + true, true) < 0) goto cleanup; - } /* FIXME: Need to distiguish between active and inactive domains here */ - if (! present/* && ! startConnected*/) { + if (! present/* && ! startConnected*/) goto ignore; - } /* vmx:fileType -> def:type */ - if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) { + if (virVMXGetConfigString(conf, fileType_name, &fileType, false) < 0) goto cleanup; - } /* vmx:fileName -> def:data.file.path */ - if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) { + if (virVMXGetConfigString(conf, fileName_name, &fileName, false) < 0) goto cleanup; - } /* Setup virDomainChrDef */ if (STRCASEEQ(fileType, "device")) { @@ -2962,9 +2864,8 @@ virVMXParseParallel(virVMXContext *ctx, virConfPtr conf, int port, (*def)->source.data.file.path = ctx->parseFileName(fileName, ctx->opaque); - if ((*def)->source.data.file.path == NULL) { + if ((*def)->source.data.file.path == NULL) goto cleanup; - } } else { virReportError(VIR_ERR_INTERNAL_ERROR, _("Expecting VMX entry '%s' to be 'device' or 'file' but " @@ -3014,9 +2915,8 @@ virVMXParseSVGA(virConfPtr conf, virDomainVideoDefPtr *def) /* vmx:vramSize */ if (virVMXGetConfigLong(conf, "svga.vramSize", &svga_vramSize, - 4 * 1024 * 1024, true) < 0) { + 4 * 1024 * 1024, true) < 0) goto cleanup; - } (*def)->vram = VIR_DIV_UP(svga_vramSize, 1024); /* Scale from bytes to kilobytes */ @@ -3122,15 +3022,13 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe /* def:name -> vmx:displayName */ preliminaryDisplayName = virVMXEscapeHexPipe(def->name); - if (preliminaryDisplayName == NULL) { + if (preliminaryDisplayName == NULL) goto cleanup; - } displayName = virVMXEscapeHexPercent(preliminaryDisplayName); - if (displayName == NULL) { + if (displayName == NULL) goto cleanup; - } virBufferAsprintf(&buffer, "displayName = \"%s\"\n", displayName); @@ -3188,9 +3086,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe sched_cpu_affinity_length = 0; bit = -1; - while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0) { + while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0) ++sched_cpu_affinity_length; - } if (sched_cpu_affinity_length < def->maxvcpus) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -3204,9 +3101,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe while ((bit = virBitmapNextSetBit(def->cpumask, bit)) >= 0) { virBufferAsprintf(&buffer, "%d", bit); - if (sched_cpu_affinity_length > 1) { + if (sched_cpu_affinity_length > 1) virBufferAddChar(&buffer, ','); - } --sched_cpu_affinity_length; } @@ -3233,9 +3129,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe for (i = 0; i < def->ngraphics; ++i) { switch (def->graphics[i]->type) { case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - if (virVMXFormatVNC(def->graphics[i], &buffer) < 0) { + if (virVMXFormatVNC(def->graphics[i], &buffer) < 0) goto cleanup; - } break; @@ -3250,15 +3145,13 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe /* def:disks */ for (i = 0; i < def->ndisks; ++i) { if (virVMXVerifyDiskAddress(xmlopt, def->disks[i]) < 0 || - virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) { + virVMXHandleLegacySCSIDiskDriverName(def, def->disks[i]) < 0) goto cleanup; - } } if (virVMXGatherSCSIControllers(ctx, def, scsi_virtualDev, - scsi_present) < 0) { + scsi_present) < 0) goto cleanup; - } for (i = 0; i < 4; ++i) { if (scsi_present[i]) { @@ -3277,17 +3170,15 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe case VIR_DOMAIN_DISK_DEVICE_DISK: case VIR_DOMAIN_DISK_DEVICE_CDROM: case VIR_DOMAIN_DISK_DEVICE_LUN: - if (virVMXFormatDisk(ctx, def->disks[i], &buffer) < 0) { + if (virVMXFormatDisk(ctx, def->disks[i], &buffer) < 0) goto cleanup; - } break; case VIR_DOMAIN_DISK_DEVICE_FLOPPY: if (virVMXFormatFloppy(ctx, def->disks[i], &buffer, - floppy_present) < 0) { + floppy_present) < 0) goto cleanup; - } break; @@ -3301,9 +3192,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe for (i = 0; i < 2; ++i) { /* floppy[0..1].present defaults to true, disable it explicitly */ - if (! floppy_present[i]) { + if (! floppy_present[i]) virBufferAsprintf(&buffer, "floppy%zu.present = \"false\"\n", i); - } } /* def:fss */ @@ -3313,16 +3203,14 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe } for (i = 0; i < def->nfss; ++i) { - if (virVMXFormatFileSystem(def->fss[i], i, &buffer) < 0) { + if (virVMXFormatFileSystem(def->fss[i], i, &buffer) < 0) goto cleanup; - } } /* def:nets */ for (i = 0; i < def->nnets; ++i) { - if (virVMXFormatEthernet(def->nets[i], i, &buffer) < 0) { + if (virVMXFormatEthernet(def->nets[i], i, &buffer) < 0) goto cleanup; - } } /* def:inputs */ @@ -3339,9 +3227,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe goto cleanup; } - if (virVMXFormatSVGA(def->videos[0], &buffer) < 0) { + if (virVMXFormatSVGA(def->videos[0], &buffer) < 0) goto cleanup; - } } /* def:hostdevs */ @@ -3349,16 +3236,14 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe /* def:serials */ for (i = 0; i < def->nserials; ++i) { - if (virVMXFormatSerial(ctx, def->serials[i], &buffer) < 0) { + if (virVMXFormatSerial(ctx, def->serials[i], &buffer) < 0) goto cleanup; - } } /* def:parallels */ for (i = 0; i < def->nparallels; ++i) { - if (virVMXFormatParallel(ctx, def->parallels[i], &buffer) < 0) { + if (virVMXFormatParallel(ctx, def->parallels[i], &buffer) < 0) goto cleanup; - } } /* Get final VMX output */ @@ -3368,9 +3253,8 @@ virVMXFormatConfig(virVMXContext *ctx, virDomainXMLOptionPtr xmlopt, virDomainDe vmx = virBufferContentAndReset(&buffer); cleanup: - if (vmx == NULL) { + if (vmx == NULL) virBufferFreeAndReset(&buffer); - } VIR_FREE(preliminaryDisplayName); VIR_FREE(displayName); @@ -3467,14 +3351,12 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def, if (def->bus == VIR_DOMAIN_DISK_BUS_SCSI) { if (virVMXSCSIDiskNameToControllerAndUnit(def->dst, &controllerOrBus, - &unit) < 0) { + &unit) < 0) return -1; - } } else if (def->bus == VIR_DOMAIN_DISK_BUS_IDE) { if (virVMXIDEDiskNameToBusAndUnit(def->dst, &controllerOrBus, - &unit) < 0) { + &unit) < 0) return -1; - } } else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("Unsupported bus type '%s' for %s"), @@ -3518,9 +3400,8 @@ virVMXFormatDisk(virVMXContext *ctx, virDomainDiskDefPtr def, fileName = ctx->formatFileName(src, ctx->opaque); - if (fileName == NULL) { + if (fileName == NULL) return -1; - } virBufferAsprintf(buffer, "%s%d:%d.fileName = \"%s\"\n", busType, controllerOrBus, unit, fileName); @@ -3575,9 +3456,8 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def, return -1; } - if (virVMXFloppyDiskNameToUnit(def->dst, &unit) < 0) { + if (virVMXFloppyDiskNameToUnit(def->dst, &unit) < 0) return -1; - } floppy_present[unit] = true; @@ -3589,9 +3469,8 @@ virVMXFormatFloppy(virVMXContext *ctx, virDomainDiskDefPtr def, if (src) { fileName = ctx->formatFileName(src, ctx->opaque); - if (fileName == NULL) { + if (fileName == NULL) return -1; - } virBufferAsprintf(buffer, "floppy%d.fileName = \"%s\"\n", unit, fileName); @@ -3784,9 +3663,8 @@ virVMXFormatSerial(virVMXContext *ctx, virDomainChrDefPtr def, fileName = ctx->formatFileName(def->source.data.file.path, ctx->opaque); - if (fileName == NULL) { + if (fileName == NULL) return -1; - } virBufferAsprintf(buffer, "serial%d.fileName = \"%s\"\n", def->target.port, fileName); @@ -3891,9 +3769,8 @@ virVMXFormatParallel(virVMXContext *ctx, virDomainChrDefPtr def, fileName = ctx->formatFileName(def->source.data.file.path, ctx->opaque); - if (fileName == NULL) { + if (fileName == NULL) return -1; - } virBufferAsprintf(buffer, "parallel%d.fileName = \"%s\"\n", def->target.port, fileName); -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/uml/uml_conf.c | 6 ++---- src/uml/uml_driver.c | 9 +++------ src/vmware/vmware_conf.c | 9 +++------ src/vmware/vmware_driver.c | 6 ++---- src/xen/block_stats.c | 3 +-- src/xen/xen_driver.c | 6 ++---- src/xen/xen_hypervisor.c | 12 ++++-------- src/xen/xen_inotify.c | 3 +-- src/xen/xend_internal.c | 21 +++++++-------------- src/xen/xm_internal.c | 11 ++++------- src/xenapi/xenapi_driver.c | 15 +++++---------- src/xenapi/xenapi_utils.c | 15 +++++---------- src/xenconfig/xen_common.c | 12 ++++-------- src/xenconfig/xen_sxpr.c | 12 ++++-------- src/xenconfig/xen_xm.c | 3 +-- 15 files changed, 48 insertions(+), 95 deletions(-) diff --git a/src/uml/uml_conf.c b/src/uml/uml_conf.c index a99e8e9..9dcd4ae 100644 --- a/src/uml/uml_conf.c +++ b/src/uml/uml_conf.c @@ -172,9 +172,8 @@ umlBuildCommandLineNet(virConnectPtr conn, case VIR_DOMAIN_NET_TYPE_ETHERNET: /* ethNNN=tuntap,tapname,macaddr,gateway */ virBufferAddLit(&buf, "tuntap,"); - if (def->ifname) { + if (def->ifname) virBufferAdd(&buf, def->ifname, -1); - } if (def->data.ethernet.ipaddr) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("IP address not supported for ethernet interface")); @@ -215,9 +214,8 @@ umlBuildCommandLineNet(virConnectPtr conn, } bridge = virNetworkGetBridgeName(network); virNetworkFree(network); - if (bridge == NULL) { + if (bridge == NULL) goto error; - } if (umlConnectTapDevice(conn, vm, def, bridge) < 0) { VIR_FREE(bridge); diff --git a/src/uml/uml_driver.c b/src/uml/uml_driver.c index 2baf2fa..b01d631 100644 --- a/src/uml/uml_driver.c +++ b/src/uml/uml_driver.c @@ -336,9 +336,8 @@ umlInotifyEvent(int watch, dom = virDomainObjListFindByName(driver->domains, name); - if (!dom) { + if (!dom) continue; - } if (e.mask & IN_DELETE) { VIR_DEBUG("Got inotify domain shutdown '%s'", name); @@ -1335,9 +1334,8 @@ static int umlGetProcessInfo(unsigned long long *cpuTime, pid_t pid) FILE *pidinfo; unsigned long long usertime, systime; - if (virAsprintf(&proc, "/proc/%lld/stat", (long long) pid) < 0) { + if (virAsprintf(&proc, "/proc/%lld/stat", (long long) pid) < 0) return -1; - } if (!(pidinfo = fopen(proc, "r"))) { /* VM probably shut down, so fake 0 */ @@ -2306,9 +2304,8 @@ static int umlDomainDetachUmlDisk(struct uml_driver *driver, char *reply; for (i = 0; i < vm->def->ndisks; i++) { - if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) { + if (STREQ(vm->def->disks[i]->dst, dev->data.disk->dst)) break; - } } if (i == vm->def->ndisks) { diff --git a/src/vmware/vmware_conf.c b/src/vmware/vmware_conf.c index 81ac4ae..f855c1b 100644 --- a/src/vmware/vmware_conf.c +++ b/src/vmware/vmware_conf.c @@ -90,9 +90,8 @@ vmwareCapsInit(void) cpu->type = VIR_CPU_TYPE_HOST; if (!(data = cpuNodeData(cpu->arch)) - || cpuDecode(cpu, data, NULL, 0, NULL) < 0) { + || cpuDecode(cpu, data, NULL, 0, NULL) < 0) goto error; - } /* x86_64 guests are supported if * - Host arch is x86_64 @@ -163,9 +162,8 @@ vmwareLoadDomains(struct vmware_driver *driver) goto cleanup; if ((vmdef = - virVMXParseConfig(&ctx, driver->xmlopt, vmx)) == NULL) { + virVMXParseConfig(&ctx, driver->xmlopt, vmx)) == NULL) goto cleanup; - } if (!(vm = virDomainObjListAdd(driver->domains, vmdef, driver->xmlopt, @@ -432,9 +430,8 @@ vmwareVmxPath(virDomainDefPtr vmdef, char **vmxPath) goto cleanup; } - if (vmwareParsePath(src, &directoryName, &fileName) < 0) { + if (vmwareParsePath(src, &directoryName, &fileName) < 0) goto cleanup; - } if (!virFileHasSuffix(fileName, ".vmdk")) { virReportError(VIR_ERR_INTERNAL_ERROR, diff --git a/src/vmware/vmware_driver.c b/src/vmware/vmware_driver.c index c3fa2dc..5379876 100644 --- a/src/vmware/vmware_driver.c +++ b/src/vmware/vmware_driver.c @@ -313,9 +313,8 @@ vmwareStopVM(struct vmware_driver *driver, vmwareSetSentinal(cmd, vmwareDriverTypeToString(driver->type)); vmwareSetSentinal(cmd, ((vmwareDomainPtr) vm->privateData)->vmxPath); - if (virRun(cmd, NULL) < 0) { + if (virRun(cmd, NULL) < 0) return -1; - } vm->def->id = -1; virDomainObjSetState(vm, VIR_DOMAIN_SHUTOFF, reason); @@ -345,9 +344,8 @@ vmwareStartVM(struct vmware_driver *driver, virDomainObjPtr vm) else vmwareSetSentinal(cmd, NULL); - if (virRun(cmd, NULL) < 0) { + if (virRun(cmd, NULL) < 0) return -1; - } if ((vm->def->id = vmwareExtractPid(vmxPath)) < 0) { vmwareStopVM(driver, vm, VIR_DOMAIN_SHUTOFF_FAILED); diff --git a/src/xen/block_stats.c b/src/xen/block_stats.c index 58e796d..e1e10a2 100644 --- a/src/xen/block_stats.c +++ b/src/xen/block_stats.c @@ -107,9 +107,8 @@ read_bd_stat(int device, int domid, const char *str) VIR_FREE(path); - if (r >= 0) { + if (r >= 0) return r; - } } return -1; diff --git a/src/xen/xen_driver.c b/src/xen/xen_driver.c index 5f7c98f..7334142 100644 --- a/src/xen/xen_driver.c +++ b/src/xen/xen_driver.c @@ -2550,15 +2550,13 @@ xenUnifiedNodeDeviceAssignedDomainId(virNodeDevicePtr dev) /* Get active domains */ numdomains = xenUnifiedConnectNumOfDomains(conn); - if (numdomains < 0) { + if (numdomains < 0) return ret; - } if (numdomains > 0) { if (VIR_ALLOC_N(ids, numdomains) < 0) goto out; - if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0) { + if ((numdomains = xenUnifiedConnectListDomains(conn, &ids[0], numdomains)) < 0) goto out; - } } /* Get pci bdf */ diff --git a/src/xen/xen_hypervisor.c b/src/xen/xen_hypervisor.c index 4be8891..5dcaf7f 100644 --- a/src/xen/xen_hypervisor.c +++ b/src/xen/xen_hypervisor.c @@ -2258,9 +2258,8 @@ get_cpu_flags(virConnectPtr conn, const char **hvm, int *pae, int *longmode) if (STREQLEN((const char *)®s.r_ebx, "AuthcAMDenti", 12)) { if (pread(fd, ®s, sizeof(regs), 0x80000001) == sizeof(regs)) { /* Read secure virtual machine bit (bit 2 of ECX feature ID) */ - if ((regs.r_ecx >> 2) & 1) { + if ((regs.r_ecx >> 2) & 1) *hvm = "svm"; - } if ((regs.r_edx >> 6) & 1) *pae = 1; } @@ -2447,9 +2446,8 @@ xenHypervisorMakeCapabilitiesInternal(virConnectPtr conn, /* Search for existing matching (model,hvm) tuple */ for (i = 0; i < nr_guest_archs; i++) { if (guest_archs[i].arch == arch && - guest_archs[i].hvm == hvm) { + guest_archs[i].hvm == hvm) break; - } } /* Too many arch flavours - highly unlikely ! */ @@ -2571,9 +2569,8 @@ xenHypervisorDomainGetOSType(virConnectPtr conn, /* HV's earlier than 3.1.0 don't include the HVM flags in guests status*/ if (hv_versions.hypervisor < 2 || - hv_versions.dom_interface < 4) { + hv_versions.dom_interface < 4) return xenDaemonDomainGetOSType(conn, def); - } XEN_GETDOMAININFO_CLEAR(dominfo); @@ -2935,9 +2932,8 @@ xenHypervisorNodeGetCellsFreeMemory(virConnectPtr conn, else op_sys.u.availheap.node = cell; ret = xenHypervisorDoV2Sys(priv->handle, &op_sys); - if (ret < 0) { + if (ret < 0) return -1; - } if (hv_versions.sys_interface >= 5) freeMems[i] = op_sys.u.availheap5.avail_bytes; else diff --git a/src/xen/xen_inotify.c b/src/xen/xen_inotify.c index cd1e2df..a6f4116 100644 --- a/src/xen/xen_inotify.c +++ b/src/xen/xen_inotify.c @@ -417,9 +417,8 @@ xenInotifyOpen(virConnectPtr conn, VIR_DEBUG("Registering with event loop"); /* Add the handle for monitoring */ if ((priv->inotifyWatch = virEventAddHandle(priv->inotifyFD, VIR_EVENT_HANDLE_READABLE, - xenInotifyEvent, conn, NULL)) < 0) { + xenInotifyEvent, conn, NULL)) < 0) VIR_DEBUG("Failed to add inotify handle, disabling events"); - } return 0; } diff --git a/src/xen/xend_internal.c b/src/xen/xend_internal.c index f1322c4..950196c 100644 --- a/src/xen/xend_internal.c +++ b/src/xen/xend_internal.c @@ -147,14 +147,12 @@ wr_sync(int fd, void *buffer, size_t size, int do_read) } /* recoverable error, retry */ - if ((len == -1) && ((errno == EAGAIN) || (errno == EINTR))) { + if ((len == -1) && ((errno == EAGAIN) || (errno == EINTR))) continue; - } /* eof */ - if (len == 0) { + if (len == 0) break; - } /* unrecoverable error */ if (len == -1) { @@ -1759,9 +1757,8 @@ xenDaemonNodeGetTopology(virConnectPtr conn, virCapsPtr caps) struct sexpr *root; root = sexpr_get(conn, "/xend/node/"); - if (root == NULL) { + if (root == NULL) return -1; - } ret = sexpr_to_xend_topology(root, caps); sexpr_free(root); @@ -2039,9 +2036,8 @@ xenDaemonDomainGetVcpus(virConnectPtr conn, if (t->u.s.car->kind == SEXPR_VALUE && virStrToLong_i(t->u.s.car->u.value, NULL, 10, &cpu) == 0 && cpu >= 0 - && (VIR_CPU_MAPLEN(cpu+1) <= maplen)) { + && (VIR_CPU_MAPLEN(cpu+1) <= maplen)) VIR_USE_CPU(cpumap, cpu); - } break; } } @@ -2078,9 +2074,8 @@ xenDaemonLookupByUUID(virConnectPtr conn, const unsigned char *uuid) names = xenDaemonListDomainsOld(conn); tmp = names; - if (names == NULL) { + if (names == NULL) return NULL; - } while (*tmp != NULL) { id = xenDaemonDomainLookupByName_ids(conn, *tmp, &ident[0]); if (id >= 0) { @@ -2160,9 +2155,8 @@ xenDaemonCreateXML(virConnectPtr conn, virDomainDefPtr def) ret = xenDaemonDomainCreateXML(conn, sexpr); VIR_FREE(sexpr); - if (ret != 0) { + if (ret != 0) goto error; - } /* This comes before wait_for_devices, to ensure that latter cleanup will destroy the domain upon failure */ @@ -2562,9 +2556,8 @@ xenDaemonDomainGetAutostart(virConnectPtr conn, *autostart = 0; tmp = sexpr_node(root, "domain/on_xend_start"); - if (tmp && STREQ(tmp, "start")) { + if (tmp && STREQ(tmp, "start")) *autostart = 1; - } sexpr_free(root); return 0; diff --git a/src/xen/xm_internal.c b/src/xen/xm_internal.c index 30985d8..966bbf9 100644 --- a/src/xen/xm_internal.c +++ b/src/xen/xm_internal.c @@ -121,9 +121,8 @@ xenXMConfigReaper(const void *payload, if (entry->refreshedAt != args->now) { const char *olddomname = entry->def->name; char *nameowner = (char *)virHashLookup(args->priv->nameConfigMap, olddomname); - if (nameowner && STREQ(nameowner, key)) { + if (nameowner && STREQ(nameowner, key)) virHashRemoveEntry(args->priv->nameConfigMap, olddomname); - } return 1; } return 0; @@ -231,9 +230,8 @@ xenXMConfigCacheAddFile(virConnectPtr conn, const char *filename) /* If we currently own the name, then release it and re-acquire it later - just in case it was renamed */ nameowner = (char *)virHashLookup(priv->nameConfigMap, entry->def->name); - if (nameowner && STREQ(nameowner, filename)) { + if (nameowner && STREQ(nameowner, filename)) virHashRemoveEntry(priv->nameConfigMap, entry->def->name); - } /* Clear existing config entry which needs refresh */ virDomainDefFree(entry->def); @@ -372,9 +370,8 @@ xenXMConfigCacheRefresh(virConnectPtr conn) /* If we already have a matching entry and it is not modified, then carry on to next one*/ - if (xenXMConfigCacheAddFile(conn, path) < 0) { - /* Ignoring errors, since a lot of stuff goes wrong in /etc/xen */ - } + xenXMConfigCacheAddFile(conn, path); + /* Ignoring errors, since a lot of stuff goes wrong in /etc/xen */ VIR_FREE(path); } diff --git a/src/xenapi/xenapi_driver.c b/src/xenapi/xenapi_driver.c index ed4f7e8..0a228f8 100644 --- a/src/xenapi/xenapi_driver.c +++ b/src/xenapi/xenapi_driver.c @@ -136,9 +136,8 @@ xenapiConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); if (conn->uri == NULL || conn->uri->scheme == NULL || - STRCASENEQ(conn->uri->scheme, "XenAPI")) { + STRCASENEQ(conn->uri->scheme, "XenAPI")) return VIR_DRV_OPEN_DECLINED; - } if (conn->uri->server == NULL) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, @@ -1493,16 +1492,13 @@ xenapiDomainGetXMLDesc(virDomainPtr dom, unsigned int flags) } defPtr->maxvcpus = defPtr->vcpus = xenapiDomainGetMaxVcpus(dom); enum xen_on_normal_exit action; - if (xen_vm_get_actions_after_shutdown(session, &action, vm)) { + if (xen_vm_get_actions_after_shutdown(session, &action, vm)) defPtr->onPoweroff = xenapiNormalExitEnum2virDomainLifecycle(action); - } - if (xen_vm_get_actions_after_reboot(session, &action, vm)) { + if (xen_vm_get_actions_after_reboot(session, &action, vm)) defPtr->onReboot = xenapiNormalExitEnum2virDomainLifecycle(action); - } enum xen_on_crash_behaviour crash; - if (xen_vm_get_actions_after_crash(session, &crash, vm)) { + if (xen_vm_get_actions_after_crash(session, &crash, vm)) defPtr->onCrash = xenapiCrashExitEnum2virDomainLifecycle(action); - } xen_vm_get_platform(session, &result, vm); if (result != NULL) { size_t i; @@ -2060,9 +2056,8 @@ call_func(const void *data, size_t len, void *user_handle, fflush(stdout); #endif CURL *curl = curl_easy_init(); - if (!curl) { + if (!curl) return -1; - } xen_comms comms = { .func = result_func, .handle = result_handle diff --git a/src/xenapi/xenapi_utils.c b/src/xenapi/xenapi_utils.c index c71dd15..3f7f00e 100644 --- a/src/xenapi/xenapi_utils.c +++ b/src/xenapi/xenapi_utils.c @@ -67,15 +67,13 @@ xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username, memset(&cred, 0, sizeof(virConnectCredential)); if (virAsprintf(&prompt, "Enter %s password for %s", username, - hostname) < 0) { + hostname) < 0) return NULL; - } for (ncred = 0; ncred < auth->ncredtype; ncred++) { if (auth->credtype[ncred] != VIR_CRED_PASSPHRASE && - auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) { + auth->credtype[ncred] != VIR_CRED_NOECHOPROMPT) continue; - } cred.type = auth->credtype[ncred]; cred.prompt = prompt; @@ -84,9 +82,8 @@ xenapiUtil_RequestPassword(virConnectAuthPtr auth, const char *username, 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; } @@ -105,9 +102,8 @@ xenapiUtil_ParseQuery(virConnectPtr conn, virURIPtr uri, int *noVerify) for (i = 0; i < uri->paramsCount; i++) { virURIParamPtr queryParam = &uri->params[i]; if (STRCASEEQ(queryParam->name, "no_verify")) { - if (noVerify == NULL) { + if (noVerify == NULL) continue; - } if (virStrToLong_i(queryParam->value, NULL, 10, noVerify) < 0 || (*noVerify != 0 && *noVerify != 1)) { xenapiSessionErrorHandler(conn, VIR_ERR_INVALID_ARG, @@ -282,9 +278,8 @@ mapDomainPinVcpu(unsigned char *cpumap, int maplen) size_t i, j; for (i = 0; i < maplen; i++) { for (j = 0; j < 8; j++) { - if (cpumap[i] & (1 << j)) { + if (cpumap[i] & (1 << j)) virBufferAsprintf(&buf, "%zu,", (8*i)+j); - } } } if (virBufferCheckError(&buf) < 0) diff --git a/src/xenconfig/xen_common.c b/src/xenconfig/xen_common.c index 32954f3..113b32f 100644 --- a/src/xenconfig/xen_common.c +++ b/src/xenconfig/xen_common.c @@ -593,9 +593,8 @@ xenParseVfb(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) goto cleanup; if (listenAddr && virDomainGraphicsListenSetAddress(graphics, 0, listenAddr, - -1, true) < 0) { + -1, true) < 0) goto cleanup; - } VIR_FREE(listenAddr); if (xenConfigCopyStringOpt(conf, "vncpasswd", &graphics->data.vnc.auth.passwd) < 0) @@ -729,9 +728,8 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def) !(chr = xenParseSxprChar(str, NULL))) goto cleanup; if (chr) { - if (VIR_ALLOC_N(def->parallels, 1) < 0) { + if (VIR_ALLOC_N(def->parallels, 1) < 0) goto cleanup; - } chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL; chr->target.port = 0; @@ -762,9 +760,8 @@ xenParseCharDev(virConfPtr conf, virDomainDefPtr def) goto cleanup; chr->deviceType = VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL; chr->target.port = portnum; - if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0) { + if (VIR_APPEND_ELEMENT(def->serials, def->nserials, chr) < 0) goto cleanup; - } value = value->next; } @@ -1632,9 +1629,8 @@ xenFormatCPUAllocation(virConfPtr conf, virDomainDefPtr def) goto cleanup; if ((def->cpumask != NULL) && - ((cpus = virBitmapFormat(def->cpumask)) == NULL)) { + ((cpus = virBitmapFormat(def->cpumask)) == NULL)) goto cleanup; - } if (cpus && xenXMConfigSetString(conf, "cpus", cpus) < 0) diff --git a/src/xenconfig/xen_sxpr.c b/src/xenconfig/xen_sxpr.c index 6623ea8..e8a22f9 100644 --- a/src/xenconfig/xen_sxpr.c +++ b/src/xenconfig/xen_sxpr.c @@ -130,15 +130,13 @@ xenParseSxprOS(const struct sexpr *node, /* If HVM kenrel == loader, then old xend, so kill off kernel */ if (hvm && def->os.kernel && - STREQ(def->os.kernel, def->os.loader->path)) { + STREQ(def->os.kernel, def->os.loader->path)) VIR_FREE(def->os.kernel); - } /* Drop kernel argument that has no value */ if (hvm && def->os.kernel && *def->os.kernel == '\0' && - def->os.loader) { + def->os.loader) VIR_FREE(def->os.kernel); - } if (!def->os.kernel && hvm) { @@ -1959,16 +1957,14 @@ xenFormatSxprNet(virConnectPtr conn, if (def->model != NULL && STREQ(def->model, "netfront")) { virBufferAddLit(buf, "(type netfront)"); } else { - if (def->model != NULL) { + if (def->model != NULL) virBufferEscapeSexpr(buf, "(model '%s')", def->model); - } /* * apparently (type ioemu) breaks paravirt drivers on HVM so skip * this from XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU */ - if (xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU) { + if (xendConfigVersion <= XEND_CONFIG_MAX_VERS_NET_TYPE_IOEMU) virBufferAddLit(buf, "(type ioemu)"); - } } } diff --git a/src/xenconfig/xen_xm.c b/src/xenconfig/xen_xm.c index 1e57e24..8d35f62 100644 --- a/src/xenconfig/xen_xm.c +++ b/src/xenconfig/xen_xm.c @@ -337,9 +337,8 @@ xenFormatXMDisks(virConfPtr conf, virDomainDefPtr def, int xendConfigVersion) if (xendConfigVersion == XEND_CONFIG_VERSION_3_0_2 && def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_CDROM && def->disks[i]->dst && - STREQ(def->disks[i]->dst, "hdc")) { + STREQ(def->disks[i]->dst, "hdc")) continue; - } if (def->disks[i]->device == VIR_DOMAIN_DISK_DEVICE_FLOPPY) continue; -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/security/security_dac.c | 9 ++--- src/security/security_manager.c | 3 +- src/security/security_selinux.c | 6 ++-- src/security/virt-aa-helper.c | 15 +++------ src/storage/parthelper.c | 3 +- src/storage/storage_backend.c | 9 ++--- src/storage/storage_backend_disk.c | 21 ++++-------- src/storage/storage_backend_fs.c | 9 ++--- src/storage/storage_backend_mpath.c | 30 ++++++----------- src/storage/storage_backend_rbd.c | 30 ++++++----------- src/storage/storage_backend_scsi.c | 9 ++--- src/storage/storage_driver.c | 9 ++--- src/test/test_driver.c | 66 +++++++++++++------------------------ 13 files changed, 73 insertions(+), 146 deletions(-) diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 85253af..208f6e2 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -774,13 +774,11 @@ virSecurityDACSetChardevLabel(virSecurityManagerPtr mgr, goto done; if (virFileExists(in) && virFileExists(out)) { if ((virSecurityDACSetOwnership(in, user, group) < 0) || - (virSecurityDACSetOwnership(out, user, group) < 0)) { + (virSecurityDACSetOwnership(out, user, group) < 0)) goto done; - } } else if (virSecurityDACSetOwnership(dev_source->data.file.path, - user, group) < 0) { + user, group) < 0) goto done; - } ret = 0; break; @@ -834,9 +832,8 @@ virSecurityDACRestoreChardevLabel(virSecurityManagerPtr mgr ATTRIBUTE_UNUSED, goto done; if (virFileExists(in) && virFileExists(out)) { if ((virSecurityDACRestoreSecurityFileLabel(out) < 0) || - (virSecurityDACRestoreSecurityFileLabel(in) < 0)) { + (virSecurityDACRestoreSecurityFileLabel(in) < 0)) goto done; - } } else if (virSecurityDACRestoreSecurityFileLabel(dev_source->data.file.path) < 0) { goto done; } diff --git a/src/security/security_manager.c b/src/security/security_manager.c index 8671620..302f54d 100644 --- a/src/security/security_manager.c +++ b/src/security/security_manager.c @@ -875,9 +875,8 @@ virSecurityManagerGetNested(virSecurityManagerPtr mgr) { virSecurityManagerPtr* list = NULL; - if (STREQ("stack", mgr->drv->name)) { + if (STREQ("stack", mgr->drv->name)) return virSecurityStackGetNested(mgr); - } if (VIR_ALLOC_N(list, 2) < 0) return NULL; diff --git a/src/security/security_selinux.c b/src/security/security_selinux.c index f96be50..d140fb8 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -1719,9 +1719,8 @@ virSecuritySELinuxSetSecurityChardevLabel(virDomainDefPtr def, goto done; if (virFileExists(in) && virFileExists(out)) { if ((virSecuritySELinuxSetFilecon(in, imagelabel) < 0) || - (virSecuritySELinuxSetFilecon(out, imagelabel) < 0)) { + (virSecuritySELinuxSetFilecon(out, imagelabel) < 0)) goto done; - } } else if (virSecuritySELinuxSetFilecon(dev_source->data.file.path, imagelabel) < 0) { goto done; @@ -1784,9 +1783,8 @@ virSecuritySELinuxRestoreSecurityChardevLabel(virSecurityManagerPtr mgr, goto done; if (virFileExists(in) && virFileExists(out)) { if ((virSecuritySELinuxRestoreSecurityFileLabel(mgr, out) < 0) || - (virSecuritySELinuxRestoreSecurityFileLabel(mgr, in) < 0)) { + (virSecuritySELinuxRestoreSecurityFileLabel(mgr, in) < 0)) goto done; - } } else if (virSecuritySELinuxRestoreSecurityFileLabel(mgr, dev_source->data.file.path) < 0) { goto done; } diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 1f299a0..6fc7474 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -667,9 +667,8 @@ caps_mockup(vahControl * ctl, const char *xmlStr) char *arch; if (!(xml = virXMLParseStringCtxt(xmlStr, _("(domain_definition)"), - &ctxt))) { + &ctxt))) goto cleanup; - } if (!xmlStrEqual(ctxt->node->name, BAD_CAST "domain")) { vah_error(NULL, 0, _("unexpected root element, expecting <domain>")); @@ -1061,9 +1060,8 @@ get_files(vahControl * ctl) virDomainHostdevSubsysPCIBackendType backend = dev->source.subsys.u.pci.backend; if (backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO || - backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { + backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) needsVfio = true; - } if (pci == NULL) continue; @@ -1253,13 +1251,11 @@ main(int argc, char **argv) /* clear the environment */ environ = NULL; - if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0) { + if (setenv("PATH", "/sbin:/usr/sbin", 1) != 0) vah_error(ctl, 1, _("could not set PATH")); - } - if (setenv("IFS", " \t\n", 1) != 0) { + if (setenv("IFS", " \n\t", 1) != 0) vah_error(ctl, 1, _("could not set IFS")); - } if (!(progname = strrchr(argv[0], '/'))) progname = argv[0]; @@ -1290,9 +1286,8 @@ main(int argc, char **argv) } else if (ctl->cmd == 'c' || ctl->cmd == 'r') { char *included_files = NULL; - if (ctl->cmd == 'c' && virFileExists(profile)) { + if (ctl->cmd == 'c' && virFileExists(profile)) vah_error(ctl, 1, _("profile exists")); - } if (ctl->append && ctl->newfile) { if (vah_add_file(&buf, ctl->newfile, "rw") != 0) diff --git a/src/storage/parthelper.c b/src/storage/parthelper.c index 84e7ba0..8de32fd 100644 --- a/src/storage/parthelper.c +++ b/src/storage/parthelper.c @@ -91,9 +91,8 @@ int main(int argc, char **argv) if (VIR_STRDUP_QUIET(canonical_path, path) < 0) return 2; } else { - if (virFileResolveLink(path, &canonical_path) != 0) { + if (virFileResolveLink(path, &canonical_path) != 0) return 2; - } partsep = *canonical_path && c_isdigit(canonical_path[strlen(canonical_path)-1]) ? "p" : ""; diff --git a/src/storage/storage_backend.c b/src/storage/storage_backend.c index 00cfe74..98720f6 100644 --- a/src/storage/storage_backend.c +++ b/src/storage/storage_backend.c @@ -182,9 +182,8 @@ virStorageBackendCopyToFD(virStorageVolDefPtr vol, } #ifdef __linux__ - if (ioctl(fd, BLKBSZGET, &wbytes) < 0) { + if (ioctl(fd, BLKBSZGET, &wbytes) < 0) wbytes = 0; - } #endif if ((wbytes == 0) && fstat(fd, &st) == 0) wbytes = st.st_blksize; @@ -395,9 +394,8 @@ createRawFile(int fd, virStorageVolDefPtr vol, (vol->target.allocation < inputvol->target.capacity); ret = virStorageBackendCopyToFD(vol, inputvol, fd, &remain, want_sparse); - if (ret < 0) { + if (ret < 0) goto cleanup; - } } if (remain && need_alloc) { @@ -631,9 +629,8 @@ virStorageBackendCreateExecCommand(virStoragePoolObjPtr pool, virCommandSetGID(cmd, -1); if (!filecreated) { - if (virCommandRun(cmd, NULL) < 0) { + if (virCommandRun(cmd, NULL) < 0) return -1; - } if (stat(vol->target.path, &st) < 0) { virReportSystemError(errno, _("failed to create %s"), vol->target.path); diff --git a/src/storage/storage_backend_disk.c b/src/storage/storage_backend_disk.c index abab1e1..0546b10 100644 --- a/src/storage/storage_backend_disk.c +++ b/src/storage/storage_backend_disk.c @@ -171,9 +171,8 @@ virStorageBackendDiskMakeFreeExtent(virStoragePoolObjPtr pool, return -1; /* Don't bother to re-alloc freeExtents - it'll be free'd shortly */ /* first block reported as free, even if it is not */ - if (dev->freeExtents[dev->nfreeExtent].start == 0) { + if (dev->freeExtents[dev->nfreeExtent].start == 0) dev->freeExtents[dev->nfreeExtent].start = SECTOR_SIZE; - } pool->def->available += (dev->freeExtents[dev->nfreeExtent].end - @@ -349,9 +348,8 @@ virStorageBackendDiskRefreshPool(virConnectPtr conn ATTRIBUTE_UNUSED, return -1; } - if (virStorageBackendDiskReadGeometry(pool) != 0) { + if (virStorageBackendDiskReadGeometry(pool) != 0) return -1; - } return virStorageBackendDiskReadPartitions(pool, NULL); } @@ -467,9 +465,8 @@ virStorageBackendDiskPartTypeToCreate(virStoragePoolObjPtr pool) partType == VIR_STORAGE_VOL_DISK_TYPE_EXTENDED) count++; } - if (count >= 4) { + if (count >= 4) return VIR_STORAGE_VOL_DISK_TYPE_LOGICAL; - } } /* for all other cases, all partitions are primary */ @@ -587,9 +584,8 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool, } /* if we are creating a logical partition, we need one extra block between partitions (or actually move start one block) */ - if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) { + if (partType == VIR_STORAGE_VOL_DISK_TYPE_LOGICAL) size -= SECTOR_SIZE; - } } if (size > neededSize && (smallestSize == 0 || @@ -602,9 +598,8 @@ virStorageBackendDiskPartBoundaries(virStoragePoolObjPtr pool, /* for primary partition, the free extent must not be within a logical free area */ } else if (partType == VIR_STORAGE_VOL_DISK_TYPE_PRIMARY && - dev->freeExtents[i].type != VIR_STORAGE_FREE_NORMAL) { + dev->freeExtents[i].type != VIR_STORAGE_FREE_NORMAL) continue; - } smallestSize = size; smallestExtent = i; alignedAllocation = neededSize; @@ -659,16 +654,14 @@ virStorageBackendDiskCreateVol(virConnectPtr conn ATTRIBUTE_UNUSED, goto cleanup; } - if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0) { + if (virStorageBackendDiskPartFormat(pool, vol, &partFormat) != 0) goto cleanup; - } virCommandAddArg(cmd, partFormat); if (virStorageBackendDiskPartBoundaries(pool, &startOffset, &endOffset, - vol->target.capacity) != 0) { + vol->target.capacity) != 0) goto cleanup; - } virCommandAddArgFormat(cmd, "%lluB", startOffset); virCommandAddArgFormat(cmd, "%lluB", endOffset); diff --git a/src/storage/storage_backend_fs.c b/src/storage/storage_backend_fs.c index 0f8ceee..71c941b 100644 --- a/src/storage/storage_backend_fs.c +++ b/src/storage/storage_backend_fs.c @@ -639,9 +639,8 @@ virStorageBackendFileSystemProbe(const char *device, error: VIR_FREE(libblkid_format); - if (probe != NULL) { + if (probe != NULL) blkid_free_probe(probe); - } return ret; } @@ -733,13 +732,11 @@ virStorageBackendMakeFileSystem(virStoragePoolObjPtr pool, ok_to_mkfs = true; } else if (flags & VIR_STORAGE_POOL_BUILD_NO_OVERWRITE && virStorageBackendFileSystemProbe(device, format) == - FILESYSTEM_PROBE_NOT_FOUND) { + FILESYSTEM_PROBE_NOT_FOUND) ok_to_mkfs = true; - } - if (ok_to_mkfs) { + if (ok_to_mkfs) ret = virStorageBackendExecuteMKFS(device, format); - } error: return ret; diff --git a/src/storage/storage_backend_mpath.c b/src/storage/storage_backend_mpath.c index f21ae4c..828ebd4 100644 --- a/src/storage/storage_backend_mpath.c +++ b/src/storage/storage_backend_mpath.c @@ -61,9 +61,8 @@ virStorageBackendMpathNewVol(virStoragePoolObjPtr pool, goto cleanup; if (virStorageBackendUpdateVolInfo(vol, true, true, - VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) { + VIR_STORAGE_VOL_OPEN_DEFAULT) < 0) goto cleanup; - } /* XXX should use logical unit's UUID instead */ if (VIR_STRDUP(vol->key, vol->target.path) < 0) @@ -119,14 +118,12 @@ virStorageBackendIsMultipath(const char *dev_name) goto out; } - if (STREQ(target_type, "multipath")) { + if (STREQ(target_type, "multipath")) ret = 1; - } out: - if (dmt != NULL) { + if (dmt != NULL) dm_task_destroy(dmt); - } return ret; } @@ -138,21 +135,17 @@ virStorageBackendGetMinorNumber(const char *dev_name, uint32_t *minor) struct dm_task *dmt; struct dm_info info; - if (!(dmt = dm_task_create(DM_DEVICE_INFO))) { + if (!(dmt = dm_task_create(DM_DEVICE_INFO))) goto out; - } - if (!dm_task_set_name(dmt, dev_name)) { + if (!dm_task_set_name(dmt, dev_name)) goto out; - } - if (!dm_task_run(dmt)) { + if (!dm_task_run(dmt)) goto out; - } - if (!dm_task_get_info(dmt, &info)) { + if (!dm_task_get_info(dmt, &info)) goto out; - } *minor = info.minor; ret = 0; @@ -177,9 +170,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool, do { is_mpath = virStorageBackendIsMultipath(names->name); - if (is_mpath < 0) { + if (is_mpath < 0) goto out; - } if (is_mpath == 1) { @@ -193,9 +185,8 @@ virStorageBackendCreateVols(virStoragePoolObjPtr pool, goto out; } - if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0) { + if (virStorageBackendMpathNewVol(pool, minor, map_device) < 0) goto out; - } VIR_FREE(map_device); } @@ -247,9 +238,8 @@ virStorageBackendGetMaps(virStoragePoolObjPtr pool) virStorageBackendCreateVols(pool, names); out: - if (dmt != NULL) { + if (dmt != NULL) dm_task_destroy(dmt); - } return retval; } diff --git a/src/storage/storage_backend_rbd.c b/src/storage/storage_backend_rbd.c index bddbc1d..5a16eff 100644 --- a/src/storage/storage_backend_rbd.c +++ b/src/storage/storage_backend_rbd.c @@ -330,13 +330,11 @@ static int virStorageBackendRBDRefreshPool(virConnectPtr conn, ptr.cluster = NULL; ptr.ioctx = NULL; - if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) { + if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) goto cleanup; - } - if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) { + if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) goto cleanup; - } struct rados_cluster_stat_t clusterstat; r = rados_cluster_stat(ptr.cluster, &clusterstat); @@ -428,17 +426,14 @@ static int virStorageBackendRBDDeleteVol(virConnectPtr conn, VIR_DEBUG("Removing RBD image %s/%s", pool->def->source.name, vol->name); - if (flags & VIR_STORAGE_VOL_DELETE_ZEROED) { + if (flags & VIR_STORAGE_VOL_DELETE_ZEROED) VIR_WARN("%s", _("This storage backend does not supported zeroed removal of volumes")); - } - if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) { + if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) goto cleanup; - } - if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) { + if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) goto cleanup; - } r = rbd_remove(ptr.ioctx, vol->name); if (r < 0) { @@ -555,17 +550,14 @@ static int virStorageBackendRBDRefreshVol(virConnectPtr conn, ptr.ioctx = NULL; int ret = -1; - if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) { + if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) goto cleanup; - } - if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) { + if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) goto cleanup; - } - if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) { + if (volStorageBackendRBDRefreshVolInfo(vol, pool, &ptr) < 0) goto cleanup; - } ret = 0; @@ -589,13 +581,11 @@ static int virStorageBackendRBDResizeVol(virConnectPtr conn ATTRIBUTE_UNUSED, virCheckFlags(0, -1); - if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) { + if (virStorageBackendRBDOpenRADOSConn(&ptr, conn, &pool->def->source) < 0) goto cleanup; - } - if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) { + if (virStorageBackendRBDOpenIoCTX(&ptr, pool) < 0) goto cleanup; - } r = rbd_open(ptr.ioctx, vol->name, &image, NULL); if (r < 0) { diff --git a/src/storage/storage_backend_scsi.c b/src/storage/storage_backend_scsi.c index 02160bc..fb4288b 100644 --- a/src/storage/storage_backend_scsi.c +++ b/src/storage/storage_backend_scsi.c @@ -255,9 +255,8 @@ getNewStyleBlockDevice(const char *lun_path, while ((direrr = virDirRead(block_dir, &block_dirent, block_path)) > 0) { - if (STREQLEN(block_dirent->d_name, ".", 1)) { + if (STREQLEN(block_dirent->d_name, ".", 1)) continue; - } if (VIR_STRDUP(*block_device, block_dirent->d_name) < 0) { closedir(block_dir); @@ -396,9 +395,8 @@ processLU(virStoragePoolObjPtr pool, VIR_DEBUG("%u:%u:%u:%u is a Direct-Access LUN", host, bus, target, lun); - if (getBlockDevice(host, bus, target, lun, &block_device) < 0) { + if (getBlockDevice(host, bus, target, lun, &block_device) < 0) goto out; - } if (virStorageBackendSCSINewLun(pool, host, bus, target, lun, @@ -448,9 +446,8 @@ virStorageBackendSCSIFindLUs(virStoragePoolObjPtr pool, while ((retval = virDirRead(devicedir, &lun_dirent, device_path)) > 0) { if (sscanf(lun_dirent->d_name, devicepattern, - &bus, &target, &lun) != 3) { + &bus, &target, &lun) != 3) continue; - } found = true; VIR_DEBUG("Found LU '%s'", lun_dirent->d_name); diff --git a/src/storage/storage_driver.c b/src/storage/storage_driver.c index 7c518bf..dbd9141 100644 --- a/src/storage/storage_driver.c +++ b/src/storage/storage_driver.c @@ -493,9 +493,8 @@ storageConnectListDefinedStoragePools(virConnectPtr conn, cleanup: storageDriverUnlock(driver); - for (i = 0; i < got; i++) { + for (i = 0; i < got; i++) VIR_FREE(names[i]); - } memset(names, 0, nnames * sizeof(*names)); return -1; } @@ -1670,9 +1669,8 @@ storageVolCreateXML(virStoragePoolPtr obj, /* Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ VIR_FREE(voldef->key); - if (backend->createVol(obj->conn, pool, voldef) < 0) { + if (backend->createVol(obj->conn, pool, voldef) < 0) goto cleanup; - } pool->volumes.objs[pool->volumes.count++] = voldef; volobj = virGetStorageVol(obj->conn, pool->def->name, voldef->name, @@ -1851,9 +1849,8 @@ storageVolCreateXMLFrom(virStoragePoolPtr obj, * Wipe any key the user may have suggested, as volume creation * will generate the canonical key. */ VIR_FREE(newvol->key); - if (backend->createVol(obj->conn, pool, newvol) < 0) { + if (backend->createVol(obj->conn, pool, newvol) < 0) goto cleanup; - } pool->volumes.objs[pool->volumes.count++] = newvol; volobj = virGetStorageVol(obj->conn, pool->def->name, newvol->name, diff --git a/src/test/test_driver.c b/src/test/test_driver.c index 2afd6fe..a185dea 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -672,9 +672,8 @@ testDomainStartState(testConnPtr privconn, if (virDomainObjSetDefTransient(privconn->caps, privconn->xmlopt, - dom, false) < 0) { + dom, false) < 0) goto cleanup; - } dom->hasManagedSave = false; ret = 0; @@ -960,9 +959,8 @@ testParseNodeInfo(virNodeInfoPtr nodeInfo, xmlXPathContextPtr ctxt) nodeInfo->sockets * nodeInfo->nodes); ret = virXPathLong("string(/node/cpu/active[1])", ctxt, &l); if (ret == 0) { - if (l < nodeInfo->cpus) { + if (l < nodeInfo->cpus) nodeInfo->cpus = l; - } } else if (ret == -2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("invalid node cpu active value")); @@ -1070,9 +1068,8 @@ testParseDomains(testConnPtr privconn, virDomainObjPtr obj; num = virXPathNodeSet("/node/domain", ctxt, &nodes); - if (num < 0) { + if (num < 0) goto error; - } for (i = 0; i < num; i++) { virDomainDefPtr def; @@ -1137,9 +1134,8 @@ testParseNetworks(testConnPtr privconn, virNetworkObjPtr obj; num = virXPathNodeSet("/node/network", ctxt, &nodes); - if (num < 0) { + if (num < 0) goto error; - } for (i = 0; i < num; i++) { virNetworkDefPtr def; @@ -1177,9 +1173,8 @@ testParseInterfaces(testConnPtr privconn, virInterfaceObjPtr obj; num = virXPathNodeSet("/node/interface", ctxt, &nodes); - if (num < 0) { + if (num < 0) goto error; - } for (i = 0; i < num; i++) { virInterfaceDefPtr def; @@ -1225,9 +1220,8 @@ testOpenVolumesForPool(const char *file, num = virXPathNodeSet(vol_xpath, ctxt, &nodes); VIR_FREE(vol_xpath); - if (num < 0) { + if (num < 0) goto error; - } for (i = 0; i < num; i++) { xmlNodePtr node = testParseXMLDocFromFile(nodes[i], file, @@ -1275,9 +1269,8 @@ testParseStorage(testConnPtr privconn, virStoragePoolObjPtr obj; num = virXPathNodeSet("/node/pool", ctxt, &nodes); - if (num < 0) { + if (num < 0) goto error; - } for (i = 0; i < num; i++) { virStoragePoolDefPtr def; @@ -1328,9 +1321,8 @@ testParseNodedevs(testConnPtr privconn, virNodeDeviceObjPtr obj; num = virXPathNodeSet("/node/device", ctxt, &nodes); - if (num < 0) { + if (num < 0) goto error; - } for (i = 0; i < num; i++) { virNodeDeviceDefPtr def; @@ -1430,9 +1422,8 @@ testOpenFromFile(virConnectPtr conn, const char *file) if (!(privconn->eventState = virObjectEventStateNew())) goto error; - if (!(doc = virXMLParseFileCtxt(file, &ctxt))) { + if (!(doc = virXMLParseFileCtxt(file, &ctxt))) goto error; - } if (!xmlStrEqual(ctxt->node->name, BAD_CAST "node")) { virReportError(VIR_ERR_XML_ERROR, "%s", @@ -2713,9 +2704,8 @@ testDomainSetVcpusFlags(virDomainPtr domain, unsigned int nrCpus, case VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_AFFECT_CONFIG: ret = testDomainUpdateVCPUs(privconn, privdom, nrCpus, 0); - if (ret == 0) { + if (ret == 0) persistentDef->vcpus = nrCpus; - } break; } @@ -2806,9 +2796,8 @@ static int testDomainGetVcpus(virDomainPtr domain, unsigned char *cpumap = VIR_GET_CPUMAP(cpumaps, maplen, v); for (i = 0; i < maxcpu; i++) { - if (VIR_CPU_USABLE(privdomdata->cpumaps, privmaplen, v, i)) { + if (VIR_CPU_USABLE(privdomdata->cpumaps, privmaplen, v, i)) VIR_USE_CPU(cpumap, i); - } } } } @@ -2866,9 +2855,8 @@ static int testDomainPinVcpu(virDomainPtr domain, memset(privcpumap, 0, privmaplen); for (i = 0; i < maxcpu; i++) { - if (VIR_CPU_USABLE(cpumap, maplen, 0, i)) { + if (VIR_CPU_USABLE(cpumap, maplen, 0, i)) VIR_USE_CPU(privcpumap, i); - } } ret = 0; @@ -3070,9 +3058,8 @@ static int testNodeGetCellsFreeMemory(virConnectPtr conn, for (cell = startCell, i = 0; (cell < privconn->numCells && i < maxCells); - ++cell, ++i) { + ++cell, ++i) freemems[i] = privconn->cells[cell].mem; - } ret = i; cleanup: @@ -4068,9 +4055,8 @@ static int testConnectNumOfInterfaces(virConnectPtr conn) testDriverLock(privconn); for (i = 0; (i < privconn->ifaces.count); i++) { virInterfaceObjLock(privconn->ifaces.objs[i]); - if (virInterfaceObjIsActive(privconn->ifaces.objs[i])) { + if (virInterfaceObjIsActive(privconn->ifaces.objs[i])) count++; - } virInterfaceObjUnlock(privconn->ifaces.objs[i]); } testDriverUnlock(privconn); @@ -4115,9 +4101,8 @@ static int testConnectNumOfDefinedInterfaces(virConnectPtr conn) testDriverLock(privconn); for (i = 0; i < privconn->ifaces.count; i++) { virInterfaceObjLock(privconn->ifaces.objs[i]); - if (!virInterfaceObjIsActive(privconn->ifaces.objs[i])) { + if (!virInterfaceObjIsActive(privconn->ifaces.objs[i])) count++; - } virInterfaceObjUnlock(privconn->ifaces.objs[i]); } testDriverUnlock(privconn); @@ -6066,21 +6051,18 @@ testNodeDeviceCreateXML(virConnectPtr conn, testDriverLock(driver); def = virNodeDeviceDefParseString(xmlDesc, CREATE_DEVICE, NULL); - if (def == NULL) { + if (def == NULL) goto cleanup; - } /* We run these next two simply for validation */ - if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) { + if (virNodeDeviceGetWWNs(def, &wwnn, &wwpn) == -1) goto cleanup; - } if (virNodeDeviceGetParentHost(&driver->devs, def->name, def->parent, - &parent_host) == -1) { + &parent_host) == -1) goto cleanup; - } /* 'name' is supposed to be filled in by the node device backend, which * we don't have. Use WWPN instead. */ @@ -6101,9 +6083,8 @@ testNodeDeviceCreateXML(virConnectPtr conn, } - if (!(obj = virNodeDeviceAssignDef(&driver->devs, def))) { + if (!(obj = virNodeDeviceAssignDef(&driver->devs, def))) goto cleanup; - } virNodeDeviceObjUnlock(obj); dev = virGetNodeDevice(conn, def->name); @@ -6134,9 +6115,8 @@ testNodeDeviceDestroy(virNodeDevicePtr dev) goto out; } - if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) { + if (virNodeDeviceGetWWNs(obj->def, &wwnn, &wwpn) == -1) goto out; - } if (VIR_STRDUP(parent_name, obj->def->parent) < 0) goto out; @@ -7045,9 +7025,8 @@ testDomainSnapshotReparentChildren(void *payload, virDomainSnapshotObjPtr snap = payload; testSnapReparentDataPtr rep = data; - if (rep->err < 0) { + if (rep->err < 0) return; - } VIR_FREE(snap->def->parent); snap->parent = rep->parent; @@ -7089,9 +7068,8 @@ testDomainSnapshotDelete(virDomainSnapshotPtr snapshot, testDomainSnapshotDiscardAll, &rem); if (rem.current) { - if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) { + if (flags & VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN_ONLY) snap->def->current = true; - } vm->current_snapshot = snap; } } else if (snap->nchildren) { -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/network/bridge_driver.c | 53 ++++++++++--------------------- src/network/bridge_driver_linux.c | 9 ++---- src/network/leaseshelper.c | 3 +- src/nodeinfo.c | 3 +- src/nwfilter/nwfilter_dhcpsnoop.c | 6 ++-- src/nwfilter/nwfilter_ebiptables_driver.c | 12 +++---- src/nwfilter/nwfilter_gentech_driver.c | 12 +++---- src/nwfilter/nwfilter_learnipaddr.c | 3 +- src/openvz/openvz_conf.c | 3 +- src/openvz/openvz_driver.c | 33 +++++++------------ src/parallels/parallels_driver.c | 6 ++-- src/phyp/phyp_driver.c | 21 ++++-------- src/remote/remote_driver.c | 33 +++++++------------ src/rpc/virnetclient.c | 9 ++---- src/rpc/virnetserver.c | 3 +- src/rpc/virnetserverclient.c | 3 +- src/rpc/virnetserverservice.c | 3 +- 17 files changed, 72 insertions(+), 143 deletions(-) diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c index 11e86e0..e84c2c0 100644 --- a/src/network/bridge_driver.c +++ b/src/network/bridge_driver.c @@ -276,9 +276,8 @@ networkRemoveInactive(virNetworkDriverStatePtr driver, /* remove the (possibly) existing dnsmasq and radvd files */ if (!(dctx = dnsmasqContextNew(def->name, - driverState->dnsmasqStateDir))) { + driverState->dnsmasqStateDir))) goto cleanup; - } if (!(leasefile = networkDnsmasqLeaseFileName(def->name))) goto cleanup; @@ -443,11 +442,8 @@ networkAutostartConfigs(virNetworkDriverStatePtr driver) for (i = 0; i < driver->networks.count; i++) { virNetworkObjLock(driver->networks.objs[i]); if (driver->networks.objs[i]->autostart && - !virNetworkObjIsActive(driver->networks.objs[i])) { - if (networkStartNetwork(driver, driver->networks.objs[i]) < 0) { - /* failed to start but already logged */ - } - } + !virNetworkObjIsActive(driver->networks.objs[i])) + networkStartNetwork(driver, driver->networks.objs[i]); virNetworkObjUnlock(driver->networks.objs[i]); } } @@ -615,9 +611,8 @@ networkStateInitialize(bool privileged, (virAsprintf(&driverState->dnsmasqStateDir, "%s/dnsmasq/lib", rundir) < 0) || (virAsprintf(&driverState->radvdStateDir, - "%s/radvd/lib", rundir) < 0)) { + "%s/radvd/lib", rundir) < 0)) goto error; - } } if (virFileMakePath(driverState->stateDir) < 0) { @@ -1350,9 +1345,8 @@ networkStartDhcpDaemon(virNetworkDriverStatePtr driver, goto cleanup; ret = virCommandRun(cmd, NULL); - if (ret < 0) { + if (ret < 0) goto cleanup; - } /* * There really is no race here - when dnsmasq daemonizes, its @@ -1401,9 +1395,8 @@ networkRefreshDhcpDaemon(virNetworkDriverStatePtr driver, VIR_INFO("Refreshing dnsmasq for network %s", network->def->bridge); if (!(dctx = dnsmasqContextNew(network->def->name, - driverState->dnsmasqStateDir))) { + driverState->dnsmasqStateDir))) goto cleanup; - } /* Look for first IPv4 address that has dhcp defined. * We only support dhcp-host config on one IPv4 subnetwork @@ -1788,9 +1781,7 @@ networkReloadFirewallRules(virNetworkDriverStatePtr driver) * need to have iptables rules reloaded. */ networkRemoveFirewallRules(network->def); - if (networkAddFirewallRules(network->def) < 0) { - /* failed to add but already logged */ - } + networkAddFirewallRules(network->def); } virNetworkObjUnlock(network); } @@ -1952,9 +1943,8 @@ networkAddRouteToBridge(virNetworkObjPtr network, metric = 1; if (virNetDevAddRoute(network->def->bridge, &routedef->address, - prefix, &routedef->gateway, metric) < 0) { + prefix, &routedef->gateway, metric) < 0) return -1; - } return 0; } @@ -2032,9 +2022,8 @@ networkStartNetworkVirtual(virNetworkDriverStatePtr driver, v6present = true; /* Add the IP address/netmask to the bridge */ - if (networkAddAddrToBridge(network, ipdef) < 0) { + if (networkAddAddrToBridge(network, ipdef) < 0) goto err2; - } } /* Bring up the bridge interface */ @@ -2852,9 +2841,8 @@ networkValidate(virNetworkDriverStatePtr driver, if (def->portGroups[i].virtPortProfile) { if (def->forward.type != VIR_NETWORK_FORWARD_BRIDGE || def->portGroups[i].virtPortProfile->virtPortType - != VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) { + != VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH) badVlanUse = true; - } } else if (!vlanAllowed) { /* virtualport taken from base network definition */ badVlanUse = true; @@ -3156,9 +3144,8 @@ networkUpdate(virNetworkPtr net, if (flags & VIR_NETWORK_UPDATE_AFFECT_CONFIG) { /* save updated persistent config to disk */ if (virNetworkSaveConfig(driver->networkConfigDir, - virNetworkObjGetPersistentDef(network)) < 0) { + virNetworkObjGetPersistentDef(network)) < 0) goto cleanup; - } } if (isActive && (flags & VIR_NETWORK_UPDATE_AFFECT_LIVE)) { @@ -3196,9 +3183,8 @@ networkUpdate(virNetworkPtr net, if ((newDhcpActive != oldDhcpActive && networkRestartDhcpDaemon(driver, network) < 0) || - networkRefreshDhcpDaemon(driver, network) < 0) { + networkRefreshDhcpDaemon(driver, network) < 0) goto cleanup; - } } else if (section == VIR_NETWORK_SECTION_DNS_HOST || section == VIR_NETWORK_SECTION_DNS_TXT || @@ -3222,9 +3208,8 @@ networkUpdate(virNetworkPtr net, /* save current network state to disk */ if ((ret = virNetworkSaveStatus(driverState->stateDir, - network)) < 0) { + network)) < 0) goto cleanup; - } } ret = 0; cleanup: @@ -3836,9 +3821,8 @@ networkAllocateActualDevice(virDomainDefPtr dom, iface->virtPortProfile, netdef->virtPortProfile, portgroup - ? portgroup->virtPortProfile : NULL) < 0) { + ? portgroup->virtPortProfile : NULL) < 0) goto error; - } virtport = iface->data.network.actual->virtPortProfile; if (virtport) { /* only type='openvswitch' is allowed for bridges */ @@ -3909,9 +3893,8 @@ networkAllocateActualDevice(virDomainDefPtr dom, iface->virtPortProfile, netdef->virtPortProfile, portgroup - ? portgroup->virtPortProfile : NULL) < 0) { + ? portgroup->virtPortProfile : NULL) < 0) goto error; - } virtport = iface->data.network.actual->virtPortProfile; if (virtport) { /* make sure type is supported for hostdev connections */ @@ -3960,9 +3943,8 @@ networkAllocateActualDevice(virDomainDefPtr dom, iface->virtPortProfile, netdef->virtPortProfile, portgroup - ? portgroup->virtPortProfile : NULL) < 0) { + ? portgroup->virtPortProfile : NULL) < 0) goto error; - } virtport = iface->data.network.actual->virtPortProfile; if (virtport) { /* make sure type is supported for macvtap connections */ @@ -4544,9 +4526,8 @@ networkGetNetworkAddress(const char *netname, char **netaddr) } if (!(addrptr && - (*netaddr = virSocketAddrFormat(addrptr)))) { + (*netaddr = virSocketAddrFormat(addrptr)))) goto error; - } ret = 0; cleanup: diff --git a/src/network/bridge_driver_linux.c b/src/network/bridge_driver_linux.c index 6b32838..3fcc7f2 100644 --- a/src/network/bridge_driver_linux.c +++ b/src/network/bridge_driver_linux.c @@ -74,9 +74,8 @@ int networkCheckRouteCollision(virNetworkDefPtr def) /* NUL-terminate the line, so sscanf doesn't go beyond a newline. */ char *nl = strchr(cur, '\n'); - if (nl) { + if (nl) *nl++ = '\0'; - } num = sscanf(cur, "%16s %127s %*s %*s %*s %*s %*s %127s", iface, dest, mask); @@ -460,9 +459,8 @@ networkAddGeneralIPv6FirewallRules(virFirewallPtr fw, { if (!virNetworkDefGetIpByIndex(def, AF_INET6, 0) && - !def->ipv6nogw) { + !def->ipv6nogw) return; - } /* Catch all rules to block forwarding to/from bridges */ iptablesAddForwardRejectOut(fw, VIR_FIREWALL_LAYER_IPV6, def->bridge); @@ -484,9 +482,8 @@ networkRemoveGeneralIPv6FirewallRules(virFirewallPtr fw, virNetworkDefPtr def) { if (!virNetworkDefGetIpByIndex(def, AF_INET6, 0) && - !def->ipv6nogw) { + !def->ipv6nogw) return; - } if (virNetworkDefGetIpByIndex(def, AF_INET6, 0)) { iptablesRemoveUdpInput(fw, VIR_FIREWALL_LAYER_IPV6, def->bridge, 547); diff --git a/src/network/leaseshelper.c b/src/network/leaseshelper.c index 5b3c9c3..eb216cc 100644 --- a/src/network/leaseshelper.c +++ b/src/network/leaseshelper.c @@ -209,9 +209,8 @@ main(int argc, char **argv) /* Read entire contents */ if ((custom_lease_file_len = virFileReadAll(custom_lease_file, VIR_NETWORK_DHCP_LEASE_FILE_SIZE_MAX, - &lease_entries)) < 0) { + &lease_entries)) < 0) goto cleanup; - } if (action == VIR_LEASE_ACTION_ADD || action == VIR_LEASE_ACTION_OLD || diff --git a/src/nodeinfo.c b/src/nodeinfo.c index 2e2fffa..24a9214 100644 --- a/src/nodeinfo.c +++ b/src/nodeinfo.c @@ -821,9 +821,8 @@ linuxNodeGetCPUStats(FILE *procstat, "%*s %llu %llu %llu %llu %llu" // user ~ iowait "%llu %llu %llu %llu %llu", // irq ~ guest_nice &usr, &ni, &sys, &idle, &iowait, - &irq, &softirq, &steal, &guest, &guest_nice) < 4) { + &irq, &softirq, &steal, &guest, &guest_nice) < 4) continue; - } if (virNodeCPUStatsAssign(¶ms[0], VIR_NODE_CPU_STATS_KERNEL, (sys + irq + softirq) * TICK_TO_NSEC) < 0) diff --git a/src/nwfilter/nwfilter_dhcpsnoop.c b/src/nwfilter/nwfilter_dhcpsnoop.c index a2f58ba..5b4965d 100644 --- a/src/nwfilter/nwfilter_dhcpsnoop.c +++ b/src/nwfilter/nwfilter_dhcpsnoop.c @@ -315,9 +315,8 @@ virNWFilterSnoopActivate(virNWFilterSnoopReqPtr req) virNWFilterSnoopActiveLock(); - if (virHashAddEntry(virNWFilterSnoopState.active, key, (void *)0x1) < 0) { + if (virHashAddEntry(virNWFilterSnoopState.active, key, (void *)0x1) < 0) VIR_FREE(key); - } virNWFilterSnoopActiveUnlock(); @@ -1420,9 +1419,8 @@ virNWFilterDHCPSnoopThread(void *req0) while (!error) { if (virNWFilterSnoopAdjustPoll(pcapConf, ARRAY_CARDINALITY(pcapConf), - fds, &pollTo) < 0) { + fds, &pollTo) < 0) break; - } /* cap pollTo so we don't hold up the join for too long */ if (pollTo < 0 || pollTo > SNOOP_POLL_MAX_TIMEOUT_MS) diff --git a/src/nwfilter/nwfilter_ebiptables_driver.c b/src/nwfilter/nwfilter_ebiptables_driver.c index 2b89439..377b59b 100644 --- a/src/nwfilter/nwfilter_ebiptables_driver.c +++ b/src/nwfilter/nwfilter_ebiptables_driver.c @@ -3084,14 +3084,12 @@ virNWFilterRuleInstSort(const void *a, const void *b) /* ensure root chain commands appear before all others since we will need them to create the child chains */ if (root_a) { - if (root_b) { + if (root_b) goto normal; - } return -1; /* a before b */ } - if (root_b) { + if (root_b) return 1; /* b before a */ - } normal: /* priorities are limited to range [-1000, 1000] */ return insta->priority - instb->priority; @@ -3165,9 +3163,8 @@ ebtablesGetProtoIdxByFiltername(const char *filtername) enum l3_proto_idx idx; for (idx = 0; idx < L3_PROTO_LAST_IDX; idx++) { - if (STRPREFIX(filtername, l3_protocols[idx].val)) { + if (STRPREFIX(filtername, l3_protocols[idx].val)) return idx; - } } return -1; @@ -3303,9 +3300,8 @@ ebtablesGetSubChainInsts(virHashTablePtr chains, cleanup: VIR_FREE(filter_names); if (ret < 0) { - for (i = 0; i < *ninsts; i++) { + for (i = 0; i < *ninsts; i++) VIR_FREE(*insts[i]); - } VIR_FREE(*insts); *ninsts = 0; } diff --git a/src/nwfilter/nwfilter_gentech_driver.c b/src/nwfilter/nwfilter_gentech_driver.c index 79fc422..aaca77d 100644 --- a/src/nwfilter/nwfilter_gentech_driver.c +++ b/src/nwfilter/nwfilter_gentech_driver.c @@ -567,9 +567,8 @@ virNWFilterDetermineMissingVarsRec(virNWFilterDefPtr filter, switch (useNewFilter) { case INSTANTIATE_FOLLOW_NEWFILTER: - if (obj->newDef) { + if (obj->newDef) next_filter = obj->newDef; - } break; case INSTANTIATE_ALWAYS: break; @@ -705,9 +704,8 @@ virNWFilterInstantiate(const unsigned char *vmuuid ATTRIBUTE_UNUSED, } else if (virHashSize(missing_vars->hashTable) > 1) { goto err_unresolvable_vars; } else if (!forceWithPendingReq && - virNWFilterLookupLearnReq(ifindex) != NULL) { + virNWFilterLookupLearnReq(ifindex) != NULL) goto err_exit; - } rc = virNWFilterDefToInst(driver, filter, @@ -1139,15 +1137,13 @@ virNWFilterDomainFWUpdateCB(virDomainObjPtr obj, break; case STEP_TEAR_NEW: - if (!virHashLookup(cb->skipInterfaces, net->ifname)) { + if (!virHashLookup(cb->skipInterfaces, net->ifname)) ret = virNWFilterRollbackUpdateFilter(net); - } break; case STEP_TEAR_OLD: - if (!virHashLookup(cb->skipInterfaces, net->ifname)) { + if (!virHashLookup(cb->skipInterfaces, net->ifname)) ret = virNWFilterTearOldFilter(net); - } break; case STEP_APPLY_CURRENT: diff --git a/src/nwfilter/nwfilter_learnipaddr.c b/src/nwfilter/nwfilter_learnipaddr.c index 911079e..1b875c3 100644 --- a/src/nwfilter/nwfilter_learnipaddr.c +++ b/src/nwfilter/nwfilter_learnipaddr.c @@ -797,9 +797,8 @@ virNWFilterLearnInit(void) threadsTerminate = false; pendingLearnReq = virHashCreate(0, freeLearnReqEntry); - if (!pendingLearnReq) { + if (!pendingLearnReq) return -1; - } ifaceLockMap = virHashCreate(0, virHashValueFree); if (!ifaceLockMap) { diff --git a/src/openvz/openvz_conf.c b/src/openvz/openvz_conf.c index 856c9f5..edf37d0 100644 --- a/src/openvz/openvz_conf.c +++ b/src/openvz/openvz_conf.c @@ -660,9 +660,8 @@ openvzWriteConfigParam(const char * conf_file, const char *param, const char *va if (fp == NULL) goto error; temp_fd = open(temp_file, O_WRONLY | O_CREAT | O_TRUNC, 0644); - if (temp_fd == -1) { + if (temp_fd == -1) goto error; - } while (1) { if (getline(&line, &line_size, fp) <= 0) diff --git a/src/openvz/openvz_driver.c b/src/openvz/openvz_driver.c index a0346b4..6847e12 100644 --- a/src/openvz/openvz_driver.c +++ b/src/openvz/openvz_driver.c @@ -156,9 +156,8 @@ openvzDomainDefineCmd(virDomainDefPtr vmdef) virCommandAddArgList(cmd, vmdef->name, "--name", vmdef->name, NULL); if (vmdef->nfss == 1 && - vmdef->fss[0]->type == VIR_DOMAIN_FS_TYPE_TEMPLATE) { + vmdef->fss[0]->type == VIR_DOMAIN_FS_TYPE_TEMPLATE) virCommandAddArgList(cmd, "--ostemplate", vmdef->fss[0]->src, NULL); - } return cmd; } @@ -619,9 +618,8 @@ static int openvzDomainSuspend(virDomainPtr dom) if (virDomainObjGetState(vm, NULL) != VIR_DOMAIN_PAUSED) { openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) goto cleanup; - } virDomainObjSetState(vm, VIR_DOMAIN_PAUSED, VIR_DOMAIN_PAUSED_USER); } @@ -658,9 +656,8 @@ static int openvzDomainResume(virDomainPtr dom) if (virDomainObjGetState(vm, NULL) == VIR_DOMAIN_PAUSED) { openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) goto cleanup; - } virDomainObjSetState(vm, VIR_DOMAIN_RUNNING, VIR_DOMAIN_RUNNING_UNPAUSED); } @@ -1113,9 +1110,8 @@ openvzDomainCreateXML(virConnectPtr conn, const char *xml, openvzSetProgramSentinal(progstart, vm->def->name); - if (virRun(progstart, NULL) < 0) { + if (virRun(progstart, NULL) < 0) goto cleanup; - } vm->pid = strtoI(vm->def->name); vm->def->id = vm->pid; @@ -1172,9 +1168,8 @@ openvzDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) goto cleanup; - } vm->pid = strtoI(vm->def->name); vm->def->id = vm->pid; @@ -1218,9 +1213,8 @@ openvzDomainUndefineFlags(virDomainPtr dom, goto cleanup; openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) goto cleanup; - } if (virDomainObjIsActive(vm)) { vm->persistent = 0; @@ -1264,9 +1258,8 @@ openvzDomainSetAutostart(virDomainPtr dom, int autostart) } openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) goto cleanup; - } ret = 0; cleanup: @@ -1357,9 +1350,8 @@ static int openvzDomainSetVcpusInternal(virDomainObjPtr vm, str_vcpus[31] = '\0'; openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) return -1; - } vm->def->maxvcpus = vm->def->vcpus = nvcpus; return 0; @@ -1504,7 +1496,8 @@ static int openvzConnectClose(virConnectPtr conn) return 0; } -static const char *openvzConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED) { +static const char *openvzConnectGetType(virConnectPtr conn ATTRIBUTE_UNUSED) +{ return "OpenVZ"; } @@ -1719,9 +1712,8 @@ openvzDomainSetMemoryInternal(virDomainObjPtr vm, snprintf(str_mem, sizeof(str_mem), "%llu", mem * 1024); openvzSetProgramSentinal(prog, vm->def->name); - if (virRun(prog, NULL) < 0) { + if (virRun(prog, NULL) < 0) goto cleanup; - } return 0; @@ -2052,9 +2044,8 @@ openvzUpdateDevice(virDomainDefPtr vmdef, return -1; } - if (openvzSetDiskQuota(vmdef, fs, persist) < 0) { + if (openvzSetDiskQuota(vmdef, fs, persist) < 0) return -1; - } cur->space_hard_limit = fs->space_hard_limit; cur->space_soft_limit = fs->space_soft_limit; } else { diff --git a/src/parallels/parallels_driver.c b/src/parallels/parallels_driver.c index 808dc4a..aa0c4bd 100644 --- a/src/parallels/parallels_driver.c +++ b/src/parallels/parallels_driver.c @@ -167,9 +167,8 @@ parallelsBuildCapabilities(void) caps->host.cpu = cpu; if (!(data = cpuNodeData(cpu->arch)) - || cpuDecode(cpu, data, NULL, 0, NULL) < 0) { + || cpuDecode(cpu, data, NULL, 0, NULL) < 0) goto cleanup; - } cleanup: cpuDataFree(data); @@ -510,9 +509,8 @@ parallelsGetNetInfo(virDomainNetDefPtr net, net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_UP; if ((tmp = virJSONValueObjectGetString(value, "state")) && - STREQ(tmp, "disconnected")) { + STREQ(tmp, "disconnected")) net->linkstate = VIR_DOMAIN_NET_INTERFACE_LINK_STATE_DOWN; - } return 0; diff --git a/src/phyp/phyp_driver.c b/src/phyp/phyp_driver.c index 09617c8..4995269 100644 --- a/src/phyp/phyp_driver.c +++ b/src/phyp/phyp_driver.c @@ -128,9 +128,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status, } } - if (channel == NULL) { + if (channel == NULL) goto err; - } while ((rc = libssh2_channel_exec(channel, cmd)) == LIBSSH2_ERROR_EAGAIN) { @@ -141,9 +140,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status, } } - if (rc != 0) { + if (rc != 0) goto err; - } for (;;) { /* loop until we block */ @@ -179,9 +177,8 @@ phypExec(LIBSSH2_SESSION *session, const char *cmd, int *exit_status, } } - if (rc == 0) { + if (rc == 0) exitcode = libssh2_channel_get_exit_status(channel); - } (*exit_status) = exitcode; libssh2_channel_free(channel); @@ -690,9 +687,8 @@ phypUUIDTable_Pull(virConnectPtr conn) do { amount = sizeof(buffer); - if ((fileinfo.st_size - got) < amount) { + if ((fileinfo.st_size - got) < amount) amount = fileinfo.st_size - got; - } rc = libssh2_channel_read(channel, buffer, amount); if (rc > 0) { @@ -808,9 +804,8 @@ phypUUIDTable_Init(virConnectPtr conn) cleanup: if (ret < 0 && table_created) { - for (i = 0; i < uuid_table->nlpars; i++) { + for (i = 0; i < uuid_table->nlpars; i++) VIR_FREE(uuid_table->lpars[i]); - } VIR_FREE(uuid_table->lpars); } VIR_FREE(ids); @@ -1695,18 +1690,16 @@ phypDomainAttachDevice(virDomainPtr domain, const char *xml) domain_name = escape_specialcharacters(domain->name); - if (domain_name == NULL) { + if (domain_name == NULL) goto cleanup; - } if (VIR_STRDUP(def->os.type, "aix") < 0) goto cleanup; dev = virDomainDeviceDefParse(xml, def, phyp_driver->caps, NULL, VIR_DOMAIN_XML_INACTIVE); - if (!dev) { + if (!dev) goto cleanup; - } if (! (vios_name = diff --git a/src/remote/remote_driver.c b/src/remote/remote_driver.c index d111e10..d605616 100644 --- a/src/remote/remote_driver.c +++ b/src/remote/remote_driver.c @@ -2191,9 +2191,8 @@ remoteDomainPinEmulator(virDomainPtr dom, if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_PIN_EMULATOR, (xdrproc_t) xdr_remote_domain_pin_emulator_args, (char *) &args, - (xdrproc_t) xdr_void, (char *) NULL) == -1) { + (xdrproc_t) xdr_void, (char *) NULL) == -1) goto done; - } rv = 0; @@ -2352,9 +2351,8 @@ remoteDomainGetSecurityLabel(virDomainPtr domain, virSecurityLabelPtr seclabel) if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL, (xdrproc_t) xdr_remote_domain_get_security_label_args, (char *)&args, - (xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret) == -1) { + (xdrproc_t) xdr_remote_domain_get_security_label_ret, (char *)&ret) == -1) goto done; - } if (ret.label.label_val != NULL) { if (strlen(ret.label.label_val) >= sizeof(seclabel->label)) { @@ -2392,9 +2390,8 @@ remoteDomainGetSecurityLabelList(virDomainPtr domain, virSecurityLabelPtr* secla if (call(domain->conn, priv, 0, REMOTE_PROC_DOMAIN_GET_SECURITY_LABEL_LIST, (xdrproc_t) xdr_remote_domain_get_security_label_list_args, (char *)&args, - (xdrproc_t) xdr_remote_domain_get_security_label_list_ret, (char *)&ret) == -1) { + (xdrproc_t) xdr_remote_domain_get_security_label_list_ret, (char *)&ret) == -1) goto done; - } if (VIR_ALLOC_N(*seclabels, ret.labels.labels_len) < 0) goto cleanup; @@ -2469,9 +2466,8 @@ remoteNodeGetSecurityModel(virConnectPtr conn, virSecurityModelPtr secmodel) if (call(conn, priv, 0, REMOTE_PROC_NODE_GET_SECURITY_MODEL, (xdrproc_t) xdr_void, NULL, - (xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret) == -1) { + (xdrproc_t) xdr_remote_node_get_security_model_ret, (char *)&ret) == -1) goto done; - } if (ret.model.model_val != NULL) { if (strlen(ret.model.model_val) >= sizeof(secmodel->model)) { @@ -2655,9 +2651,8 @@ remoteDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) memset(&ret, 0, sizeof(ret)); if (call(dom->conn, priv, 0, REMOTE_PROC_DOMAIN_CREATE_WITH_FLAGS, (xdrproc_t)xdr_remote_domain_create_with_flags_args, (char *)&args, - (xdrproc_t)xdr_remote_domain_create_with_flags_ret, (char *)&ret) == -1) { + (xdrproc_t)xdr_remote_domain_create_with_flags_ret, (char *)&ret) == -1) goto done; - } dom->id = ret.dom.id; xdr_free((xdrproc_t) &xdr_remote_domain_create_with_flags_ret, (char *) &ret); @@ -2907,9 +2902,8 @@ static int remoteDomainGetBlockIoTune(virDomainPtr domain, (xdrproc_t) xdr_remote_domain_get_block_io_tune_args, (char *) &args, (xdrproc_t) xdr_remote_domain_get_block_io_tune_ret, - (char *) &ret) == -1) { + (char *) &ret) == -1) goto done; - } /* Handle the case when the caller does not know the number of parameters * and is asking for the number of parameters supported @@ -4140,9 +4134,8 @@ static sasl_callback_t *remoteAuthMakeCallbacks(int *credtype, int ncredtype) sasl_callback_t *cbs; size_t i; int n; - if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) { + if (VIR_ALLOC_N(cbs, ncredtype+1) < 0) return NULL; - } for (i = 0, n = 0; i < ncredtype; i++) { int id = remoteAuthCredVir2SASL(credtype[i]); @@ -4621,9 +4614,8 @@ remoteAuthPolkit(virConnectPtr conn, struct private_data *priv, memset(&ret, 0, sizeof(ret)); if (call(conn, priv, 0, REMOTE_PROC_AUTH_POLKIT, (xdrproc_t) xdr_void, (char *)NULL, - (xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) { + (xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) return -1; /* virError already set by call */ - } VIR_DEBUG("PolicyKit-1 authentication complete"); return 0; @@ -4683,9 +4675,8 @@ remoteAuthPolkit(virConnectPtr conn, struct private_data *priv, memset(&ret, 0, sizeof(ret)); if (call(conn, priv, 0, REMOTE_PROC_AUTH_POLKIT, (xdrproc_t) xdr_void, (char *)NULL, - (xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) { + (xdrproc_t) xdr_remote_auth_polkit_ret, (char *) &ret) != 0) return -1; /* virError already set by call */ - } out: VIR_DEBUG("PolicyKit-0 authentication complete"); @@ -7516,9 +7507,8 @@ remoteDomainCreateXMLWithFiles(virConnectPtr conn, const char *xml_desc, NULL, NULL, REMOTE_PROC_DOMAIN_CREATE_XML_WITH_FILES, (xdrproc_t)xdr_remote_domain_create_xml_with_files_args, (char *)&args, - (xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char *)&ret) == -1) { + (xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char *)&ret) == -1) goto done; - } rv = get_nonnull_domain(conn, ret.dom); xdr_free((xdrproc_t)xdr_remote_domain_create_xml_with_files_ret, (char *)&ret); @@ -7551,9 +7541,8 @@ remoteDomainCreateWithFiles(virDomainPtr dom, NULL, NULL, REMOTE_PROC_DOMAIN_CREATE_WITH_FILES, (xdrproc_t)xdr_remote_domain_create_with_files_args, (char *)&args, - (xdrproc_t)xdr_remote_domain_create_with_files_ret, (char *)&ret) == -1) { + (xdrproc_t)xdr_remote_domain_create_with_files_ret, (char *)&ret) == -1) goto done; - } dom->id = ret.dom.id; xdr_free((xdrproc_t) &xdr_remote_domain_create_with_files_ret, (char *) &ret); diff --git a/src/rpc/virnetclient.c b/src/rpc/virnetclient.c index a156fe1..8657b0e 100644 --- a/src/rpc/virnetclient.c +++ b/src/rpc/virnetclient.c @@ -160,9 +160,8 @@ static void virNetClientCallQueue(virNetClientCallPtr *head, virNetClientCallPtr call) { virNetClientCallPtr tmp = *head; - while (tmp && tmp->next) { + while (tmp && tmp->next) tmp = tmp->next; - } if (tmp) tmp->next = call; else @@ -237,9 +236,8 @@ static bool virNetClientCallMatchPredicate(virNetClientCallPtr head, { virNetClientCallPtr tmp = head; while (tmp) { - if (pred(tmp, opaque)) { + if (pred(tmp, opaque)) return true; - } tmp = tmp->next; } return false; @@ -1535,9 +1533,8 @@ static int virNetClientIOEventLoop(virNetClientPtr client, /* If we have existing SASL decoded data, pretend * the socket became readable so we consume it */ - if (virNetSocketHasCachedData(client->sock)) { + if (virNetSocketHasCachedData(client->sock)) fds[0].revents |= POLLIN; - } /* If wantClose flag is set, pretend there was an error on the socket */ diff --git a/src/rpc/virnetserver.c b/src/rpc/virnetserver.c index 3d3e422..47d83ba 100644 --- a/src/rpc/virnetserver.c +++ b/src/rpc/virnetserver.c @@ -1233,9 +1233,8 @@ void virNetServerClose(virNetServerPtr srv) virObjectLock(srv); - for (i = 0; i < srv->nservices; i++) { + for (i = 0; i < srv->nservices; i++) virNetServerServiceClose(srv->services[i]); - } virObjectUnlock(srv); } diff --git a/src/rpc/virnetserverclient.c b/src/rpc/virnetserverclient.c index c6ef84c..b2a4fdf 100644 --- a/src/rpc/virnetserverclient.c +++ b/src/rpc/virnetserverclient.c @@ -496,9 +496,8 @@ virNetServerClientPtr virNetServerClientNewPostExecRestart(virJSONValuePtr objec _("Missing privateData field in JSON state document")); goto error; } - if (!(client->privateData = privNew(client, child, privOpaque))) { + if (!(client->privateData = privNew(client, child, privOpaque))) goto error; - } client->privateDataFreeFunc = privFree; client->privateDataPreExecRestart = privPreExecRestart; } diff --git a/src/rpc/virnetserverservice.c b/src/rpc/virnetserverservice.c index 647007b..d84b6de 100644 --- a/src/rpc/virnetserverservice.c +++ b/src/rpc/virnetserverservice.c @@ -516,7 +516,6 @@ void virNetServerServiceClose(virNetServerServicePtr svc) if (!svc) return; - for (i = 0; i < svc->nsocks; i++) { + for (i = 0; i < svc->nsocks; i++) virNetSocketClose(svc->socks[i]); - } } -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- src/access/viraccessdriverstack.c | 3 +-- src/bhyve/bhyve_driver.c | 3 +-- src/cpu/cpu_powerpc.c | 3 +-- src/cpu/cpu_x86.c | 3 +-- src/datatypes.c | 6 ++---- src/driver.c | 3 +-- src/interface/interface_backend_udev.c | 15 +++++---------- src/libvirt-domain.c | 6 ++---- src/libvirt-lxc.c | 3 +-- src/libvirt-nodedev.c | 3 +-- src/libvirt-storage.c | 6 ++---- src/libxl/libxl_conf.c | 3 +-- src/libxl/libxl_driver.c | 12 ++++-------- src/locking/lock_daemon.c | 9 +++------ src/locking/lock_driver_sanlock.c | 6 ++---- src/lxc/lxc_container.c | 12 ++++-------- src/lxc/lxc_driver.c | 12 ++++-------- src/lxc/lxc_process.c | 6 ++---- 18 files changed, 38 insertions(+), 76 deletions(-) diff --git a/src/access/viraccessdriverstack.c b/src/access/viraccessdriverstack.c index 11ed4f6..b43a743 100644 --- a/src/access/viraccessdriverstack.c +++ b/src/access/viraccessdriverstack.c @@ -54,9 +54,8 @@ static void virAccessDriverStackCleanup(virAccessManagerPtr manager) virAccessDriverStackPrivatePtr priv = virAccessManagerGetPrivateData(manager); size_t i; - for (i = 0; i < priv->managersLen; i++) { + for (i = 0; i < priv->managersLen; i++) virObjectUnref(priv->managers[i]); - } VIR_FREE(priv->managers); } diff --git a/src/bhyve/bhyve_driver.c b/src/bhyve/bhyve_driver.c index eb0d455..12067dd 100644 --- a/src/bhyve/bhyve_driver.c +++ b/src/bhyve/bhyve_driver.c @@ -1153,9 +1153,8 @@ bhyveStateInitialize(bool priveleged ATTRIBUTE_UNUSED, return 0; } - if (VIR_ALLOC(bhyve_driver) < 0) { + if (VIR_ALLOC(bhyve_driver) < 0) return -1; - } if (virMutexInit(&bhyve_driver->lock) < 0) { VIR_FREE(bhyve_driver); diff --git a/src/cpu/cpu_powerpc.c b/src/cpu/cpu_powerpc.c index 67cb9ff..493432a 100644 --- a/src/cpu/cpu_powerpc.c +++ b/src/cpu/cpu_powerpc.c @@ -487,9 +487,8 @@ ppcDecode(virCPUDefPtr cpu, } if (VIR_STRDUP(cpu->model, model->name) < 0 || - (model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0)) { + (model->vendor && VIR_STRDUP(cpu->vendor, model->vendor->name) < 0)) goto cleanup; - } ret = 0; diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c index 026b54e..b0e7c49 100644 --- a/src/cpu/cpu_x86.c +++ b/src/cpu/cpu_x86.c @@ -1765,9 +1765,8 @@ x86Encode(virArch arch, if (v && (VIR_ALLOC(data_vendor) < 0 || - virCPUx86DataAddCPUID(data_vendor, &v->cpuid) < 0)) { + virCPUx86DataAddCPUID(data_vendor, &v->cpuid) < 0)) goto error; - } } if (forced && diff --git a/src/datatypes.c b/src/datatypes.c index 87e3550..b4f6765 100644 --- a/src/datatypes.c +++ b/src/datatypes.c @@ -450,9 +450,8 @@ virStoragePoolDispose(void *obj) virUUIDFormat(pool->uuid, uuidstr); VIR_DEBUG("release pool %p %s %s", pool, pool->name, uuidstr); - if (pool->privateDataFreeFunc) { + if (pool->privateDataFreeFunc) pool->privateDataFreeFunc(pool->privateData); - } VIR_FREE(pool->name); virObjectUnref(pool->conn); @@ -525,9 +524,8 @@ virStorageVolDispose(void *obj) virStorageVolPtr vol = obj; VIR_DEBUG("release vol %p %s", vol, vol->name); - if (vol->privateDataFreeFunc) { + if (vol->privateDataFreeFunc) vol->privateDataFreeFunc(vol->privateData); - } VIR_FREE(vol->key); VIR_FREE(vol->name); diff --git a/src/driver.c b/src/driver.c index 71569e6..1be32ef 100644 --- a/src/driver.c +++ b/src/driver.c @@ -85,9 +85,8 @@ virDriverLoadModule(const char *name) *tmp = c_toupper(*tmp); } - if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0) { + if (virAsprintfQuiet(®func, "%sRegister", fixedname) < 0) goto cleanup; - } regsym = dlsym(handle, regfunc); if (!regsym) { diff --git a/src/interface/interface_backend_udev.c b/src/interface/interface_backend_udev.c index 1dbbfe7..401697f 100644 --- a/src/interface/interface_backend_udev.c +++ b/src/interface/interface_backend_udev.c @@ -391,9 +391,8 @@ udevConnectListAllInterfaces(virConnectPtr conn, devices = udev_enumerate_get_list_entry(enumerate); /* For each item so we can count */ - udev_list_entry_foreach(dev_entry, devices) { + udev_list_entry_foreach(dev_entry, devices) count++; - } /* If we've got nothing, exit out */ if (count == 0) { @@ -845,9 +844,8 @@ udevGetIfaceDefBond(struct udev *udev, return 0; error: - for (i = 0; slave_count != -1 && i < slave_count; i++) { + for (i = 0; slave_count != -1 && i < slave_count; i++) VIR_FREE(slave_list[i]); - } VIR_FREE(slave_list); return -1; @@ -952,9 +950,8 @@ udevGetIfaceDefBridge(struct udev *udev, return 0; error: - for (i = 0; member_count != -1 && i < member_count; i++) { + for (i = 0; member_count != -1 && i < member_count; i++) VIR_FREE(member_list[i]); - } VIR_FREE(member_list); return -1; @@ -1102,14 +1099,12 @@ udevGetIfaceDef(struct udev *udev, const char *name) * to prevent false positives */ vlan_parent_dev = strrchr(name, '.'); - if (vlan_parent_dev) { + if (vlan_parent_dev) ifacedef->type = VIR_INTERFACE_TYPE_VLAN; - } /* Fallback check to see if this is a bond device */ - if (udev_device_get_sysattr_value(dev, "bonding/mode")) { + if (udev_device_get_sysattr_value(dev, "bonding/mode")) ifacedef->type = VIR_INTERFACE_TYPE_BOND; - } } switch (ifacedef->type) { diff --git a/src/libvirt-domain.c b/src/libvirt-domain.c index 2b0defc..427f77a 100644 --- a/src/libvirt-domain.c +++ b/src/libvirt-domain.c @@ -4063,9 +4063,8 @@ virDomainMigrate3(virDomainPtr domain, virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_XML, &dxml) < 0 || virTypedParamsGetULLong(params, nparams, - VIR_MIGRATE_PARAM_BANDWIDTH, &bandwidth) < 0) { + VIR_MIGRATE_PARAM_BANDWIDTH, &bandwidth) < 0) goto error; - } if (VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, VIR_DRV_FEATURE_MIGRATION_V3) && @@ -4492,9 +4491,8 @@ virDomainMigrateToURI3(virDomainPtr domain, virTypedParamsGetString(params, nparams, VIR_MIGRATE_PARAM_DEST_XML, &dxml) < 0 || virTypedParamsGetULLong(params, nparams, - VIR_MIGRATE_PARAM_BANDWIDTH, &bandwidth) < 0) { + VIR_MIGRATE_PARAM_BANDWIDTH, &bandwidth) < 0) goto error; - } if (flags & VIR_MIGRATE_PEER2PEER) { if (!VIR_DRV_SUPPORTS_FEATURE(domain->conn->driver, domain->conn, diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index 58892df..8553570 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -145,9 +145,8 @@ virDomainLxcEnterNamespace(virDomainPtr domain, if (virProcessSetNamespaces(nfdlist, fdlist) < 0) { if (oldfdlist && noldfdlist) { - for (i = 0; i < *noldfdlist; i++) { + for (i = 0; i < *noldfdlist; i++) VIR_FORCE_CLOSE((*oldfdlist)[i]); - } VIR_FREE(*oldfdlist); *noldfdlist = 0; } diff --git a/src/libvirt-nodedev.c b/src/libvirt-nodedev.c index c19aeef..b6c6d1e 100644 --- a/src/libvirt-nodedev.c +++ b/src/libvirt-nodedev.c @@ -741,9 +741,8 @@ virNodeDeviceDestroy(virNodeDevicePtr dev) if (dev->conn->nodeDeviceDriver && dev->conn->nodeDeviceDriver->nodeDeviceDestroy) { int retval = dev->conn->nodeDeviceDriver->nodeDeviceDestroy(dev); - if (retval < 0) { + if (retval < 0) goto error; - } return 0; } diff --git a/src/libvirt-storage.c b/src/libvirt-storage.c index 190c718..54c7332 100644 --- a/src/libvirt-storage.c +++ b/src/libvirt-storage.c @@ -1746,9 +1746,8 @@ virStorageVolWipe(virStorageVolPtr vol, if (conn->storageDriver && conn->storageDriver->storageVolWipe) { int ret; ret = conn->storageDriver->storageVolWipe(vol, flags); - if (ret < 0) { + if (ret < 0) goto error; - } return ret; } @@ -1789,9 +1788,8 @@ virStorageVolWipePattern(virStorageVolPtr vol, if (conn->storageDriver && conn->storageDriver->storageVolWipePattern) { int ret; ret = conn->storageDriver->storageVolWipePattern(vol, algorithm, flags); - if (ret < 0) { + if (ret < 0) goto error; - } return ret; } diff --git a/src/libxl/libxl_conf.c b/src/libxl/libxl_conf.c index e296ffc..3c200ef 100644 --- a/src/libxl/libxl_conf.c +++ b/src/libxl/libxl_conf.c @@ -675,9 +675,8 @@ libxlMakeDomBuildInfo(virDomainDefPtr def, VIR_TRISTATE_SWITCH_ON); for (i = 0; i < def->clock.ntimers; i++) { if (def->clock.timers[i]->name == VIR_DOMAIN_TIMER_NAME_HPET && - def->clock.timers[i]->present == 1) { + def->clock.timers[i]->present == 1) libxl_defbool_set(&b_info->u.hvm.hpet, 1); - } } for (i = 0; i < def->os.nBootDevs; i++) { switch (def->os.bootDevs[i]) { diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index d2c077c..8cbf3c0 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -246,9 +246,8 @@ libxlDriverShouldLoad(bool privileged) * xenfs to /proc/xen. */ status = virFileReadAll(HYPERVISOR_CAPABILITIES, 10, &output); - if (status >= 0) { + if (status >= 0) status = strncmp(output, "control_d", 9); - } VIR_FREE(output); if (status) { VIR_INFO("No Xen capabilities detected, probably not running " @@ -1792,9 +1791,8 @@ libxlDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, goto endjob; } - if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max) { + if (!(flags & VIR_DOMAIN_VCPU_MAXIMUM) && vm->def->maxvcpus < max) max = vm->def->maxvcpus; - } if (nvcpus > max) { virReportError(VIR_ERR_INVALID_ARG, @@ -1964,9 +1962,8 @@ libxlDomainPinVcpuFlags(virDomainPtr dom, unsigned int vcpu, &flags, &targetDef) < 0) goto endjob; - if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (flags & VIR_DOMAIN_AFFECT_LIVE) targetDef = vm->def; - } /* Make sure coverity knows targetDef is valid at this point. */ sa_assert(targetDef); @@ -2066,9 +2063,8 @@ libxlDomainGetVcpuPinInfo(virDomainPtr dom, int ncpumaps, &flags, &targetDef) < 0) goto cleanup; - if (flags & VIR_DOMAIN_AFFECT_LIVE) { + if (flags & VIR_DOMAIN_AFFECT_LIVE) targetDef = vm->def; - } /* Make sure coverity knows targetDef is valid at this point. */ sa_assert(targetDef); diff --git a/src/locking/lock_daemon.c b/src/locking/lock_daemon.c index 75244e8..bb34f06 100644 --- a/src/locking/lock_daemon.c +++ b/src/locking/lock_daemon.c @@ -225,9 +225,8 @@ virLockDaemonNewPostExecRestart(virJSONValuePtr object, bool privileged) if (virHashAddEntry(lockd->lockspaces, virLockSpaceGetDirectory(lockspace), - lockspace) < 0) { + lockspace) < 0) virLockSpaceFree(lockspace); - } } if (!(child = virJSONValueObjectGet(object, "server"))) { @@ -343,9 +342,8 @@ virLockDaemonForkIntoBackground(const char *argv0) /* We wait to make sure the first child forked successfully */ if ((got = waitpid(pid, &exitstatus, 0)) < 0 || got != pid || - exitstatus != 0) { + exitstatus != 0) return -1; - } /* Now block until the second child initializes successfully */ again: @@ -1160,9 +1158,8 @@ int main(int argc, char **argv) { c = getopt_long(argc, argv, "ldf:p:t:vVh", opts, &optidx); - if (c == -1) { + if (c == -1) break; - } switch (c) { case 0: diff --git a/src/locking/lock_driver_sanlock.c b/src/locking/lock_driver_sanlock.c index 0318f25..d84a419 100644 --- a/src/locking/lock_driver_sanlock.c +++ b/src/locking/lock_driver_sanlock.c @@ -1008,9 +1008,8 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock, VIR_DEBUG("Acquire completed fd=%d", sock); if (res_free) { - for (i = 0; i < res_count; i++) { + for (i = 0; i < res_count; i++) VIR_FREE(res_args[i]); - } VIR_FREE(res_args); } @@ -1021,9 +1020,8 @@ static int virLockManagerSanlockAcquire(virLockManagerPtr lock, error: if (res_free) { - for (i = 0; i < res_count; i++) { + for (i = 0; i < res_count; i++) VIR_FREE(res_args[i]); - } VIR_FREE(res_args); } VIR_FREE(opt); diff --git a/src/lxc/lxc_container.c b/src/lxc/lxc_container.c index 8aba3ba..0229ee0 100644 --- a/src/lxc/lxc_container.c +++ b/src/lxc/lxc_container.c @@ -396,9 +396,8 @@ int lxcContainerSendContinue(int control) VIR_DEBUG("Send continue on fd %d", control); writeCount = safewrite(control, &msg, sizeof(msg)); - if (writeCount != sizeof(msg)) { + if (writeCount != sizeof(msg)) goto error_out; - } rc = 0; error_out: @@ -858,14 +857,12 @@ static int lxcContainerMountBasicFS(bool userns_enabled, */ if (userns_enabled && netns_disabled && STREQ(mnt->src, "sysfs")) { - if (VIR_STRDUP(mnt_src, "/sys") < 0) { + if (VIR_STRDUP(mnt_src, "/sys") < 0) goto cleanup; - } mnt_mflags = MS_NOSUID|MS_NOEXEC|MS_NODEV|MS_RDONLY|MS_BIND; } else { - if (VIR_STRDUP(mnt_src, mnt->src) < 0) { + if (VIR_STRDUP(mnt_src, mnt->src) < 0) goto cleanup; - } mnt_mflags = mnt->mflags; } @@ -2128,9 +2125,8 @@ static int lxcContainerChild(void *data) /* rename and enable interfaces */ if (lxcContainerRenameAndEnableInterfaces(vmDef, argv->nveths, - argv->veths) < 0) { + argv->veths) < 0) goto cleanup; - } /* drop a set of root capabilities */ if (lxcContainerDropCapabilities(vmDef, !!hasReboot) < 0) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 6a58d50..10bae70 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -1582,9 +1582,8 @@ static int lxcStateInitialize(bool privileged, return 0; } - if (VIR_ALLOC(lxc_driver) < 0) { + if (VIR_ALLOC(lxc_driver) < 0) return -1; - } if (virMutexInit(&lxc_driver->lock) < 0) { VIR_FREE(lxc_driver); return -1; @@ -1968,9 +1967,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, vm->def->cputune.period = params[i].value.ul; } - if (flags & VIR_DOMAIN_AFFECT_CONFIG) { + if (flags & VIR_DOMAIN_AFFECT_CONFIG) vmdef->cputune.period = params[i].value.ul; - } } else if (STREQ(param->field, VIR_DOMAIN_SCHEDULER_VCPU_QUOTA)) { if (flags & VIR_DOMAIN_AFFECT_LIVE) { rc = lxcSetVcpuBWLive(priv->cgroup, 0, params[i].value.l); @@ -1981,9 +1979,8 @@ lxcDomainSetSchedulerParametersFlags(virDomainPtr dom, vm->def->cputune.quota = params[i].value.l; } - if (flags & VIR_DOMAIN_AFFECT_CONFIG) { + if (flags & VIR_DOMAIN_AFFECT_CONFIG) vmdef->cputune.quota = params[i].value.l; - } } } @@ -4017,9 +4014,8 @@ lxcDomainAttachDeviceUnlink(virDomainObjPtr vm, if (virProcessRunInMountNamespace(priv->initpid, lxcDomainAttachDeviceUnlinkHelper, - file) < 0) { + file) < 0) return -1; - } return 0; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 6c83fdb..37ddbbc 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -536,9 +536,8 @@ static void virLXCProcessMonitorEOFNotify(virLXCMonitorPtr mon, if (vm) virObjectUnlock(vm); - if (event) { + if (event) virObjectEventStateQueue(driver->domainEventState, event); - } } static void virLXCProcessMonitorExitNotify(virLXCMonitorPtr mon ATTRIBUTE_UNUSED, @@ -826,9 +825,8 @@ virLXCProcessBuildControllerCmd(virLXCDriverPtr driver, virCommandAddArgFormat(cmd, "%d", handshakefd); virCommandAddArg(cmd, "--background"); - for (i = 0; i < nveths; i++) { + for (i = 0; i < nveths; i++) virCommandAddArgList(cmd, "--veth", veths[i], NULL); - } virCommandPassFD(cmd, handshakefd, 0); -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- tests/commandhelper.c | 3 +-- tests/esxutilstest.c | 18 ++++++----------- tests/eventtest.c | 3 +-- tests/networkxml2conftest.c | 3 +-- tests/networkxml2xmltest.c | 3 +-- tests/networkxml2xmlupdatetest.c | 3 +-- tests/nodeinfotest.c | 3 +-- tests/nwfilterxml2xmltest.c | 3 +-- tests/openvzutilstest.c | 9 +++------ tests/qemuxml2argvtest.c | 6 ++---- tests/qemuxmlnstest.c | 3 +-- tests/secretxml2xmltest.c | 3 +-- tests/securityselinuxlabeltest.c | 6 ++---- tests/sexpr2xmltest.c | 3 +-- tests/shunloadtest.c | 6 ++---- tests/storagepoolxml2xmltest.c | 3 +-- tests/storagevolxml2argvtest.c | 3 +-- tests/storagevolxml2xmltest.c | 3 +-- tests/sysinfotest.c | 6 ++---- tests/utiltest.c | 3 +-- tests/virbuftest.c | 3 +-- tests/virhashtest.c | 42 ++++++++++++++-------------------------- tests/virtimetest.c | 3 +-- tests/vmx2xmltest.c | 24 ++++++++--------------- tests/xml2sexprtest.c | 3 +-- tests/xml2vmxtest.c | 39 +++++++++++++------------------------ 26 files changed, 69 insertions(+), 138 deletions(-) diff --git a/tests/commandhelper.c b/tests/commandhelper.c index 86ed891..015efda 100644 --- a/tests/commandhelper.c +++ b/tests/commandhelper.c @@ -70,9 +70,8 @@ int main(int argc, char **argv) { if (!log) goto cleanup; - for (i = 1; i < argc; i++) { + for (i = 1; i < argc; i++) fprintf(log, "ARG:%s\n", argv[i]); - } origenv = environ; n = 0; diff --git a/tests/esxutilstest.c b/tests/esxutilstest.c index 41c0807..1061487 100644 --- a/tests/esxutilstest.c +++ b/tests/esxutilstest.c @@ -50,13 +50,11 @@ testParseDatastorePath(const void *data ATTRIBUTE_UNUSED) if (esxUtil_ParseDatastorePath (paths[i].datastorePath, &datastoreName, &directoryName, - &directoryAndFileName) != paths[i].result) { + &directoryAndFileName) != paths[i].result) goto failure; - } - if (paths[i].result < 0) { + if (paths[i].result < 0) continue; - } if (STRNEQ(paths[i].datastoreName, datastoreName)) { virtTestDifference(stderr, paths[i].datastoreName, datastoreName); @@ -134,13 +132,11 @@ testConvertDateTimeToCalendarTime(const void *data ATTRIBUTE_UNUSED) dateTime.value = (char *)times[i].dateTime; if (esxVI_DateTime_ConvertToCalendarTime(&dateTime, - &calendarTime) < 0) { + &calendarTime) < 0) return -1; - } - if (times[i].calendarTime != calendarTime) { + if (times[i].calendarTime != calendarTime) return -1; - } } return 0; @@ -186,9 +182,8 @@ testEscapeDatastoreItem(const void *data ATTRIBUTE_UNUSED) escaped = esxUtil_EscapeDatastoreItem(datastoreItems[i].string); - if (escaped == NULL) { + if (escaped == NULL) return -1; - } if (STRNEQ(datastoreItems[i].escaped, escaped)) { VIR_FREE(escaped); @@ -228,9 +223,8 @@ testConvertWindows1252ToUTF8(const void *data ATTRIBUTE_UNUSED) utf8 = virVMXConvertToUTF8("Windows-1252", windows1252ToUTF8[i].windows1252); - if (utf8 == NULL) { + if (utf8 == NULL) return -1; - } if (STRNEQ(windows1252ToUTF8[i].utf8, utf8)) { VIR_FREE(utf8); diff --git a/tests/eventtest.c b/tests/eventtest.c index 87b49d3..13adbf6 100644 --- a/tests/eventtest.c +++ b/tests/eventtest.c @@ -124,9 +124,8 @@ static int eventThreadJobDone; ATTRIBUTE_NORETURN static void *eventThreadLoop(void *data ATTRIBUTE_UNUSED) { while (1) { pthread_mutex_lock(&eventThreadMutex); - while (!eventThreadRunOnce) { + while (!eventThreadRunOnce) pthread_cond_wait(&eventThreadRunCond, &eventThreadMutex); - } eventThreadRunOnce = 0; pthread_mutex_unlock(&eventThreadMutex); diff --git a/tests/networkxml2conftest.c b/tests/networkxml2conftest.c index 4f1d934..fc37e14 100644 --- a/tests/networkxml2conftest.c +++ b/tests/networkxml2conftest.c @@ -87,9 +87,8 @@ testCompareXMLToConfHelper(const void *data) if (virAsprintf(&inxml, "%s/networkxml2confdata/%s.xml", abs_srcdir, info->name) < 0 || virAsprintf(&outxml, "%s/networkxml2confdata/%s.conf", - abs_srcdir, info->name) < 0) { + abs_srcdir, info->name) < 0) goto cleanup; - } result = testCompareXMLToConfFiles(inxml, outxml, info->caps); diff --git a/tests/networkxml2xmltest.c b/tests/networkxml2xmltest.c index 65ac591..ac3c12d 100644 --- a/tests/networkxml2xmltest.c +++ b/tests/networkxml2xmltest.c @@ -68,9 +68,8 @@ testCompareXMLToXMLHelper(const void *data) if (virAsprintf(&inxml, "%s/networkxml2xmlin/%s.xml", abs_srcdir, info->name) < 0 || virAsprintf(&outxml, "%s/networkxml2xmlout/%s.xml", - abs_srcdir, info->name) < 0) { + abs_srcdir, info->name) < 0) goto cleanup; - } result = testCompareXMLToXMLFiles(inxml, outxml, info->flags); diff --git a/tests/networkxml2xmlupdatetest.c b/tests/networkxml2xmlupdatetest.c index f34638a..fa1d597 100644 --- a/tests/networkxml2xmlupdatetest.c +++ b/tests/networkxml2xmlupdatetest.c @@ -101,9 +101,8 @@ testCompareXMLToXMLHelper(const void *data) virAsprintf(&updatexml, "%s/networkxml2xmlupdatein/%s.xml", abs_srcdir, info->updatexml) < 0 || virAsprintf(&outxml, "%s/networkxml2xmlupdateout/%s.xml", - abs_srcdir, info->outxml) < 0) { + abs_srcdir, info->outxml) < 0) goto cleanup; - } result = testCompareXMLToXMLFiles(netxml, updatexml, outxml, info->flags, info->command, info->section, diff --git a/tests/nodeinfotest.c b/tests/nodeinfotest.c index 3c76e5d..beefc3a 100644 --- a/tests/nodeinfotest.c +++ b/tests/nodeinfotest.c @@ -187,9 +187,8 @@ linuxTestNodeInfo(const void *opaque) virAsprintf(&cpuinfo, "%s/nodeinfodata/linux-%s-%s.cpuinfo", abs_srcdir, archStr, data->testName) < 0 || virAsprintf(&output, "%s/nodeinfodata/linux-%s-%s.expected", - abs_srcdir, archStr, data->testName) < 0) { + abs_srcdir, archStr, data->testName) < 0) goto cleanup; - } result = linuxTestCompareFiles(cpuinfo, sysfs_dir, data->arch, output); diff --git a/tests/nwfilterxml2xmltest.c b/tests/nwfilterxml2xmltest.c index ba1ead1..84155d7 100644 --- a/tests/nwfilterxml2xmltest.c +++ b/tests/nwfilterxml2xmltest.c @@ -79,9 +79,8 @@ testCompareXMLToXMLHelper(const void *data) if (virAsprintf(&inxml, "%s/nwfilterxml2xmlin/%s.xml", abs_srcdir, tp->name) < 0 || virAsprintf(&outxml, "%s/nwfilterxml2xmlout/%s.xml", - abs_srcdir, tp->name) < 0) { + abs_srcdir, tp->name) < 0) goto cleanup; - } result = testCompareXMLToXMLFiles(inxml, outxml, tp->expect_warning); diff --git a/tests/openvzutilstest.c b/tests/openvzutilstest.c index ed2c098..15315a3 100644 --- a/tests/openvzutilstest.c +++ b/tests/openvzutilstest.c @@ -42,19 +42,16 @@ testReadConfigParam(const void *data ATTRIBUTE_UNUSED) char *conf = NULL; char *value = NULL; - if (virAsprintf(&conf, "%s/openvzutilstest.conf", abs_srcdir) < 0) { + if (virAsprintf(&conf, "%s/openvzutilstest.conf", abs_srcdir) < 0) return -1; - } for (i = 0; i < ARRAY_CARDINALITY(configParams); ++i) { if (openvzReadConfigParam(conf, configParams[i].param, - &value) != configParams[i].ret) { + &value) != configParams[i].ret) goto cleanup; - } - if (configParams[i].ret != 1) { + if (configParams[i].ret != 1) continue; - } if (STRNEQ(configParams[i].value, value)) { virtTestDifference(stderr, configParams[i].value, value); diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 63e61bd..1e66b26 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -335,9 +335,8 @@ static int testCompareXMLToArgvFiles(const char *xml, virResetLastError(); if (vmdef->os.arch == VIR_ARCH_X86_64 || - vmdef->os.arch == VIR_ARCH_I686) { + vmdef->os.arch == VIR_ARCH_I686) virQEMUCapsSet(extraFlags, QEMU_CAPS_PCI_MULTIBUS); - } if (qemuAssignDeviceAliases(vmdef, extraFlags) < 0) goto out; @@ -347,9 +346,8 @@ static int testCompareXMLToArgvFiles(const char *xml, if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI && - hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) { + hostdev->source.subsys.u.pci.backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_DEFAULT) hostdev->source.subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_KVM; - } } for (i = 0; i < vmdef->ndisks; i++) { diff --git a/tests/qemuxmlnstest.c b/tests/qemuxmlnstest.c index 2f37a26..a53d081 100644 --- a/tests/qemuxmlnstest.c +++ b/tests/qemuxmlnstest.c @@ -108,9 +108,8 @@ static int testCompareXMLToArgvFiles(const char *xml, virResetLastError(); if (vmdef->os.arch == VIR_ARCH_X86_64 || - vmdef->os.arch == VIR_ARCH_I686) { + vmdef->os.arch == VIR_ARCH_I686) virQEMUCapsSet(extraFlags, QEMU_CAPS_PCI_MULTIBUS); - } if (qemuAssignDeviceAliases(vmdef, extraFlags) < 0) goto fail; diff --git a/tests/secretxml2xmltest.c b/tests/secretxml2xmltest.c index c9d879e..769e886 100644 --- a/tests/secretxml2xmltest.c +++ b/tests/secretxml2xmltest.c @@ -61,9 +61,8 @@ testCompareXMLToXMLHelper(const void *data) virAsprintf(&outxml, "%s/secretxml2xml%s/%s.xml", abs_srcdir, info->different ? "out" : "in", - info->name) < 0) { + info->name) < 0) goto cleanup; - } result = testCompareXMLToXMLFiles(inxml, outxml); diff --git a/tests/securityselinuxlabeltest.c b/tests/securityselinuxlabeltest.c index 455eb74..8106c77 100644 --- a/tests/securityselinuxlabeltest.c +++ b/tests/securityselinuxlabeltest.c @@ -120,9 +120,8 @@ testSELinuxLoadFileList(const char *testname, abs_srcdir, testname) < 0) goto cleanup; - if (!(fp = fopen(path, "r"))) { + if (!(fp = fopen(path, "r"))) goto cleanup; - } if (VIR_ALLOC_N(line, 1024) < 0) goto cleanup; @@ -191,9 +190,8 @@ testSELinuxLoadDef(const char *testname) abs_srcdir, testname) < 0) goto cleanup; - if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0) { + if (virFileReadAll(xmlfile, 1024*1024, &xmlstr) < 0) goto cleanup; - } if (!(def = virDomainDefParseString(xmlstr, caps, xmlopt, QEMU_EXPECTED_VIRT_TYPES, diff --git a/tests/sexpr2xmltest.c b/tests/sexpr2xmltest.c index 7247414..4ed1d4d 100644 --- a/tests/sexpr2xmltest.c +++ b/tests/sexpr2xmltest.c @@ -102,9 +102,8 @@ testCompareHelper(const void *data) if (virAsprintf(&xml, "%s/sexpr2xmldata/sexpr2xml-%s.xml", abs_srcdir, info->input) < 0 || virAsprintf(&args, "%s/sexpr2xmldata/sexpr2xml-%s.sexpr", - abs_srcdir, info->output) < 0) { + abs_srcdir, info->output) < 0) goto cleanup; - } result = testCompareFiles(xml, args, info->version); diff --git a/tests/shunloadtest.c b/tests/shunloadtest.c index 80f5351..37d990d 100644 --- a/tests/shunloadtest.c +++ b/tests/shunloadtest.c @@ -74,9 +74,8 @@ static void *threadMain(void *arg) pthread_cond_signal(&cond); } - while (!quit) { + while (!quit) pthread_cond_wait(&cond, &lock); - } pthread_mutex_unlock(&lock); return NULL; @@ -126,9 +125,8 @@ int main(int argc ATTRIBUTE_UNUSED, char **argv) /* Wait for the thread to start and call libvirt */ pthread_mutex_lock(&lock); - while (!running && !failstart) { + while (!running && !failstart) pthread_cond_wait(&cond, &lock); - } /* Close the shared library (and thus make libvirt.so * non-resident */ diff --git a/tests/storagepoolxml2xmltest.c b/tests/storagepoolxml2xmltest.c index 8a2c0b5..d3fc0fe 100644 --- a/tests/storagepoolxml2xmltest.c +++ b/tests/storagepoolxml2xmltest.c @@ -61,9 +61,8 @@ testCompareXMLToXMLHelper(const void *data) if (virAsprintf(&inxml, "%s/storagepoolxml2xmlin/%s.xml", abs_srcdir, (const char*)data) < 0 || virAsprintf(&outxml, "%s/storagepoolxml2xmlout/%s.xml", - abs_srcdir, (const char*)data) < 0) { + abs_srcdir, (const char*)data) < 0) goto cleanup; - } result = testCompareXMLToXMLFiles(inxml, outxml); diff --git a/tests/storagevolxml2argvtest.c b/tests/storagevolxml2argvtest.c index f9d2d2d..b3daee6 100644 --- a/tests/storagevolxml2argvtest.c +++ b/tests/storagevolxml2argvtest.c @@ -169,9 +169,8 @@ testCompareXMLToArgvHelper(const void *data) if (virAsprintf(&poolxml, "%s/storagepoolxml2xmlin/%s.xml", abs_srcdir, info->pool) < 0 || virAsprintf(&volxml, "%s/storagevolxml2xmlin/%s.xml", - abs_srcdir, info->vol) < 0) { + abs_srcdir, info->vol) < 0) goto cleanup; - } if (virAsprintf(&cmdline, "%s/storagevolxml2argvdata/%s.argv", abs_srcdir, info->cmdline) < 0 && !info->shouldFail) goto cleanup; diff --git a/tests/storagevolxml2xmltest.c b/tests/storagevolxml2xmltest.c index 234a2f1..848f80b 100644 --- a/tests/storagevolxml2xmltest.c +++ b/tests/storagevolxml2xmltest.c @@ -80,9 +80,8 @@ testCompareXMLToXMLHelper(const void *data) virAsprintf(&inxml, "%s/storagevolxml2xmlin/%s.xml", abs_srcdir, info->name) < 0 || virAsprintf(&outxml, "%s/storagevolxml2xmlout/%s.xml", - abs_srcdir, info->name) < 0) { + abs_srcdir, info->name) < 0) goto cleanup; - } result = testCompareXMLToXMLFiles(poolxml, inxml, outxml); diff --git a/tests/sysinfotest.c b/tests/sysinfotest.c index 5ba3298..a33f0dd 100644 --- a/tests/sysinfotest.c +++ b/tests/sysinfotest.c @@ -72,9 +72,8 @@ testSysinfo(const void *data) if (!testdata->expected || virtTestLoadFile(testdata->expected, &sysfsExpectData) < 0 || - !(ret = virSysinfoRead())) { + !(ret = virSysinfoRead())) goto cleanup; - } if (virSysinfoFormat(&buf, ret) < 0) goto cleanup; @@ -114,9 +113,8 @@ sysinfotest_run(const char *test, (cpuinfo && virAsprintf(&testdata.cpuinfo, "%s/%s", abs_srcdir, cpuinfo) < 0) || (expected && - virAsprintf(&testdata.expected, "%s/%s", abs_srcdir, expected) < 0)) { + virAsprintf(&testdata.expected, "%s/%s", abs_srcdir, expected) < 0)) goto error; - } if (virtTestRun(test, testSysinfo, &testdata) < 0) goto error; diff --git a/tests/utiltest.c b/tests/utiltest.c index 89e82aa..8950cf2 100644 --- a/tests/utiltest.c +++ b/tests/utiltest.c @@ -124,9 +124,8 @@ testParseVersionString(const void *data ATTRIBUTE_UNUSED) return -1; } - if (result < 0) { + if (result < 0) continue; - } if (version != versions[i].version) { if (virTestGetDebug() > 0) { diff --git a/tests/virbuftest.c b/tests/virbuftest.c index 2398890..554a8c0 100644 --- a/tests/virbuftest.c +++ b/tests/virbuftest.c @@ -38,9 +38,8 @@ static int testBufInfiniteLoop(const void *data) * which was the case after the above addchar at the time of the bug. * This test is a bit fragile, since it relies on virBuffer internals. */ - if (virAsprintf(&addstr, "%*s", buf->a - buf->b - 1, "a") < 0) { + if (virAsprintf(&addstr, "%*s", buf->a - buf->b - 1, "a") < 0) goto out; - } if (info->doEscape) virBufferEscapeString(buf, "%s", addstr); diff --git a/tests/virhashtest.c b/tests/virhashtest.c index 340dc84..6373eb4 100644 --- a/tests/virhashtest.c +++ b/tests/virhashtest.c @@ -344,24 +344,20 @@ testHashForEachIter(void *payload ATTRIBUTE_UNUSED, virHashTablePtr hash = data; if (virHashAddEntry(hash, uuids_new[0], NULL) == 0 && - virTestGetVerbose()) { + virTestGetVerbose()) fprintf(stderr, "\nadding entries in ForEach should be forbidden"); - } if (virHashUpdateEntry(hash, uuids_new[0], NULL) == 0 && - virTestGetVerbose()) { + virTestGetVerbose()) fprintf(stderr, "\nupdating entries in ForEach should be forbidden"); - } if (virHashSteal(hash, uuids_new[0]) != NULL && - virTestGetVerbose()) { + virTestGetVerbose()) fprintf(stderr, "\nstealing entries in ForEach should be forbidden"); - } if (virHashSteal(hash, uuids_new[0]) != NULL && - virTestGetVerbose()) { + virTestGetVerbose()) fprintf(stderr, "\nstealing entries in ForEach should be forbidden"); - } if (virHashForEach(hash, testHashIter, NULL) >= 0 && virTestGetVerbose()) { @@ -531,17 +527,15 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED) virHashAddEntry(hash, keya, value3) < 0 || virHashAddEntry(hash, keyc, value1) < 0 || virHashAddEntry(hash, keyb, value2) < 0) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to create hash"); - } goto cleanup; } if (!(array = virHashGetItems(hash, NULL)) || array[3].key || array[3].value) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to get items with NULL sort"); - } goto cleanup; } VIR_FREE(array); @@ -554,9 +548,8 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED) STRNEQ(array[2].key, "c") || STRNEQ(array[2].value, "1") || array[3].key || array[3].value) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to get items with key sort"); - } goto cleanup; } VIR_FREE(array); @@ -569,9 +562,8 @@ testHashGetItems(const void *data ATTRIBUTE_UNUSED) STRNEQ(array[2].key, "a") || STRNEQ(array[2].value, "3") || array[3].key || array[3].value) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to get items with value sort"); - } goto cleanup; } @@ -612,44 +604,38 @@ testHashEqual(const void *data ATTRIBUTE_UNUSED) virHashAddEntry(hash1, keyc, value3_l) < 0 || virHashAddEntry(hash2, keya, value1_u) < 0 || virHashAddEntry(hash2, keyb, value2_u) < 0) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to create hashes"); - } goto cleanup; } if (virHashEqual(hash1, hash2, testHashEqualCompValue)) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed equal test for different number of elements"); - } goto cleanup; } if (virHashAddEntry(hash2, keyc, value4_u) < 0) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to add element to hash2"); - } goto cleanup; } if (virHashEqual(hash1, hash2, testHashEqualCompValue)) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed equal test for same number of elements"); - } goto cleanup; } if (virHashUpdateEntry(hash2, keyc, value3_u) < 0) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed to update element in hash2"); - } goto cleanup; } if (!virHashEqual(hash1, hash2, testHashEqualCompValue)) { - if (virTestGetVerbose()) { + if (virTestGetVerbose()) testError("\nfailed equal test for equal hash tables"); - } goto cleanup; } diff --git a/tests/virtimetest.c b/tests/virtimetest.c index 64bf19b..9ab38ae 100644 --- a/tests/virtimetest.c +++ b/tests/virtimetest.c @@ -88,9 +88,8 @@ testTimeLocalOffset(const void *args) } tzset(); - if (virTimeLocalOffsetFromUTC(&actual) < 0) { + if (virTimeLocalOffsetFromUTC(&actual) < 0) return -1; - } if (data->offset != actual) { VIR_DEBUG("Expect Offset %ld got %ld\n", diff --git a/tests/vmx2xmltest.c b/tests/vmx2xmltest.c index 5c103dd..375bc27 100644 --- a/tests/vmx2xmltest.c +++ b/tests/vmx2xmltest.c @@ -27,9 +27,8 @@ testCapsInit(void) caps = virCapabilitiesNew(VIR_ARCH_I686, true, true); - if (caps == NULL) { + if (caps == NULL) return; - } virCapabilitiesAddHostMigrateTransport(caps, "esx"); @@ -39,14 +38,12 @@ testCapsInit(void) VIR_ARCH_I686, NULL, NULL, 0, NULL); - if (guest == NULL) { + if (guest == NULL) goto failure; - } if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, - NULL) == NULL) { + NULL) == NULL) goto failure; - } /* x86_64 guest */ guest = @@ -54,14 +51,12 @@ testCapsInit(void) VIR_ARCH_X86_64, NULL, NULL, 0, NULL); - if (guest == NULL) { + if (guest == NULL) goto failure; - } if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, - NULL) == NULL) { + NULL) == NULL) goto failure; - } return; @@ -128,9 +123,8 @@ testCompareHelper(const void *data) if (virAsprintf(&vmx, "%s/vmx2xmldata/vmx2xml-%s.vmx", abs_srcdir, info->input) < 0 || virAsprintf(&xml, "%s/vmx2xmldata/vmx2xml-%s.xml", abs_srcdir, - info->output) < 0) { + info->output) < 0) goto cleanup; - } ret = testCompareFiles(vmx, xml); @@ -159,9 +153,8 @@ testParseVMXFileName(const char *fileName, void *opaque ATTRIBUTE_UNUSED) /* Expected format: '/vmfs/volumes/<datastore>/<path>' */ if ((tmp = STRSKIP(copyOfFileName, "/vmfs/volumes/")) == NULL || (datastoreName = strtok_r(tmp, "/", &saveptr)) == NULL || - (directoryAndFileName = strtok_r(NULL, "", &saveptr)) == NULL) { + (directoryAndFileName = strtok_r(NULL, "", &saveptr)) == NULL) goto cleanup; - } if (virAsprintf(&src, "[%s] %s", datastoreName, directoryAndFileName) < 0) @@ -201,9 +194,8 @@ mymain(void) testCapsInit(); - if (caps == NULL) { + if (caps == NULL) return EXIT_FAILURE; - } if (!(xmlopt = virVMXDomainXMLConfInit())) return EXIT_FAILURE; diff --git a/tests/xml2sexprtest.c b/tests/xml2sexprtest.c index 7d9e780..b74f00b 100644 --- a/tests/xml2sexprtest.c +++ b/tests/xml2sexprtest.c @@ -82,9 +82,8 @@ testCompareHelper(const void *data) if (virAsprintf(&xml, "%s/xml2sexprdata/xml2sexpr-%s.xml", abs_srcdir, info->input) < 0 || virAsprintf(&args, "%s/xml2sexprdata/xml2sexpr-%s.sexpr", - abs_srcdir, info->output) < 0) { + abs_srcdir, info->output) < 0) goto cleanup; - } result = testCompareFiles(xml, args, info->version); diff --git a/tests/xml2vmxtest.c b/tests/xml2vmxtest.c index 58418dc..17b2520 100644 --- a/tests/xml2vmxtest.c +++ b/tests/xml2vmxtest.c @@ -27,9 +27,8 @@ testCapsInit(void) caps = virCapabilitiesNew(VIR_ARCH_I686, true, true); - if (caps == NULL) { + if (caps == NULL) return; - } virCapabilitiesAddHostMigrateTransport(caps, "esx"); @@ -40,14 +39,12 @@ testCapsInit(void) VIR_ARCH_I686, NULL, NULL, 0, NULL); - if (guest == NULL) { + if (guest == NULL) goto failure; - } if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, - NULL) == NULL) { + NULL) == NULL) goto failure; - } /* x86_64 guest */ guest = @@ -55,14 +52,12 @@ testCapsInit(void) VIR_ARCH_X86_64, NULL, NULL, 0, NULL); - if (guest == NULL) { + if (guest == NULL) goto failure; - } if (virCapabilitiesAddGuestDomain(guest, "vmware", NULL, NULL, 0, - NULL) == NULL) { + NULL) == NULL) goto failure; - } return; @@ -81,21 +76,18 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) char *formatted = NULL; virDomainDefPtr def = NULL; - if (virtTestLoadFile(xml, &xmlData) < 0) { + if (virtTestLoadFile(xml, &xmlData) < 0) goto failure; - } - if (virtTestLoadFile(vmx, &vmxData) < 0) { + if (virtTestLoadFile(vmx, &vmxData) < 0) goto failure; - } def = virDomainDefParseString(xmlData, caps, xmlopt, 1 << VIR_DOMAIN_VIRT_VMWARE, VIR_DOMAIN_XML_INACTIVE); - if (def == NULL) { + if (def == NULL) goto failure; - } if (!virDomainDefCheckABIStability(def, def)) { fprintf(stderr, "ABI stability check failed on %s", xml); @@ -104,9 +96,8 @@ testCompareFiles(const char *xml, const char *vmx, int virtualHW_version) formatted = virVMXFormatConfig(&ctx, xmlopt, def, virtualHW_version); - if (formatted == NULL) { + if (formatted == NULL) goto failure; - } if (STRNEQ(vmxData, formatted)) { virtTestDifference(stderr, vmxData, formatted); @@ -141,9 +132,8 @@ testCompareHelper(const void *data) if (virAsprintf(&xml, "%s/xml2vmxdata/xml2vmx-%s.xml", abs_srcdir, info->input) < 0 || virAsprintf(&vmx, "%s/xml2vmxdata/xml2vmx-%s.vmx", abs_srcdir, - info->output) < 0) { + info->output) < 0) goto cleanup; - } result = testCompareFiles(xml, vmx, info->virtualHW_version); @@ -181,9 +171,8 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) /* Expected format: '[<datastore>] <path>' where <path> is optional */ if ((tmp = STRSKIP(copyOfDatastorePath, "[")) == NULL || *tmp == ']' || - (datastoreName = strtok_r(tmp, "]", &saveptr)) == NULL) { + (datastoreName = strtok_r(tmp, "]", &saveptr)) == NULL) goto cleanup; - } directoryAndFileName = strtok_r(NULL, "", &saveptr); @@ -207,9 +196,8 @@ testFormatVMXFileName(const char *src, void *opaque ATTRIBUTE_UNUSED) success = true; cleanup: - if (! success) { + if (! success) VIR_FREE(absolutePath); - } VIR_FREE(copyOfDatastorePath); @@ -233,9 +221,8 @@ mymain(void) testCapsInit(); - if (caps == NULL) { + if (caps == NULL) return EXIT_FAILURE; - } if (!(xmlopt = virVMXDomainXMLConfInit())) return EXIT_FAILURE; -- 2.1.3

As stated in our contributor guidelines, we don't want curly brackets around oneline code block (with some exceptions). Signed-off-by: Martin Kletzander <mkletzan@redhat.com> --- daemon/libvirtd.c | 15 +++++---------- daemon/remote.c | 15 +++++---------- examples/object-events/event-test.c | 3 +-- examples/openauth/openauth.c | 9 +++------ tools/virsh-console.c | 15 +++++---------- tools/virsh-domain.c | 30 ++++++++++-------------------- tools/virsh-edit.c | 6 ++---- tools/virsh-host.c | 3 +-- tools/virsh-interface.c | 6 ++---- tools/virsh-pool.c | 6 ++---- tools/virsh-volume.c | 15 +++++---------- tools/virsh.c | 18 ++++++------------ tools/wireshark/src/packet-libvirt.c | 6 ++---- 13 files changed, 49 insertions(+), 98 deletions(-) diff --git a/daemon/libvirtd.c b/daemon/libvirtd.c index 1864bfd..b7f82c5 100644 --- a/daemon/libvirtd.c +++ b/daemon/libvirtd.c @@ -981,9 +981,8 @@ static int migrateProfile(void) if (!(home = virGetUserDirectory())) goto cleanup; - if (virAsprintf(&old_base, "%s/.libvirt", home) < 0) { + if (virAsprintf(&old_base, "%s/.libvirt", home) < 0) goto cleanup; - } /* if the new directory is there or the old one is not: do nothing */ if (!(config_dir = virGetUserConfigDirectory())) @@ -998,21 +997,18 @@ static int migrateProfile(void) } /* test if we already attempted to migrate first */ - if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0) { + if (virAsprintf(&updated, "%s/DEPRECATED-DIRECTORY", old_base) < 0) goto cleanup; - } - if (virFileExists(updated)) { + if (virFileExists(updated)) goto cleanup; - } config_home = virGetEnvBlockSUID("XDG_CONFIG_HOME"); if (config_home && config_home[0] != '\0') { if (VIR_STRDUP(xdg_dir, config_home) < 0) goto cleanup; } else { - if (virAsprintf(&xdg_dir, "%s/.config", home) < 0) { + if (virAsprintf(&xdg_dir, "%s/.config", home) < 0) goto cleanup; - } } old_umask = umask(077); @@ -1164,9 +1160,8 @@ int main(int argc, char **argv) { c = getopt_long(argc, argv, "ldf:p:t:vVh", opts, &optidx); - if (c == -1) { + if (c == -1) break; - } switch (c) { case 0: diff --git a/daemon/remote.c b/daemon/remote.c index c93c97a..54819a1 100644 --- a/daemon/remote.c +++ b/daemon/remote.c @@ -500,9 +500,8 @@ remoteRelayDomainEventGraphics(virConnectPtr conn, authScheme, callback->callbackID); VIR_DEBUG("Subject %d", subject->nidentity); - for (i = 0; i < subject->nidentity; i++) { + for (i = 0; i < subject->nidentity; i++) VIR_DEBUG(" %s=%s", subject->identities[i].type, subject->identities[i].name); - } /* build return data */ memset(&data, 0, sizeof(data)); @@ -3255,9 +3254,8 @@ remoteDispatchAuthPolkit(virNetServerPtr server, } if (virNetServerClientGetUNIXIdentity(client, &callerUid, &callerGid, - &callerPid, ×tamp) < 0) { + &callerPid, ×tamp) < 0) goto authfail; - } if (timestamp == 0) { VIR_WARN("Failing polkit auth due to missing client (pid=%lld) start time", @@ -4268,9 +4266,8 @@ remoteDispatchDomainOpenGraphicsFd(virNetServerPtr server ATTRIBUTE_UNUSED, cleanup: VIR_FORCE_CLOSE(fd); - if (rv < 0) { + if (rv < 0) virNetMessageSaveError(rerr); - } if (dom) virDomainFree(dom); @@ -5689,9 +5686,8 @@ remoteDispatchDomainCreateXMLWithFiles(virNetServerPtr server ATTRIBUTE_UNUSED, rv = 0; cleanup: - for (i = 0; i < nfiles; i++) { + for (i = 0; i < nfiles; i++) VIR_FORCE_CLOSE(files[i]); - } VIR_FREE(files); if (rv < 0) virNetMessageSaveError(rerr); @@ -5741,9 +5737,8 @@ static int remoteDispatchDomainCreateWithFiles(virNetServerPtr server ATTRIBUTE_ rv = 0; cleanup: - for (i = 0; i < nfiles; i++) { + for (i = 0; i < nfiles; i++) VIR_FORCE_CLOSE(files[i]); - } VIR_FREE(files); if (rv < 0) virNetMessageSaveError(rerr); diff --git a/examples/object-events/event-test.c b/examples/object-events/event-test.c index 0c6faf4..8987ee5 100644 --- a/examples/object-events/event-test.c +++ b/examples/object-events/event-test.c @@ -730,9 +730,8 @@ int main(int argc, char **argv) virConnectUnregisterCloseCallback(dconn, connectClose); VIR_DEBUG("Closing connection"); - if (dconn && virConnectClose(dconn) < 0) { + if (dconn && virConnectClose(dconn) < 0) printf("error closing\n"); - } printf("done\n"); return 0; diff --git a/examples/openauth/openauth.c b/examples/openauth/openauth.c index fae96e0..0be977e 100644 --- a/examples/openauth/openauth.c +++ b/examples/openauth/openauth.c @@ -132,9 +132,8 @@ showDomains(virConnectPtr conn) goto out; } - if (numNames > 0) { + if (numNames > 0) printf("Inactive domains:\n"); - } for (i = 0; i < numNames; i++) { printf(" %s\n", *(nameList + i)); @@ -181,9 +180,8 @@ authCallback(virConnectCredentialPtr cred, unsigned int ncred, void *cbdata) case VIR_CRED_AUTHNAME: cred[i].result = strdup(authData->username); - if (cred[i].result == NULL) { + if (cred[i].result == NULL) return -1; - } cred[i].resultlen = strlen(cred[i].result); break; @@ -191,9 +189,8 @@ authCallback(virConnectCredentialPtr cred, unsigned int ncred, void *cbdata) case VIR_CRED_PASSPHRASE: cred[i].result = strdup(authData->password); - if (cred[i].result == NULL) { + if (cred[i].result == NULL) return -1; - } cred[i].resultlen = strlen(cred[i].result); break; diff --git a/tools/virsh-console.c b/tools/virsh-console.c index c245df7..656c646 100644 --- a/tools/virsh-console.c +++ b/tools/virsh-console.c @@ -190,9 +190,8 @@ virConsoleEventOnStream(virStreamPtr st, VIR_STREAM_EVENT_READABLE); if (events & VIR_STREAM_EVENT_ERROR || - events & VIR_STREAM_EVENT_HANGUP) { + events & VIR_STREAM_EVENT_HANGUP) virConsoleShutdown(con); - } } @@ -224,9 +223,8 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED, con->terminalToStream.offset, avail); if (got < 0) { - if (errno != EAGAIN) { + if (errno != EAGAIN) virConsoleShutdown(con); - } return; } if (got == 0) { @@ -246,9 +244,8 @@ virConsoleEventOnStdin(int watch ATTRIBUTE_UNUSED, } if (events & VIR_EVENT_HANDLE_ERROR || - events & VIR_EVENT_HANDLE_HANGUP) { + events & VIR_EVENT_HANDLE_HANGUP) virConsoleShutdown(con); - } } @@ -268,9 +265,8 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED, con->streamToTerminal.data, con->streamToTerminal.offset); if (done < 0) { - if (errno != EAGAIN) { + if (errno != EAGAIN) virConsoleShutdown(con); - } return; } memmove(con->streamToTerminal.data, @@ -290,9 +286,8 @@ virConsoleEventOnStdout(int watch ATTRIBUTE_UNUSED, virEventUpdateHandle(con->stdoutWatch, 0); if (events & VIR_EVENT_HANDLE_ERROR || - events & VIR_EVENT_HANDLE_HANGUP) { + events & VIR_EVENT_HANDLE_HANGUP) virConsoleShutdown(con); - } } diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index bd5f404..60a33f8 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -161,9 +161,8 @@ vshNodeGetCPUCount(virConnectPtr conn) if ((ret = virNodeGetCPUMap(conn, NULL, NULL, 0)) < 0) { /* fall back to nodeinfo */ vshResetLibvirtError(); - if (virNodeGetInfo(conn, &nodeinfo) == 0) { + if (virNodeGetInfo(conn, &nodeinfo) == 0) ret = VIR_NODEINFO_MAXCPUS(nodeinfo); - } } return ret; } @@ -3327,9 +3326,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) flags |= VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA; snapshots_safe = true; } - if (nvram) { + if (nvram) flags |= VIR_DOMAIN_UNDEFINE_NVRAM; - } if (!(dom = vshCommandOptDomain(ctl, cmd, &name))) return false; @@ -3379,9 +3377,8 @@ cmdUndefine(vshControl *ctl, const vshCmd *cmd) flags &= ~VIR_DOMAIN_UNDEFINE_MANAGED_SAVE; managed_save_safe = true; } - if (has_snapshots == 0) { + if (has_snapshots == 0) snapshots_safe = true; - } if (has_snapshots_metadata == 0) { flags &= ~VIR_DOMAIN_UNDEFINE_SNAPSHOTS_METADATA; snapshots_safe = true; @@ -6061,9 +6058,8 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen, int cpu, lastcpu; bool bit, lastbit, isInvert; - if (!cpumaps || cpumaplen <= 0 || maxcpu <= 0 || vcpuindex < 0) { + if (!cpumaps || cpumaplen <= 0 || maxcpu <= 0 || vcpuindex < 0) return false; - } bit = lastbit = isInvert = false; lastcpu = -1; @@ -6083,9 +6079,8 @@ vshPrintPinInfo(unsigned char *cpumaps, size_t cpumaplen, vshPrint(ctl, "-%d", cpu - 1); lastbit = bit; } - if (bit && !isInvert) { + if (bit && !isInvert) vshPrint(ctl, "-%d", maxcpu - 1); - } return true; } @@ -6242,9 +6237,8 @@ cmdVcpuPin(vshControl *ctl, const vshCmd *cmd) goto cleanup; } - if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) { + if ((maxcpu = vshNodeGetCPUCount(ctl->conn)) < 0) goto cleanup; - } cpumaplen = VIR_CPU_MAPLEN(maxcpu); @@ -7809,13 +7803,11 @@ cmdSetmem(vshControl *ctl, const vshCmd *cmd) kibibytes = VIR_DIV_UP(bytes, 1024); if (flags == -1) { - if (virDomainSetMemory(dom, kibibytes) != 0) { + if (virDomainSetMemory(dom, kibibytes) != 0) ret = false; - } } else { - if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) { + if (virDomainSetMemoryFlags(dom, kibibytes, flags) < 0) ret = false; - } } virDomainFree(dom); @@ -9369,9 +9361,8 @@ doMigrate(void *opaque) if (vshCommandOptBool(cmd, "rdma-pin-all")) flags |= VIR_MIGRATE_RDMA_PIN_ALL; - if (vshCommandOptBool(cmd, "offline")) { + if (vshCommandOptBool(cmd, "offline")) flags |= VIR_MIGRATE_OFFLINE; - } if (vshCommandOptBool(cmd, "abort-on-error")) flags |= VIR_MIGRATE_ABORT_ON_ERROR; @@ -10034,9 +10025,8 @@ cmdTTYConsole(vshControl *ctl, const vshCmd *cmd) obj = xmlXPathEval(BAD_CAST "string(/domain/devices/console/@tty)", ctxt); if (obj == NULL || obj->type != XPATH_STRING || - obj->stringval == NULL || obj->stringval[0] == 0) { + obj->stringval == NULL || obj->stringval[0] == 0) goto cleanup; - } vshPrint(ctl, "%s\n", (const char *)obj->stringval); ret = true; diff --git a/tools/virsh-edit.c b/tools/virsh-edit.c index 10298f6..41a6d53 100644 --- a/tools/virsh-edit.c +++ b/tools/virsh-edit.c @@ -85,9 +85,8 @@ do { goto edit_cleanup; /* Compare original XML with edited. Has it changed at all? */ - if (STREQ(doc, doc_edited)) { + if (STREQ(doc, doc_edited)) EDIT_NOT_CHANGED; - } redefine: msg = NULL; @@ -109,9 +108,8 @@ do { } /* Everything checks out, so redefine the object. */ - if (!msg && !(EDIT_DEFINE)) { + if (!msg && !(EDIT_DEFINE)) msg = _("Failed."); - } if (msg) { int c = vshAskReedit(ctl, msg); diff --git a/tools/virsh-host.c b/tools/virsh-host.c index 4a3ff28..8afffc8 100644 --- a/tools/virsh-host.c +++ b/tools/virsh-host.c @@ -376,9 +376,8 @@ cmdFreepages(vshControl *ctl, const vshCmd *cmd) goto cleanup; vshPrint(ctl, _("Node %d:\n"), cell); - for (j = 0; j < npages; j++) { + for (j = 0; j < npages; j++) vshPrint(ctl, "%uKiB: %lld\n", pagesize[j], counts[j]); - } vshPrint(ctl, "%c", '\n'); } diff --git a/tools/virsh-interface.c b/tools/virsh-interface.c index 6cacaf1..c429fc7 100644 --- a/tools/virsh-interface.c +++ b/tools/virsh-interface.c @@ -824,9 +824,8 @@ cmdInterfaceBridge(vshControl *ctl, const vshCmd *cmd) /* Get a handle to the original device */ if (!(if_handle = vshCommandOptInterfaceBy(ctl, cmd, "interface", - &if_name, VSH_BYNAME))) { + &if_name, VSH_BYNAME))) goto cleanup; - } /* Name for new bridge device */ if (vshCommandOptStringReq(ctl, cmd, "bridge", &br_name) < 0) @@ -1046,9 +1045,8 @@ cmdInterfaceUnbridge(vshControl *ctl, const vshCmd *cmd) /* Get a handle to the original device */ if (!(br_handle = vshCommandOptInterfaceBy(ctl, cmd, "bridge", - &br_name, VSH_BYNAME))) { + &br_name, VSH_BYNAME))) goto cleanup; - } nostart = vshCommandOptBool(cmd, "no-start"); diff --git a/tools/virsh-pool.c b/tools/virsh-pool.c index 0b8dba5..a05608b 100644 --- a/tools/virsh-pool.c +++ b/tools/virsh-pool.c @@ -470,13 +470,11 @@ cmdPoolBuild(vshControl *ctl, const vshCmd *cmd) if (!(pool = vshCommandOptPool(ctl, cmd, "pool", &name))) return false; - if (vshCommandOptBool(cmd, "no-overwrite")) { + if (vshCommandOptBool(cmd, "no-overwrite")) flags |= VIR_STORAGE_POOL_BUILD_NO_OVERWRITE; - } - if (vshCommandOptBool(cmd, "overwrite")) { + if (vshCommandOptBool(cmd, "overwrite")) flags |= VIR_STORAGE_POOL_BUILD_OVERWRITE; - } if (virStoragePoolBuild(pool, flags) == 0) { vshPrint(ctl, _("Pool %s built\n"), name); diff --git a/tools/virsh-volume.c b/tools/virsh-volume.c index 4f810f8..1859aa4 100644 --- a/tools/virsh-volume.c +++ b/tools/virsh-volume.c @@ -687,9 +687,8 @@ cmdVolUpload(vshControl *ctl, const vshCmd *cmd) return false; } - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { + if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) return false; - } if (vshCommandOptStringReq(ctl, cmd, "file", &file) < 0) goto cleanup; @@ -885,9 +884,8 @@ cmdVolDelete(vshControl *ctl, const vshCmd *cmd) bool ret = true; const char *name; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { + if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) return false; - } if (virStorageVolDelete(vol, 0) == 0) { vshPrint(ctl, _("Vol %s deleted\n"), name); @@ -945,9 +943,8 @@ cmdVolWipe(vshControl *ctl, const vshCmd *cmd) int algorithm = VIR_STORAGE_VOL_WIPE_ALG_ZERO; int funcRet; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) { + if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", &name))) return false; - } if (vshCommandOptStringReq(ctl, cmd, "algorithm", &algorithm_str) < 0) goto out; @@ -1642,9 +1639,8 @@ cmdVolPool(vshControl *ctl, const vshCmd *cmd) /* Use the supplied string to locate the volume */ if (!(vol = vshCommandOptVolBy(ctl, cmd, "vol", NULL, NULL, - VSH_BYUUID))) { + VSH_BYUUID))) return false; - } /* Look up the parent storage pool for the volume */ pool = virStoragePoolLookupByVolume(vol); @@ -1741,9 +1737,8 @@ cmdVolPath(vshControl *ctl, const vshCmd *cmd) virStorageVolPtr vol; char * StorageVolPath; - if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) { + if (!(vol = vshCommandOptVol(ctl, cmd, "vol", "pool", NULL))) return false; - } if ((StorageVolPath = virStorageVolGetPath(vol)) == NULL) { virStorageVolFree(vol); diff --git a/tools/virsh.c b/tools/virsh.c index 036b517..eb648bd 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -499,9 +499,8 @@ vshPrintRaw(vshControl *ctl, ...) char *key; va_start(ap, ctl); - while ((key = va_arg(ap, char *)) != NULL) { + while ((key = va_arg(ap, char *)) != NULL) vshPrint(ctl, "%s\r\n", key); - } va_end(ap); } @@ -874,9 +873,8 @@ cmdCd(vshControl *ctl, const vshCmd *cmd) return false; } - if (vshCommandOptString(cmd, "dir", &dir) <= 0) { + if (vshCommandOptString(cmd, "dir", &dir) <= 0) dir = dir_malloced = virGetUserDirectory(); - } if (!dir) dir = "/"; @@ -1136,9 +1134,8 @@ vshCmddefGetOption(vshControl *ctl, const vshCmdDef *cmd, const char *name, const vshCmdOptDef *ret = NULL; char *alias = NULL; - if (STREQ(name, helpopt.name)) { + if (STREQ(name, helpopt.name)) return &helpopt; - } for (i = 0; cmd->opts && cmd->opts[i].name; i++) { const vshCmdOptDef *opt = &cmd->opts[i]; @@ -1642,9 +1639,8 @@ vshCommandOptString(const vshCmd *cmd, const char *name, const char **value) if (ret <= 0) return ret; - if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) { + if (!*arg->data && !(arg->def->flags & VSH_OFLAG_EMPTY_OK)) return -1; - } *value = arg->data; return 1; } @@ -1839,9 +1835,8 @@ vshCommandOptArgv(const vshCmd *cmd, const vshCmdOpt *opt) opt = opt ? opt->next : cmd->opts; while (opt) { - if (opt->def->type == VSH_OT_ARGV) { + if (opt->def->type == VSH_OT_ARGV) return opt; - } opt = opt->next; } return NULL; @@ -3703,9 +3698,8 @@ main(int argc, char **argv) else progname++; - if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"))) { + if ((defaultConn = virGetEnvBlockSUID("VIRSH_DEFAULT_CONNECT_URI"))) ctl->name = vshStrdup(ctl, defaultConn); - } vshInitDebug(ctl); diff --git a/tools/wireshark/src/packet-libvirt.c b/tools/wireshark/src/packet-libvirt.c index 5c3c369..f7aa7ed 100644 --- a/tools/wireshark/src/packet-libvirt.c +++ b/tools/wireshark/src/packet-libvirt.c @@ -249,9 +249,8 @@ find_payload_dissector(guint32 proc, guint32 type, first = pds[0].proc; last = pds[length-1].proc; - if (proc < first || proc > last) { + if (proc < first || proc > last) return NULL; - } pd = &pds[proc-first]; /* There is no guarantee to proc numbers has no gap */ @@ -329,9 +328,8 @@ dissect_libvirt_payload_xdr_data(tvbuff_t *tvb, proto_tree *tree, gint payload_l xdr_destroy(&xdrs); g_free(payload_data); - if (nfds != 0) { + if (nfds != 0) dissect_libvirt_fds(tvb, start + payload_length, nfds); - } } static void -- 2.1.3

On 06.11.2014 17:38, Martin Kletzander wrote:
There were unnecessary curly braces in few places (and the whole esx driver), so this series proposes fixing them. As this couldn't be done automatically, there is no syntax-check. We have to keep trying to eliminate that ;)
Martin Kletzander (15): vbox: Remove useless condition branches Remove unneeded curly brackets around oneline code blocks in src/conf/ Remove unneeded curly brackets around oneline code blocks in src/esx/ Remove unneeded curly brackets around oneline code blocks in src/hyperv/ Remove unneeded curly brackets around oneline code blocks in src/node_device/ Remove unneeded curly brackets around oneline code blocks in src/qemu/ Remove unneeded curly brackets around oneline code blocks in src/util/ Remove unneeded curly brackets around oneline code blocks in src/vbox/ Remove unneeded curly brackets around oneline code blocks in src/vmx/ Remove unneeded curly brackets around oneline code blocks in src/[u-z]*/ Remove unneeded curly brackets around oneline code blocks in src/[st]*/ Remove unneeded curly brackets around oneline code blocks in src/[n-r]*/ Remove unneeded curly brackets around oneline code blocks in src/[a-m]*/ Remove unneeded curly brackets around oneline code blocks in tests/ Remove unneeded curly brackets around oneline code blocks
daemon/libvirtd.c | 15 +- daemon/remote.c | 15 +- examples/object-events/event-test.c | 3 +- examples/openauth/openauth.c | 9 +- src/access/viraccessdriverstack.c | 3 +- src/bhyve/bhyve_driver.c | 3 +- src/conf/capabilities.c | 3 +- src/conf/device_conf.c | 6 +- src/conf/domain_conf.c | 203 +++----- src/conf/interface_conf.c | 9 +- src/conf/netdev_vport_profile_conf.c | 12 +- src/conf/network_conf.c | 114 ++-- src/conf/node_device_conf.c | 27 +- src/conf/nwfilter_conf.c | 24 +- src/conf/object_event.c | 6 +- src/conf/storage_conf.c | 30 +- src/cpu/cpu_powerpc.c | 3 +- src/cpu/cpu_x86.c | 3 +- src/datatypes.c | 6 +- src/driver.c | 3 +- src/esx/esx_device_monitor.c | 3 +- src/esx/esx_driver.c | 838 ++++++++++-------------------- src/esx/esx_interface_driver.c | 36 +- src/esx/esx_network_driver.c | 132 ++--- src/esx/esx_nwfilter_driver.c | 3 +- src/esx/esx_secret_driver.c | 3 +- src/esx/esx_storage_backend_iscsi.c | 78 +-- src/esx/esx_storage_backend_vmfs.c | 204 +++----- src/esx/esx_storage_driver.c | 81 +-- src/esx/esx_util.c | 51 +- src/esx/esx_vi.c | 606 +++++++-------------- src/esx/esx_vi_methods.c | 3 +- src/esx/esx_vi_types.c | 54 +- src/hyperv/hyperv_device_monitor.c | 3 +- src/hyperv/hyperv_driver.c | 132 ++--- src/hyperv/hyperv_interface_driver.c | 3 +- src/hyperv/hyperv_network_driver.c | 3 +- src/hyperv/hyperv_nwfilter_driver.c | 3 +- src/hyperv/hyperv_secret_driver.c | 3 +- src/hyperv/hyperv_storage_driver.c | 3 +- src/hyperv/hyperv_util.c | 6 +- src/hyperv/hyperv_wmi.c | 45 +- src/interface/interface_backend_udev.c | 15 +- src/libvirt-domain.c | 6 +- src/libvirt-lxc.c | 3 +- src/libvirt-nodedev.c | 3 +- src/libvirt-storage.c | 6 +- src/libxl/libxl_conf.c | 3 +- src/libxl/libxl_driver.c | 12 +- src/locking/lock_daemon.c | 9 +- src/locking/lock_driver_sanlock.c | 6 +- src/lxc/lxc_container.c | 12 +- src/lxc/lxc_driver.c | 12 +- src/lxc/lxc_process.c | 6 +- src/network/bridge_driver.c | 53 +- src/network/bridge_driver_linux.c | 9 +- src/network/leaseshelper.c | 3 +- src/node_device/node_device_driver.c | 33 +- src/node_device/node_device_hal.c | 6 +- src/node_device/node_device_udev.c | 222 +++----- src/nodeinfo.c | 3 +- src/nwfilter/nwfilter_dhcpsnoop.c | 6 +- src/nwfilter/nwfilter_ebiptables_driver.c | 12 +- src/nwfilter/nwfilter_gentech_driver.c | 12 +- src/nwfilter/nwfilter_learnipaddr.c | 3 +- src/openvz/openvz_conf.c | 3 +- src/openvz/openvz_driver.c | 33 +- src/parallels/parallels_driver.c | 6 +- src/phyp/phyp_driver.c | 21 +- src/qemu/qemu_agent.c | 3 +- src/qemu/qemu_capabilities.c | 15 +- src/qemu/qemu_cgroup.c | 12 +- src/qemu/qemu_command.c | 42 +- src/qemu/qemu_conf.c | 3 +- src/qemu/qemu_domain.c | 9 +- src/qemu/qemu_driver.c | 57 +- src/qemu/qemu_hotplug.c | 42 +- src/qemu/qemu_migration.c | 18 +- src/qemu/qemu_monitor_json.c | 30 +- src/qemu/qemu_monitor_text.c | 9 +- src/qemu/qemu_process.c | 36 +- src/remote/remote_driver.c | 33 +- src/rpc/virnetclient.c | 9 +- src/rpc/virnetserver.c | 3 +- src/rpc/virnetserverclient.c | 3 +- src/rpc/virnetserverservice.c | 3 +- src/security/security_dac.c | 9 +- src/security/security_manager.c | 3 +- src/security/security_selinux.c | 6 +- src/security/virt-aa-helper.c | 15 +- src/storage/parthelper.c | 3 +- src/storage/storage_backend.c | 9 +- src/storage/storage_backend_disk.c | 21 +- src/storage/storage_backend_fs.c | 9 +- src/storage/storage_backend_mpath.c | 30 +- src/storage/storage_backend_rbd.c | 30 +- src/storage/storage_backend_scsi.c | 9 +- src/storage/storage_driver.c | 9 +- src/test/test_driver.c | 66 +-- src/uml/uml_conf.c | 6 +- src/uml/uml_driver.c | 9 +- src/util/virauth.c | 21 +- src/util/virbitmap.c | 6 +- src/util/virbuffer.c | 3 +- src/util/vircgroup.c | 3 +- src/util/vircommand.c | 12 +- src/util/virconf.c | 15 +- src/util/virdbus.c | 6 +- src/util/virdnsmasq.c | 6 +- src/util/vireventpoll.c | 12 +- src/util/virfile.c | 9 +- src/util/virfirewall.c | 6 +- src/util/virhostdev.c | 6 +- src/util/viriscsi.c | 12 +- src/util/virjson.c | 3 +- src/util/virlockspace.c | 6 +- src/util/virlog.c | 6 +- src/util/virnetdev.c | 12 +- src/util/virnetdevbridge.c | 3 +- src/util/virnetdevmacvlan.c | 15 +- src/util/virnetdevtap.c | 9 +- src/util/virnetdevvlan.c | 3 +- src/util/virnetdevvportprofile.c | 6 +- src/util/virpci.c | 33 +- src/util/virsexpr.c | 30 +- src/util/virstorageencryption.c | 3 +- src/util/virstoragefile.c | 6 +- src/util/virsysinfo.c | 3 +- src/util/virthreadpool.c | 9 +- src/util/virutil.c | 12 +- src/util/virxml.c | 18 +- src/vbox/vbox_MSCOMGlue.c | 33 +- src/vbox/vbox_XPCOMCGlue.c | 33 +- src/vbox/vbox_common.c | 77 +-- src/vbox/vbox_network.c | 24 +- src/vbox/vbox_snapshot_conf.c | 21 +- src/vbox/vbox_storage.c | 30 +- src/vbox/vbox_tmpl.c | 30 +- src/vmware/vmware_conf.c | 9 +- src/vmware/vmware_driver.c | 6 +- src/vmx/vmx.c | 369 +++++-------- src/xen/block_stats.c | 3 +- src/xen/xen_driver.c | 6 +- src/xen/xen_hypervisor.c | 12 +- src/xen/xen_inotify.c | 3 +- src/xen/xend_internal.c | 21 +- src/xen/xm_internal.c | 11 +- src/xenapi/xenapi_driver.c | 15 +- src/xenapi/xenapi_utils.c | 15 +- src/xenconfig/xen_common.c | 12 +- src/xenconfig/xen_sxpr.c | 12 +- src/xenconfig/xen_xm.c | 3 +- tests/commandhelper.c | 3 +- tests/esxutilstest.c | 18 +- tests/eventtest.c | 3 +- tests/networkxml2conftest.c | 3 +- tests/networkxml2xmltest.c | 3 +- tests/networkxml2xmlupdatetest.c | 3 +- tests/nodeinfotest.c | 3 +- tests/nwfilterxml2xmltest.c | 3 +- tests/openvzutilstest.c | 9 +- tests/qemuxml2argvtest.c | 6 +- tests/qemuxmlnstest.c | 3 +- tests/secretxml2xmltest.c | 3 +- tests/securityselinuxlabeltest.c | 6 +- tests/sexpr2xmltest.c | 3 +- tests/shunloadtest.c | 6 +- tests/storagepoolxml2xmltest.c | 3 +- tests/storagevolxml2argvtest.c | 3 +- tests/storagevolxml2xmltest.c | 3 +- tests/sysinfotest.c | 6 +- tests/utiltest.c | 3 +- tests/virbuftest.c | 3 +- tests/virhashtest.c | 42 +- tests/virtimetest.c | 3 +- tests/vmx2xmltest.c | 24 +- tests/xml2sexprtest.c | 3 +- tests/xml2vmxtest.c | 39 +- tools/virsh-console.c | 15 +- tools/virsh-domain.c | 30 +- tools/virsh-edit.c | 6 +- tools/virsh-host.c | 3 +- tools/virsh-interface.c | 6 +- tools/virsh-pool.c | 6 +- tools/virsh-volume.c | 15 +- tools/virsh.c | 18 +- tools/wireshark/src/packet-libvirt.c | 6 +- 187 files changed, 1746 insertions(+), 3474 deletions(-)
ACK series. Michal

On 11/06/2014 05:38 PM, Martin Kletzander wrote:
There were unnecessary curly braces in few places (and the whole esx driver), so this series proposes fixing them. As this couldn't be done automatically, there is no syntax-check. We have to keep trying to eliminate that ;)
I'm a little bit worried that without a syntax check, this is just code churn and a conflict magnet that will make it harder to backport patches. I'm not entirely opposed to the idea, but I'm also thinking we should not be applying it without discussion. -- Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On Thu, Nov 06, 2014 at 05:38:25PM +0100, Martin Kletzander wrote:
There were unnecessary curly braces in few places (and the whole esx driver), so this series proposes fixing them. As this couldn't be done automatically, there is no syntax-check. We have to keep trying to eliminate that ;)
How did you go about identifying these places that needed fixing ? I'm assunming you didn't do manual code inspection across everything. While I like the intent, I share Eric's concern about doing this without a syntax-check rule to prevent us re-introducing the problem Regards, Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
participants (5)
-
Daniel P. Berrange
-
Eric Blake
-
Laine Stump
-
Martin Kletzander
-
Michal Privoznik