]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
domain-conf: cleanup controller insert function
authorPavel Hrdina <phrdina@redhat.com>
Wed, 11 Nov 2015 14:18:07 +0000 (15:18 +0100)
committerPavel Hrdina <phrdina@redhat.com>
Wed, 11 Nov 2015 14:18:07 +0000 (15:18 +0100)
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
src/conf/domain_conf.c

index 2edf12365d5d3a15bdfe563459123e4f6c83eb1c..f9fb68338b4d9563216b9af1cab59a1582f7e0c8 100644 (file)
@@ -13397,6 +13397,7 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
     int idx;
     /* Tenatively plan to insert controller at the end. */
     int insertAt = -1;
+    virDomainControllerDefPtr current = NULL;
 
     /* Then work backwards looking for controllers of
      * the same type. If we find a controller with a
@@ -13404,17 +13405,19 @@ void virDomainControllerInsertPreAlloced(virDomainDefPtr def,
      * that position
      */
     for (idx = (def->ncontrollers - 1); idx >= 0; idx--) {
-        /* If bus matches and current controller is after
-         * new controller, then new controller should go here */
-        if (def->controllers[idx]->type == controller->type &&
-            def->controllers[idx]->idx > controller->idx) {
-            insertAt = idx;
-        } else if (def->controllers[idx]->type == controller->type &&
-                   insertAt == -1) {
-            /* Last controller with match bus is before the
-             * new controller, then put new controller just after
-             */
-            insertAt = idx + 1;
+        current = def->controllers[idx];
+        if (current->type == controller->type) {
+            if (current->idx > controller->idx) {
+                /* If bus matches and current controller is after
+                 * new controller, then new controller should go here
+                 * */
+                insertAt = idx;
+            } else if (insertAt == -1) {
+                /* Last controller with match bus is before the
+                 * new controller, then put new controller just after
+                 */
+                insertAt = idx + 1;
+            }
         }
     }