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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxxxxxxxxxxx>

---
v1 of:
https://www.mail-archive.com/libvir-list@xxxxxxxxxx/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
 

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux