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@xxxxxxxxxx> --- 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 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list