The else branches are redundant because the execution will never reach them if the conditions in the previous 'if' branches are true. I think this looks cleaner and is more readable, because having 'else' branch indicates that no return / break / goto is in the previous branch and the function can reach it. Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- src/conf/domain_conf.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 26a241db38..41d23cfe2a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -4084,8 +4084,8 @@ virDomainObjGetPersistentDef(virDomainXMLOption *xmlopt, if (domain->newDef) return domain->newDef; - else - return domain->def; + + return domain->def; } @@ -4223,8 +4223,8 @@ virDomainObjGetOneDefState(virDomainObj *vm, if (virDomainObjIsActive(vm) && flags & VIR_DOMAIN_AFFECT_CONFIG) return vm->newDef; - else - return vm->def; + + return vm->def; } @@ -6028,7 +6028,9 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, VIR_XML_PROP_NONZERO, &scsisrc->sgio)) < 0) { return -1; - } else if (rv > 0) { + } + + if (rv > 0) { if (def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { virReportError(VIR_ERR_XML_ERROR, "%s", _("sgio is only supported for scsi host device")); @@ -6040,8 +6042,9 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, VIR_XML_PROP_NONE, &scsisrc->rawio)) < 0) { return -1; - } else if (rv > 0 && - def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { + } + + if (rv > 0 && def->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) { virReportError(VIR_ERR_XML_ERROR, "%s", _("rawio is only supported for scsi host device")); return -1; @@ -9913,9 +9916,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def, ctxt->node = cur; - if ((nsources = virXPathNodeSet("./source", ctxt, &sources)) < 0) { + if ((nsources = virXPathNodeSet("./source", ctxt, &sources)) < 0) goto error; - } else if (nsources > 0) { + + if (nsources > 0) { /* Parse only the first source element since only one is used * for chardev devices, the only exception is UDP type, where * user can specify two source elements. */ @@ -9924,7 +9928,8 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def, _("only one source element is allowed for " "character device")); goto error; - } else if (nsources > 2) { + } + if (nsources > 2) { virReportError(VIR_ERR_XML_ERROR, "%s", _("only two source elements are allowed for " "character device")); @@ -10004,9 +10009,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def, } } - if ((nlogs = virXPathNodeSet("./log", ctxt, &logs)) < 0) { + if ((nlogs = virXPathNodeSet("./log", ctxt, &logs)) < 0) goto error; - } else if (nlogs == 1) { + + if (nlogs == 1) { if (virDomainChrSourceDefParseLog(def, logs[0]) < 0) goto error; } else if (nlogs > 1) { @@ -10016,9 +10022,10 @@ virDomainChrSourceDefParseXML(virDomainChrSourceDef *def, goto error; } - if ((nprotocols = virXPathNodeSet("./protocol", ctxt, &protocols)) < 0) { + if ((nprotocols = virXPathNodeSet("./protocol", ctxt, &protocols)) < 0) goto error; - } else if (nprotocols == 1) { + + if (nprotocols == 1) { if (virDomainChrSourceDefParseProtocol(def, protocols[0]) < 0) goto error; } else if (nprotocols > 1) { -- 2.35.3