Signed-off-by: Martin Kletzander <mklet...@redhat.com> --- src/conf/capabilities.c | 3 +- src/conf/domain_conf.c | 135 +++++++++++++++----------------------------- src/conf/interface_conf.c | 9 +-- src/conf/network_conf.c | 51 ++++++----------- src/conf/node_device_conf.c | 15 ++--- src/conf/nwfilter_conf.c | 12 ++-- src/conf/object_event.c | 6 +- src/conf/storage_conf.c | 24 +++----- 8 files changed, 85 insertions(+), 170 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/domain_conf.c b/src/conf/domain_conf.c index 2c65276..5f4b9f6 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -2008,9 +2008,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); } @@ -2689,9 +2688,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); @@ -4804,9 +4802,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 */ @@ -5081,9 +5078,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); @@ -5187,9 +5183,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; @@ -6143,9 +6138,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 && @@ -8329,9 +8323,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; @@ -9105,9 +9098,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; } } @@ -9243,16 +9235,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); } @@ -10452,9 +10442,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) @@ -10648,9 +10637,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; @@ -11709,9 +11697,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", @@ -13250,9 +13237,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; @@ -13392,9 +13378,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++) { @@ -13408,9 +13393,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++) { @@ -13437,9 +13421,8 @@ virDomainDefParseXML(xmlDocPtr xml, /* 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; @@ -13455,9 +13438,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; @@ -13531,9 +13513,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; @@ -13571,9 +13552,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; @@ -13613,9 +13593,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++) { @@ -13649,9 +13628,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++) { @@ -13666,9 +13644,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++) { @@ -13723,9 +13700,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++) { @@ -13754,9 +13730,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")); @@ -13774,9 +13749,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")); @@ -13824,9 +13798,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", @@ -13842,9 +13815,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++) { @@ -13865,9 +13837,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++) { @@ -13890,9 +13861,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")); @@ -13911,9 +13881,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")); @@ -13930,9 +13899,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; @@ -14106,9 +14074,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) { @@ -15886,9 +15853,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; @@ -16588,9 +16554,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: @@ -17556,9 +17521,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; } @@ -18114,9 +18078,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 @@ -18138,15 +18101,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"); @@ -20536,9 +20496,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; } @@ -20549,9 +20508,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; } @@ -20562,9 +20520,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; } @@ -20575,9 +20532,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; } @@ -20612,9 +20568,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/network_conf.c b/src/conf/network_conf.c index 3bad07d..067334e 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,9 +591,8 @@ 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++) { @@ -1363,9 +1357,8 @@ virNetworkIPDefParseXML(const char *networkName, result = 0; cleanup: - if (result < 0) { + if (result < 0) virNetworkIpDefClear(def); - } VIR_FREE(address); VIR_FREE(netmask); @@ -1589,9 +1582,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); @@ -1663,9 +1655,8 @@ virNetworkPortGroupParseXML(virPortGroupDefPtr def, result = 0; cleanup: - if (result < 0) { + if (result < 0) virPortGroupDefClear(def); - } VIR_FREE(isDefault); VIR_FREE(trustGuestRxFilters); @@ -2483,9 +2474,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 +2490,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 +2569,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 +2587,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 +2596,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 +2610,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 +2688,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 +3310,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++; diff --git a/src/conf/node_device_conf.c b/src/conf/node_device_conf.c index 2a947df..2a609e4 100644 --- a/src/conf/node_device_conf.c +++ b/src/conf/node_device_conf.c @@ -669,9 +669,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"); @@ -841,9 +840,8 @@ virNodeDevCapSCSIHostParseXML(xmlXPathContextPtr ctxt, } } - 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"); @@ -1453,9 +1451,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 +1653,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..074d745 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; @@ -2899,9 +2898,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 +3139,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 +3174,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; 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 1251b47..6ad37f8 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++) @@ -481,9 +479,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) { @@ -833,9 +830,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) { @@ -945,13 +941,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) { @@ -1814,9 +1808,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, @@ -2006,9 +1999,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"); -- 2.1.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list