Re: [PATCH 2/3] conf/network_conf: use virStringParseYesNo helper

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 10/16/19 4:39 AM, Mao Zhongyi wrote:
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.

Cc: gene@xxxxxxxxx
Cc: crobinso@xxxxxxxxxx
Cc: berrange@xxxxxxxxxx
Cc: g.sho1500@xxxxxxxxx

Signed-off-by: Mao Zhongyi <maozhongyi@xxxxxxxxxxxxxxxxxxxx>
Signed-off-by: Zhang Shengju <zhangshengju@xxxxxxxxxxxxxxxxxxxx>
---
  src/conf/network_conf.c | 4 +---
  1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/src/conf/network_conf.c b/src/conf/network_conf.c
index 75ec5ccc27..9954c3d25f 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);


ACK

Michal

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux