[PATCH v2] Two branches in a conditional structure should not have exactly the same implementation

丁丽敏 posted 1 patch 1 year, 7 months ago
Failed in applying to current master (apply log)
1 file changed, 2 insertions(+), 4 deletions(-)
[PATCH v2] Two branches in a conditional structure should not have exactly the same implementation
Posted by 丁丽敏 1 year, 7 months ago






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 truly

needed for both instances, then they should be combined.




Signed-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(-)




diff --git a/scripts/apibuild.py b/scripts/apibuild.py

index c232b4e2c8..140916ec4c 100755

--- a/scripts/apibuild.py

+++ b/scripts/apibuild.py

@@ -1248,10 +1248,8 @@ class CParser:

                                token[1] == "," or token[1] == "="):

                                 self.index_add_ref(oldtok[1], self.filename,

                                                    0, "type")

-                    elif oldtok[0] == "name" and oldtok[1][0:4] == "XEN_":

-                        self.index_add_ref(oldtok[1], self.filename,

-                                           0, "typedef")

-                    elif oldtok[0] == "name" and oldtok[1][0:7] == "LIBXEN_":

+                    elif oldtok[0] == "name" and (oldtok[1][0:4] == "XEN_" or

+                         oldtok[1][0:7] == "LIBXEN_"):

                         self.index_add_ref(oldtok[1], self.filename,

                                            0, "typedef")




-- 

2.18.4


















丁丽敏    IaaS产品部

中国移动云能力中心

电话:188-9672-5914

邮箱:dinglimin@cmss.chinamobile.com



江苏省苏州市高新区科技城昆仑山路58号 中移软件园 215153