From nobody Tue Nov 26 13:36:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571282695; cv=none; d=zoho.com; s=zohoarc; b=FkWLp/Q10etEKEPkZbAfx+brrE4QWelfqMMlbLy/M+GcYEhff2K7NQ124EBkigE4HLh6tTFUyv8zk4YWCb3NwuwEmgXOaC2Pa8BBE7QD2+pPXoRgd4SyDxfLyPdZi6dt8YaUQN+29KrYq9eCwslfjxtCFNXtbHP7DMvxs5VvF1U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571282695; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E3/vDPHqWnb2hkfQmCU7V6bhZFauoOhCDA4zVfk5cdI=; b=EotX7VXVitIL2mwcIPzu2E47VDl6xxOmg3r/6JoC8Y6ztdiW92SIi1bEo6vQ8HdulWkLX8PpoabvCgYY+yZR2FjXK76fadD3iwFB4n4Dp34YPjVp8h+wNtx99Y4+1IExDvm/oFPGszfwQW5Gt8uHMS1ecqpsUMkDsVOMVyRa1v0= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571282695568792.0671352186026; Wed, 16 Oct 2019 20:24:55 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E3F958553A; Thu, 17 Oct 2019 03:24:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id B8BE460BE1; Thu, 17 Oct 2019 03:24:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 64EFE4E589; Thu, 17 Oct 2019 03:24:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9H3KMJ8002724 for ; Wed, 16 Oct 2019 23:20:24 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8CA1A6012A; Thu, 17 Oct 2019 03:20:22 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 877B5600C4 for ; Thu, 17 Oct 2019 03:20:20 +0000 (UTC) Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by mx1.redhat.com (Postfix) with ESMTP id A5F40307B19F for ; Thu, 17 Oct 2019 03:20:02 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.5]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75da7ddcc694-b0950; Thu, 17 Oct 2019 11:19:41 +0800 (CST) Received: from localhost.localdomain (unknown[112.25.154.149]) by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee35da7ddc6aab-7fa2c; Thu, 17 Oct 2019 11:19:40 +0800 (CST) X-RM-TRANSID: 2ee75da7ddcc694-b0950 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee35da7ddc6aab-7fa2c From: Mao Zhongyi To: libvir-list@redhat.com Date: Thu, 17 Oct 2019 11:19:31 +0800 Message-Id: <1c2c33e18dba09b05792bf6ff3e47dfc0998a913.1571281133.git.maozhongyi@cmss.chinamobile.com> In-Reply-To: References: In-Reply-To: References: X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 17 Oct 2019 03:20:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 17 Oct 2019 03:20:13 +0000 (UTC) for IP:'221.176.66.80' DOMAIN:'cmccmta2.chinamobile.com' HELO:'cmccmta2.chinamobile.com' FROM:'maozhongyi@cmss.chinamobile.com' RCPT:'' X-RedHat-Spam-Score: -0.698 (RCVD_IN_DNSWL_LOW, SPF_HELO_NONE, SPF_NONE) 221.176.66.80 cmccmta2.chinamobile.com 221.176.66.80 cmccmta2.chinamobile.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Zhang Shengju , Mao Zhongyi Subject: [libvirt] [PATCH v2 1/3] conf/domain_conf: use virStringParseYesNo helper X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 17 Oct 2019 03:24:54 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This helper performs a conversion from a "yes|no" string to a corresponding boolean, and several conversions were already done, but there are still some omissions. For most of the remaining usages in domain_conf.c only "yes" is explicitly checked for. This means all other values are implicitly handled as 'false'. In this case, use virStringParseYesNo to handle the conversion and reserve the original logic of not raise an error, so ignore the return value of helper. Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju Reviewed-by: Cole Robinson --- src/conf/domain_conf.c | 35 +++++++++++++---------------------- 1 file changed, 13 insertions(+), 22 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 10d6bf0eea..370e2840eb 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7600,10 +7600,8 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, } } =20 - if ((autoAddress =3D virXMLPropString(node, "autoAddress"))) { - if (STREQ(autoAddress, "yes")) - usbsrc->autoAddress =3D true; - } + if ((autoAddress =3D virXMLPropString(node, "autoAddress"))) + ignore_value(virStringParseYesNo(autoAddress, &usbsrc->autoAddress= )); =20 /* Product can validly be 0, so we need some extra help to determine * if it is uninitialized*/ @@ -8167,10 +8165,8 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, * element that might be (pure hostdev, or higher level device * (e.g. ) with type=3D'hostdev') */ - if ((managed =3D virXMLPropString(node, "managed")) !=3D NULL) { - if (STREQ(managed, "yes")) - def->managed =3D true; - } + if ((managed =3D virXMLPropString(node, "managed")) !=3D NULL) + ignore_value(virStringParseYesNo(managed, &def->managed)); =20 sgio =3D virXMLPropString(node, "sgio"); rawio =3D virXMLPropString(node, "rawio"); @@ -13807,9 +13803,7 @@ virDomainGraphicsListenDefParseXML(virDomainGraphic= sListenDefPtr def, =20 if (autoGenerated && flags & VIR_DOMAIN_DEF_PARSE_STATUS) { - if (STREQ(autoGenerated, "yes")) { - def->autoGenerated =3D true; - } else if (STRNEQ(autoGenerated, "no")) { + if (virStringParseYesNo(autoGenerated, &def->autoGenerated) < 0) { virReportError(VIR_ERR_XML_ERROR, _("Invalid autoGenerated value: %s"), autoGenerated); @@ -13939,13 +13933,10 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphics= DefPtr def, } =20 if (autoport) { - if (STREQ(autoport, "yes")) { - if (flags & VIR_DOMAIN_DEF_PARSE_INACTIVE) - def->data.vnc.port =3D 0; - def->data.vnc.autoport =3D true; - } else { - def->data.vnc.autoport =3D false; - } + ignore_value(virStringParseYesNo(autoport, &def->data.vnc.autoport= )); + + if (def->data.vnc.autoport && flags & VIR_DOMAIN_DEF_PARSE_INACTIV= E) + def->data.vnc.port =3D 0; } =20 if (websocket) { @@ -13958,8 +13949,9 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDe= fPtr def, } } =20 - if (websocketGenerated && STREQ(websocketGenerated, "yes")) - def->data.vnc.websocketGenerated =3D true; + if (websocketGenerated) + ignore_value(virStringParseYesNo(websocketGenerated, + &def->data.vnc.websocketGenerated)); =20 if (sharePolicy) { int policy =3D @@ -15479,8 +15471,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, heads =3D virXMLPropString(cur, "heads"); =20 if ((primary =3D virXMLPropString(cur, "primary")) !=3D NU= LL) { - if (STREQ(primary, "yes")) - def->primary =3D true; + ignore_value(virStringParseYesNo(primary, &def->primar= y)); VIR_FREE(primary); } =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Nov 26 13:36:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571282699; cv=none; d=zoho.com; s=zohoarc; b=B1IAi67A2WesQhHqMdZWndLxGl4Uw6ModlsDAJPEMfBgkJ2N1SyLViRxoM4eQ/FPQKLKX2kBJBolrsePMCr1XRQUT3BghOkD2g9yH32E3vTr2NFrBNMEyx2+kZiLwYpL7TIi6LxLo9SZWC8uTaZsElD7lxyiGJk9BiNjKjmIrN8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571282699; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=NBvIAjn2jhrxFjp71qL4pOOmj6j3BW83NyHkGHQAspA=; b=YEY9TU7h3oNDRACVyDF0ZKH7E/HnvpeiAX3+M0frZjh8rjsDgUF86lVO22WIh1Z9M5x3fM15TjnS38OTdz+e2JVCsNPH2tiqIjQS4OLaFLDEnPupgUWrAyjF1qWKaXupCGddt/rUCSzRkm7gp+wGFe2qrzAnF/CrlOAPld77o6Y= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571282699641747.0934571861552; Wed, 16 Oct 2019 20:24:59 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C7C15307C648; Thu, 17 Oct 2019 03:24:57 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9905660BE1; Thu, 17 Oct 2019 03:24:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 5B25C4EA71; Thu, 17 Oct 2019 03:24:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9H3KPsg002729 for ; Wed, 16 Oct 2019 23:20:27 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0E7906FDA1; Thu, 17 Oct 2019 03:20:25 +0000 (UTC) Received: from mx1.redhat.com (ext-mx29.extmail.prod.ext.phx2.redhat.com [10.5.110.70]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0A05D60872 for ; Thu, 17 Oct 2019 03:20:22 +0000 (UTC) Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by mx1.redhat.com (Postfix) with ESMTP id 9C51A18C8937 for ; Thu, 17 Oct 2019 03:20:02 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.5]) by rmmx-syy-dmz-app06-12006 (RichMail) with SMTP id 2ee65da7ddce5a0-b0778; Thu, 17 Oct 2019 11:19:42 +0800 (CST) Received: from localhost.localdomain (unknown[112.25.154.149]) by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee35da7ddc6aab-7fa30; Thu, 17 Oct 2019 11:19:42 +0800 (CST) X-RM-TRANSID: 2ee65da7ddce5a0-b0778 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee35da7ddc6aab-7fa30 From: Mao Zhongyi To: libvir-list@redhat.com Date: Thu, 17 Oct 2019 11:19:32 +0800 Message-Id: In-Reply-To: References: In-Reply-To: References: X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 17 Oct 2019 03:20:13 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.70]); Thu, 17 Oct 2019 03:20:13 +0000 (UTC) for IP:'221.176.66.80' DOMAIN:'cmccmta2.chinamobile.com' HELO:'cmccmta2.chinamobile.com' FROM:'maozhongyi@cmss.chinamobile.com' RCPT:'' X-RedHat-Spam-Score: -0.699 (RCVD_IN_DNSWL_LOW, SPF_NONE) 221.176.66.80 cmccmta2.chinamobile.com 221.176.66.80 cmccmta2.chinamobile.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.70 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Zhang Shengju , Mao Zhongyi Subject: [libvirt] [PATCH v2 2/3] conf/network_conf: use virStringParseYesNo helper X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 17 Oct 2019 03:24:58 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju Acked-by: Michal Privoznik Reviewed-by: Cole Robinson --- 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 =3D virXPathString("string(./@ipv6)", ctxt); if (ipv6nogwStr) { - if (STREQ(ipv6nogwStr, "yes")) { - def->ipv6nogw =3D 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); --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Tue Nov 26 13:36:19 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1571282583; cv=none; d=zoho.com; s=zohoarc; b=HHflzdtOWk7lWyK7R6rb7vjEsO68G7+v4CnVUsT+SZtkjnNAFvmfHbnpXHKMliXzQkprBUgicBwDp299oDs1wJAahLWDobbdGYamep/hijpHZ07VgvkxiNxnOqC2Koyqf8QIFFVar2m9+1DzUmtTlWBsozikJ1Smm/u7gyfm6n0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571282583; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ioY3uFhTI9ORo954770ZvPlGKRmp9GFOD7PCRQpp+W8=; b=Q6KRaiKVDTRPwEzcSZcaEelOWcXITGKjqy9wPt7qbS0XTdTnDhprExU6IPmDZwUJrM4uZqeq59agoMD4YNwWFLvngoYk+pdmXAJH7//itgOZ8iOQa2sU4ZcsrPAkYrRy1Q/y+cGuQIXFrp6PRhU9G+9EaYHKglS7qM5nqcJBlmA= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1571282582685924.3050056077318; Wed, 16 Oct 2019 20:23:02 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C45CE59449; Thu, 17 Oct 2019 03:22:59 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3522F5C1D4; Thu, 17 Oct 2019 03:22:57 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E8A8D180B536; Thu, 17 Oct 2019 03:22:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9H3KUpd002765 for ; Wed, 16 Oct 2019 23:20:30 -0400 Received: by smtp.corp.redhat.com (Postfix) id 259836FDA0; Thu, 17 Oct 2019 03:20:30 +0000 (UTC) Received: from mx1.redhat.com (ext-mx24.extmail.prod.ext.phx2.redhat.com [10.5.110.65]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 20AEC60872 for ; Thu, 17 Oct 2019 03:20:30 +0000 (UTC) Received: from cmccmta3.chinamobile.com (cmccmta3.chinamobile.com [221.176.66.81]) by mx1.redhat.com (Postfix) with ESMTP id 81AC310CC211 for ; Thu, 17 Oct 2019 03:20:12 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.5]) by rmmx-syy-dmz-app10-12010 (RichMail) with SMTP id 2eea5da7ddcf660-b08a3; Thu, 17 Oct 2019 11:19:43 +0800 (CST) Received: from localhost.localdomain (unknown[112.25.154.149]) by rmsmtp-syy-appsvr03-12003 (RichMail) with SMTP id 2ee35da7ddc6aab-7fa39; Thu, 17 Oct 2019 11:19:43 +0800 (CST) X-RM-TRANSID: 2eea5da7ddcf660-b08a3 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee35da7ddc6aab-7fa39 From: Mao Zhongyi To: libvir-list@redhat.com Date: Thu, 17 Oct 2019 11:19:33 +0800 Message-Id: <0d15272150b59a81d9a865ee5c5abd541e5bb57a.1571281133.git.maozhongyi@cmss.chinamobile.com> In-Reply-To: References: In-Reply-To: References: X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Thu, 17 Oct 2019 03:20:23 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Thu, 17 Oct 2019 03:20:23 +0000 (UTC) for IP:'221.176.66.81' DOMAIN:'cmccmta3.chinamobile.com' HELO:'cmccmta3.chinamobile.com' FROM:'maozhongyi@cmss.chinamobile.com' RCPT:'' X-RedHat-Spam-Score: -0.699 (RCVD_IN_DNSWL_LOW, SPF_NONE) 221.176.66.81 cmccmta3.chinamobile.com 221.176.66.81 cmccmta3.chinamobile.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.65 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Zhang Shengju , Mao Zhongyi Subject: [libvirt] [PATCH v2 3/3] qemu/qemu_migration_params: use virStringParseYesNo helper X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Thu, 17 Oct 2019 03:23:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" 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. Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju Reviewed-by: Cole Robinson --- src/qemu/qemu_migration_params.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 85fa8f8de5..f5bc8596f4 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1326,12 +1326,7 @@ qemuMigrationParamsParse(xmlXPathContextPtr ctxt, break; =20 case QEMU_MIGRATION_PARAM_TYPE_BOOL: - if (STREQ(value, "yes")) - pv->value.b =3D true; - else if (STREQ(value, "no")) - pv->value.b =3D false; - else - rc =3D -1; + rc =3D virStringParseYesNo(value, &pv->value.b); break; =20 case QEMU_MIGRATION_PARAM_TYPE_STRING: --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list