From: Mao Zhongyi Date: Thu, 17 Oct 2019 03:19:32 +0000 (+0800) Subject: conf/network_conf: use virStringParseYesNo helper X-Git-Url: http://xenbits.xensource.com/gitweb?a=commitdiff_plain;h=5da6615baf72168decc1b331063f8e232657466d;p=libvirt.git conf/network_conf: use virStringParseYesNo helper A function virStringParseYesNo was added to convert string 'yes' to true and 'no' to false, so use this helper to replace 'STREQ(.*, \"yes\")' and 'STREQ(.*, \"no\")' as it allows us to drop several repetitive if-then-else string->bool conversion blocks. Reviewed-by: Cole Robinson Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju Acked-by: Michal Privoznik --- diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c index bee33fe581..6970831593 100644 --- a/src/conf/network_conf.c +++ b/src/conf/network_conf.c @@ -1682,9 +1682,7 @@ virNetworkDefParseXML(xmlXPathContextPtr ctxt, */ ipv6nogwStr = virXPathString("string(./@ipv6)", ctxt); if (ipv6nogwStr) { - if (STREQ(ipv6nogwStr, "yes")) { - def->ipv6nogw = true; - } else if (STRNEQ(ipv6nogwStr, "no")) { + if (virStringParseYesNo(ipv6nogwStr, &def->ipv6nogw) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Invalid ipv6 setting '%s' in network '%s'"), ipv6nogwStr, def->name);