[libvirt] [PATCH 1/6] conf: Remove dead code

Andrea Bolognani abologna at redhat.com
Tue Feb 21 19:57:39 UTC 2017


The switch in virDomainPCIControllerModelToConnectType()
had some code that, while techically part of the
_PCIE_SWITCH_DOWNSTREAM_PORT case, was in fact dead due
to the early return.

Get rid of the dead code, and fix the inaccurate function
description while at it.
---
 src/conf/domain_addr.c | 13 ++-----------
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c
index 1649d84..519cc6b 100644
--- a/src/conf/domain_addr.c
+++ b/src/conf/domain_addr.c
@@ -35,9 +35,8 @@ VIR_LOG_INIT("conf.domain_addr");
 virDomainPCIConnectFlags
 virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
 {
-    /* given a VIR_DOMAIN_CONTROLLER_MODEL_PCI*, set connectType to
-     * the equivalent VIR_PCI_CONNECT_TYPE_*. return 0 on success, -1
-     * if the model wasn't recognized.
+    /* given a VIR_DOMAIN_CONTROLLER_MODEL_PCI*, return
+     * the equivalent VIR_PCI_CONNECT_TYPE_*.
      */
     switch (model) {
     case VIR_DOMAIN_CONTROLLER_MODEL_PCI_LAST:
@@ -70,14 +69,6 @@ virDomainPCIControllerModelToConnectType(virDomainControllerModelPCI model)
 
     case VIR_DOMAIN_CONTROLLER_MODEL_PCIE_SWITCH_DOWNSTREAM_PORT:
         return VIR_PCI_CONNECT_TYPE_PCIE_SWITCH_DOWNSTREAM_PORT;
-
-        /* if this happens, there is an error in the code. A
-         * PCI controller should always have a proper model
-         * set
-         */
-        virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
-                       _("PCI controller model incorrectly set to 'last'"));
-        return -1;
     }
     return 0;
 }
-- 
2.7.4




More information about the libvir-list mailing list