From nobody Sun May 5 19:18:47 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=1571194243; cv=none; d=zoho.com; s=zohoarc; b=DmzRARow/0MwEWOS31nVNLpu4ZIIzZ2iSDAEM3TRMYr6RPeLYlncVLNGgUaxQrpUr7WbGh+4head2C8U30QwwyEPCkHfCfrxg2LspYG6zOCNduIhl9aSxzTYVdHjFcbGPe3bJQSehTRVDGMOgPeujpGbEt/KGSeoqP/MqKhORLM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571194243; 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=6mtvt6XHoLNB2Upj/wob5VgRSgcdtFLITW5qkY+QmW8=; b=bliX2V1380ekG3/60ZJX+QZh8xu8NsTVPXphfGzcAMeyo7wu92nBeZBI6PkzUNIzMVtKoWwIVbMJItfMuYlLPTfTX+EKfuoyPMEi73b6q+0V19ZMq/41wva0wnw6ycS20PEF9K6W5l5TXjvkuFSuL6TUDbl8vk4tDLtPsMSsY34= 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 1571194243126516.9195701232353; Tue, 15 Oct 2019 19:50:43 -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 38BBC8665A; Wed, 16 Oct 2019 02:50:41 +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 0ED2760C5E; Wed, 16 Oct 2019 02:50:41 +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 C0CCA18005A0; Wed, 16 Oct 2019 02:50:40 +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 x9G2f1VD025489 for ; Tue, 15 Oct 2019 22:41:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 228436060D; Wed, 16 Oct 2019 02:41:01 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 72BD9608C2; Wed, 16 Oct 2019 02:40:58 +0000 (UTC) Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by mx1.redhat.com (Postfix) with ESMTP id 74634316D8C2; Wed, 16 Oct 2019 02:40:41 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.11]) by rmmx-syy-dmz-app07-12007 (RichMail) with SMTP id 2ee75da68313351-985d0; Wed, 16 Oct 2019 10:40:20 +0800 (CST) Received: from localhost.localdomain (unknown[112.25.154.149]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee65da68308dda-b7936; Wed, 16 Oct 2019 10:40:19 +0800 (CST) X-RM-TRANSID: 2ee75da68313351-985d0 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee65da68308dda-b7936 From: Mao Zhongyi To: libvir-list@redhat.com Date: Wed, 16 Oct 2019 10:39:48 +0800 Message-Id: <20191016023950.1623751-2-maozhongyi@cmss.chinamobile.com> In-Reply-To: <20191016023950.1623751-1-maozhongyi@cmss.chinamobile.com> References: <20191016023950.1623751-1-maozhongyi@cmss.chinamobile.com> 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.41]); Wed, 16 Oct 2019 02:40:51 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 16 Oct 2019 02:40:51 +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.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: phrdina@redhat.com, maozhongyi@cmss.chinamobile.com, abologna@redhat.com, g.sho1500@gmail.com, mkletzan@redhat.com, zhangshengju@cmss.chinamobile.com, laine@laine.org Subject: [libvirt] [PATCH 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.26]); Wed, 16 Oct 2019 02:50:41 +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, but if it returns -1, don't raise an error but set the bool value to false. Cc: crobinso@redhat.com Cc: berrange@redhat.com Cc: abologna@redhat.com Cc: laine@laine.org Cc: phrdina@redhat.com Cc: mkletzan@redhat.com Cc: g.sho1500@gmail.com Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju --- src/conf/domain_conf.c | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 10d6bf0eea..7420658726 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7601,8 +7601,8 @@ virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, } =20 if ((autoAddress =3D virXMLPropString(node, "autoAddress"))) { - if (STREQ(autoAddress, "yes")) - usbsrc->autoAddress =3D true; + if (virStringParseYesNo(autoAddress, &usbsrc->autoAddress) < 0) + usbsrc->autoAddress =3D false; } =20 /* Product can validly be 0, so we need some extra help to determine @@ -8168,8 +8168,8 @@ virDomainHostdevDefParseXMLSubsys(xmlNodePtr node, * (e.g. ) with type=3D'hostdev') */ if ((managed =3D virXMLPropString(node, "managed")) !=3D NULL) { - if (STREQ(managed, "yes")) - def->managed =3D true; + if (virStringParseYesNo(managed, &def->managed) < 0) + def->managed =3D false; } =20 sgio =3D virXMLPropString(node, "sgio"); @@ -13807,9 +13807,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,12 +13937,11 @@ 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 { + if (virStringParseYesNo(autoport, &def->data.vnc.autoport) < 0) { def->data.vnc.autoport =3D false; + } else { + if (def->data.vnc.autoport && flags & VIR_DOMAIN_DEF_PARSE_INA= CTIVE) + def->data.vnc.port =3D 0; } } =20 @@ -13958,8 +13955,9 @@ virDomainGraphicsDefParseXMLVNC(virDomainGraphicsDe= fPtr def, } } =20 - if (websocketGenerated && STREQ(websocketGenerated, "yes")) - def->data.vnc.websocketGenerated =3D true; + if (websocketGenerated && + virStringParseYesNo(websocketGenerated, &def->data.vnc.websocketGe= nerated)) + def->data.vnc.websocketGenerated =3D false; =20 if (sharePolicy) { int policy =3D @@ -15479,8 +15477,8 @@ 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; + if (virStringParseYesNo(primary, &def->primary) < 0) + def->primary =3D false; 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 Sun May 5 19:18:47 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=1571194350; cv=none; d=zoho.com; s=zohoarc; b=kkGu6MP3KyBXTYxzAWYF7a4Q6/vE1ZXcBt8X0mV6V8IaX3hRP5/D87dF9DdKGvNWJIQsP14yZL3HOJT+dciaQKk09ZPgzh69q9WXaonzpafzXezT2D+C1s9ILRbrsbuNI5Y8osLr+O3DBlL5p1MvTXDuCE5sJWytKTrqOiiM1fw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571194350; 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=a1cknHAiCtGoDp9+YAUcP862/5s+OFc1okkJbR8A64U=; b=lqRnrx2ZsRCvBOon8YyLoF4TJv8v9jbI3LOW7MjlFd81sxvzxssB/5hXj3ZRcGyGFDF6dCn8yW6VilAR53HtU8h0RdPvifui7GxRULiUFy/1kI5GjwAPtUeMpqxD1aUqZFM8G+KHsGbVdurGLqTHv+6IM7oWJuwwdU9GXxqm8e8= 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 1571194350407814.0781969313756; Tue, 15 Oct 2019 19:52:30 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 883C210CC202; Wed, 16 Oct 2019 02:52:28 +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 638B25DC1E; Wed, 16 Oct 2019 02:52:28 +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 202A54EE68; Wed, 16 Oct 2019 02:52:28 +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 x9G2f9ZZ025524 for ; Tue, 15 Oct 2019 22:41:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id 45AF66031D; Wed, 16 Oct 2019 02:41:09 +0000 (UTC) Received: from mx1.redhat.com (ext-mx28.extmail.prod.ext.phx2.redhat.com [10.5.110.69]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EFC366013A; Wed, 16 Oct 2019 02:41:06 +0000 (UTC) Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by mx1.redhat.com (Postfix) with ESMTP id 4F8798E1CE8; Wed, 16 Oct 2019 02:40:40 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.11]) by rmmx-syy-dmz-app08-12008 (RichMail) with SMTP id 2ee85da683142a6-983df; Wed, 16 Oct 2019 10:40:21 +0800 (CST) Received: from localhost.localdomain (unknown[112.25.154.149]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee65da68308dda-b794c; Wed, 16 Oct 2019 10:40:20 +0800 (CST) X-RM-TRANSID: 2ee85da683142a6-983df X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee65da68308dda-b794c From: Mao Zhongyi To: libvir-list@redhat.com Date: Wed, 16 Oct 2019 10:39:49 +0800 Message-Id: <20191016023950.1623751-3-maozhongyi@cmss.chinamobile.com> In-Reply-To: <20191016023950.1623751-1-maozhongyi@cmss.chinamobile.com> References: <20191016023950.1623751-1-maozhongyi@cmss.chinamobile.com> 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.69]); Wed, 16 Oct 2019 02:40:50 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.69]); Wed, 16 Oct 2019 02:40:50 +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.69 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: maozhongyi@cmss.chinamobile.com, gene@czarc.net, g.sho1500@gmail.com, zhangshengju@cmss.chinamobile.com Subject: [libvirt] [PATCH 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Wed, 16 Oct 2019 02:52:29 +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. Cc: gene@czarc.net Cc: crobinso@redhat.com Cc: berrange@redhat.com Cc: g.sho1500@gmail.com Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju --- 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 Sun May 5 19:18:47 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=1571194240; cv=none; d=zoho.com; s=zohoarc; b=XMykwHpHcJ+rAlUyMEt6UmQCK10j/MhCN2VMhW9HTl0o8H9fOh9cWZQVG+/iqGN1GR4rih18fNEJTo+Wbt0WXNw+AYaPbwL6ZZ6jeisruSyJ2rHmVQeikyGq4rF3VE0acvaGEAsXLJBTK0UvIIsnojpYEjW8ivi9sN5RcA62inc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1571194240; 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=uIcqsJ+hU3NcvF+vnyEpOHPBID0O3bEpRJQb974oyxA=; b=C/G1U1s2SewotzyRD7VogWmOvKQ8Ns/SH4opuWW2qmp5BDC5qAfvdjumU8Lr0/9LhkrtGfJZqSMf8Tp5UgJYkejDoGir6NLAJMnJqQ5Eb925tkfYlYqub2Rb9Q9quosJwKZYyRKzJ66TkLoNPZNQUBA93IXGpa81eN/VfVBkuE4= 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 1571194239826799.2963334049193; Tue, 15 Oct 2019 19:50:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 13E5261D25; Wed, 16 Oct 2019 02:50:37 +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 DE02010027A9; Wed, 16 Oct 2019 02:50:36 +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 924054EA65; Wed, 16 Oct 2019 02:50:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x9G2f1J0025487 for ; Tue, 15 Oct 2019 22:41:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id 115965DC1E; Wed, 16 Oct 2019 02:41:01 +0000 (UTC) Received: from mx1.redhat.com (ext-mx12.extmail.prod.ext.phx2.redhat.com [10.5.110.41]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 902CF5DA8C; Wed, 16 Oct 2019 02:40:59 +0000 (UTC) Received: from cmccmta1.chinamobile.com (cmccmta1.chinamobile.com [221.176.66.79]) by mx1.redhat.com (Postfix) with ESMTP id 742E73172D88; Wed, 16 Oct 2019 02:40:48 +0000 (UTC) Received: from spf.mail.chinamobile.com (unknown[172.16.121.11]) by rmmx-syy-dmz-app04-12004 (RichMail) with SMTP id 2ee45da6831737e-98579; Wed, 16 Oct 2019 10:40:23 +0800 (CST) Received: from localhost.localdomain (unknown[112.25.154.149]) by rmsmtp-syy-appsvr06-12006 (RichMail) with SMTP id 2ee65da68308dda-b7955; Wed, 16 Oct 2019 10:40:23 +0800 (CST) X-RM-TRANSID: 2ee45da6831737e-98579 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee65da68308dda-b7955 From: Mao Zhongyi To: libvir-list@redhat.com Date: Wed, 16 Oct 2019 10:39:50 +0800 Message-Id: <20191016023950.1623751-4-maozhongyi@cmss.chinamobile.com> In-Reply-To: <20191016023950.1623751-1-maozhongyi@cmss.chinamobile.com> References: <20191016023950.1623751-1-maozhongyi@cmss.chinamobile.com> 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.41]); Wed, 16 Oct 2019 02:40:49 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Wed, 16 Oct 2019 02:40:49 +0000 (UTC) for IP:'221.176.66.79' DOMAIN:'cmccmta1.chinamobile.com' HELO:'cmccmta1.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.79 cmccmta1.chinamobile.com 221.176.66.79 cmccmta1.chinamobile.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.41 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Cc: jdenemar@redhat.com, g.sho1500@gmail.com, zhangshengju@cmss.chinamobile.com, maozhongyi@cmss.chinamobile.com Subject: [libvirt] [PATCH 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.39]); Wed, 16 Oct 2019 02:50:37 +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. Cc: jdenemar@redhat.com Cc: g.sho1500@gmail.com Cc: crobinso@redhat.com Signed-off-by: Mao Zhongyi Signed-off-by: Zhang Shengju --- src/qemu/qemu_migration_params.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/qemu/qemu_migration_params.c b/src/qemu/qemu_migration_par= ams.c index 85fa8f8de5..acd42042fe 100644 --- a/src/qemu/qemu_migration_params.c +++ b/src/qemu/qemu_migration_params.c @@ -1326,11 +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 + if (virStringParseYesNo(value, &pv->value.b) < 0) rc =3D -1; break; =20 --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list