From nobody Tue Nov 26 15:38:28 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 --- 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