From nobody Sun May 19 03:38:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1664185745; cv=none; d=zohomail.com; s=zohoarc; b=aEYDZsOm6B4Vq0xGOEfxUDwf9yPE1Le0n7OzGYoioA9RHeWfKVM8fEMvnStO6q/rvsy7V5JgrnjF96SpkfDdthHYSyH5/09YGtdGb9xj7NaFZm4wDtxhktRRdsO1ecVlbb6PpMzvvIHIwDKF+UxzKghkXqViLUO8GG7KGU5P/3A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1664185745; h=Content-Type:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dDV283I+heaBkngNZ/ofhF6fiTRoPHI11wPH2wV2BgY=; b=LjPl1sUfKl/JT8HlhsRQIjeBYoBmA1qQ7CPc6/q/mSqId53x6wigkA78uhQO98kFSAMMCwLfJYoxepNoKWXAbasmpYmqIY2Ta2x9Rp5FOYsO+zUCXET71Fl14J+IIkv6HfipMfvs6hWxlvwixzk0loxD2fmq5/k/X1Co0G5HW+A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1664185745873919.4714304343188; Mon, 26 Sep 2022 02:49:05 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-235-newUq9uuMzOeGgq615Guig-1; Mon, 26 Sep 2022 05:48:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 51FA118E0047; Mon, 26 Sep 2022 09:48:29 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2786840C6EC2; Mon, 26 Sep 2022 09:48:28 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E4EA9194658D; Mon, 26 Sep 2022 09:48:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 9D8371946586 for ; Mon, 26 Sep 2022 09:48:27 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 81FC4492CA2; Mon, 26 Sep 2022 09:48:27 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast07.extmail.prod.ext.rdu2.redhat.com [10.11.55.23]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7A98647505E for ; Mon, 26 Sep 2022 09:48:27 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5C44A3C1068C for ; Mon, 26 Sep 2022 09:48:27 +0000 (UTC) Received: from cmccmta2.chinamobile.com (cmccmta2.chinamobile.com [221.176.66.80]) by relay.mimecast.com with ESMTP id us-mta-536-e15cIVUGOp6l_9MKzZiPdg-1; Mon, 26 Sep 2022 05:48:24 -0400 Received: from spf.mail.chinamobile.com (unknown[172.16.121.97]) by rmmx-syy-dmz-app05-12005 (RichMail) with SMTP id 2ee563317565609-f962f; Mon, 26 Sep 2022 17:48:22 +0800 (CST) Received: from LAPTOP-CDJ95CPL (unknown[223.108.79.103]) by rmsmtp-syy-appsvrnew09-12034 (RichMail) with SMTP id 2f0263317564a14-81f2d; Mon, 26 Sep 2022 17:48:21 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1664185744; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:list-id:list-help:list-unsubscribe: list-subscribe:list-post; bh=dDV283I+heaBkngNZ/ofhF6fiTRoPHI11wPH2wV2BgY=; b=BvJKP5G0lH8Onuw+bdgDDr9dCekbZOqnB7tRiwzHBZWrVOmb9D+FAICQjXRubL3r9RYti4 3oV6cEtXbLuSsQVMnF2DV01/6DRF12KkpQaZ8Kd7iHzX4Q1l/Hq78O+zXP8Ou/EisJY5le 8qLvJAEnFi9vfT8bcnn15V5dyyT95DE= X-MC-Unique: newUq9uuMzOeGgq615Guig-1 X-Original-To: libvir-list@listman.corp.redhat.com X-MC-Unique: e15cIVUGOp6l_9MKzZiPdg-1 X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2ee563317565609-f962f X-RM-TagInfo: emlType=0 X-RM-SPAM-FLAG: 00000000 X-RM-TRANSID: 2f0263317564a14-81f2d MIME-Version: 1.0 x-PcFlag: bf0b9507-eac5-47c8-b2ef-41ae77e34fb6_5_31481 Date: 26 Sep 2022 17:48:21 +0800 From: =?utf-8?B?5LiB5Li95pWP?= To: libvir-list Cc: Subject: [PATCH v2] Two branches in a conditional structure should not have exactly the same implementation Message-ID: <20220926174821550291041@cmss.chinamobile.com> X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Mimecast-Spam-Signature: yes X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: multipart/Alternative; boundary="----=_001_NextPart550291041_=----" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1664185747418100001 This is a multi-part message in MIME format. ------=_001_NextPart550291041_=---- Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Having two branches in the same if structure with the same implement= ation is at best duplicate code, and at worst a coding error.If the same l= ogic is truly needed for both instances, then they should be combined. = Signed-off-by: dinglimin --- v1 of: = https://www.mail-archive.com/libvir-list@redhat.com/msg232231.html diff t= o v1: - Add the patch 's description. - Change the code format. --- sc= ripts/apibuild.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions= (-) diff --git a/scripts/apibuild.py b/scripts/apibuild.py index c232b= 4e2c8..140916ec4c 100755 --- a/scripts/apibuild.py +++ b/scripts/apibuild= .py @@ -1248,10 +1248,8 @@ class CParser: = token[1] =3D=3D "," or token[1] =3D=3D "=3D"): = self.index_add_ref(oldtok[1], self.filename, = 0, "type") - elif oldtok[= 0] =3D=3D "name" and oldtok[1][0:4] =3D=3D "XEN_": - = self.index_add_ref(oldtok[1], self.filename, - = 0, "typedef") - elif oldtok[0] =3D=3D = "name" and oldtok[1][0:7] =3D=3D "LIBXEN_": + elif oldt= ok[0] =3D=3D "name" and (oldtok[1][0:4] =3D=3D "XEN_" or + = oldtok[1][0:7] =3D=3D "LIBXEN_"): self.i= ndex_add_ref(oldtok[1], self.filename, = 0, "typedef") -- 2.18.4 =E4=B8=81=E4=B8=BD= =E6=95=8F IaaS=E4=BA=A7=E5=93=81=E9=83=A8 =E4=B8=AD=E5=9B=BD=E7=A7=BB= =E5=8A=A8=E4=BA=91=E8=83=BD=E5=8A=9B=E4=B8=AD=E5=BF=83 =E7=94=B5=E8=AF=9D:= 188-9672-5914 =E9=82=AE=E7=AE=B1:dinglimin@cmss.chinamobile.com =E6=B1= =9F=E8=8B=8F=E7=9C=81=E8=8B=8F=E5=B7=9E=E5=B8=82=E9=AB=98=E6=96=B0=E5=8C=BA= =E7=A7=91=E6=8A=80=E5=9F=8E=E6=98=86=E4=BB=91=E5=B1=B1=E8=B7=AF58=E5=8F=B7 = =E4=B8=AD=E7=A7=BB=E8=BD=AF=E4=BB=B6=E5=9B=AD 215153 =20 ------=_001_NextPart550291041_=---- Content-Type: text/html; charset="utf-8" Content-Transfer-Encoding: quoted-printable
Having two branches in the same if structure with
the same implementation is at best duplicate code,
and at worst a coding error.If the same logic is tru= ly
needed for both instances, then they should= be combined.

S= igned-off-by: dinglimin <dinglimin@cmss.chinamobile.com>
=

---
v1 of:
https://www.mail-archive.com/libvir-= list@redhat.com/msg232231.html
diff to v1:
- Add the patch 's description.
- Change the code format.
---
 scripts/apibuild.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
<= div style=3D"word-wrap: break-word;">
diff --git a/scripts/apibuild= .py b/scripts/apibuild.py
index c232b4e2c8..1409= 16ec4c 100755
--- a/scripts/apibuild.py<= /div>
+++ b/scripts/apibuild.py
@@= -1248,10 +1248,8 @@ class CParser:
   = ;                     &nb= sp;       token[1] =3D=3D "," or token[1] =3D=3D "=3D"):
              =                    self.i= ndex_add_ref(oldtok[1], self.filename,
  &n= bsp;                     =                      = ;       0, "type")
-    = ;                elif oldtok[0] =3D= =3D "name" and oldtok[1][0:4] =3D=3D "XEN_":
- &= nbsp;                    =  self.index_add_ref(oldtok[1], self.filename,
-                    = ;                     &nb= sp; 0, "typedef")
-         =            elif oldtok[0] =3D=3D "name" and o= ldtok[1][0:7] =3D=3D "LIBXEN_":
+     =                elif oldtok[0] =3D= =3D "name" and (oldtok[1][0:4] =3D=3D "XEN_" or
= +                     &nb= sp;   oldtok[1][0:7] =3D=3D "LIBXEN_"):
&nb= sp;                     &= nbsp;  self.index_add_ref(oldtok[1], self.filename,
                  &= nbsp;                    =     0, "typedef")

-- 
2.18.4
=




=E4=B8=81=E4=B8=BD=E6=95=8F    IaaS=E4=BA=A7=E5=93=81=E9=83= =A8
=E4=B8=AD=E5=9B=BD=E7=A7=BB=E5=8A=A8=E4= =BA=91=E8=83=BD=E5=8A=9B=E4=B8=AD=E5=BF=83
=E7=94=B5=E8=AF=9D:188-9672-5914
<= div style=3D"font-family: =E5=BE=AE=E8=BD=AF=E9=9B=85=E9=BB=91; font-size: = 14px;">=E9=82=AE=E7=AE=B1:dinglimin@cmss.chinamobile.com
=E6=B1=9F=E8=8B=8F=E7=9C= =81=E8=8B=8F=E5=B7=9E=E5=B8=82=E9=AB=98=E6=96=B0=E5=8C=BA=E7=A7=91=E6=8A=80= =E5=9F=8E=E6=98=86=E4=BB=91=E5=B1=B1=E8=B7=AF58=E5=8F=B7 =E4=B8=AD= =E7=A7=BB=E8=BD=AF=E4=BB=B6=E5=9B=AD 215153
=
 
= ------=_001_NextPart550291041_=------