]> xenbits.xensource.com Git - libvirt.git/commitdiff
conf/network_conf: use virStringParseYesNo helper
authorMao Zhongyi <maozhongyi@cmss.chinamobile.com>
Thu, 17 Oct 2019 03:19:32 +0000 (11:19 +0800)
committerCole Robinson <crobinso@redhat.com>
Thu, 14 Nov 2019 13:14:50 +0000 (08:14 -0500)
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 <crobinso@redhat.com>
Signed-off-by: Mao Zhongyi <maozhongyi@cmss.chinamobile.com>
Signed-off-by: Zhang Shengju <zhangshengju@cmss.chinamobile.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
src/conf/network_conf.c

index bee33fe581ccf2c930529b59bc1f3e86847a6d3f..6970831593a0e35560bd755c1655ddb968bd39ef 100644 (file)
@@ -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);