[PATCH 12/17] cpu_x86: Simplify insertions into a linked list

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

 



The next pointer is initialized to NULL, overwriting to with another
NULL doesn't hurt.

Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/cpu/cpu_x86.c | 33 ++++++++-------------------------
 1 file changed, 8 insertions(+), 25 deletions(-)

diff --git a/src/cpu/cpu_x86.c b/src/cpu/cpu_x86.c
index f8121d1..94260e9 100644
--- a/src/cpu/cpu_x86.c
+++ b/src/cpu/cpu_x86.c
@@ -563,12 +563,8 @@ x86VendorLoad(xmlXPathContextPtr ctxt,
     vendor->cpuid.edx = virReadBufInt32LE(string + 4);
     vendor->cpuid.ecx = virReadBufInt32LE(string + 8);
 
-    if (!map->vendors) {
-        map->vendors = vendor;
-    } else {
-        vendor->next = map->vendors;
-        map->vendors = vendor;
-    }
+    vendor->next = map->vendors;
+    map->vendors = vendor;
 
  cleanup:
     VIR_FREE(string);
@@ -768,12 +764,8 @@ x86FeatureLoad(xmlXPathContextPtr ctxt,
         map->migrate_blockers = migrate_blocker;
     }
 
-    if (!map->features) {
-        map->features = feature;
-    } else {
-        feature->next = map->features;
-        map->features = feature;
-    }
+    feature->next = map->features;
+    map->features = feature;
 
  cleanup:
     ctxt->node = ctxt_node;
@@ -1108,12 +1100,8 @@ x86ModelLoad(xmlXPathContextPtr ctxt,
             goto error;
     }
 
-    if (!map->models) {
-        map->models = model;
-    } else {
-        model->next = map->models;
-        map->models = model;
-    }
+    model->next = map->models;
+    map->models = model;
 
  cleanup:
     VIR_FREE(vendor);
@@ -1209,13 +1197,8 @@ x86MapLoadInternalFeatures(virCPUx86MapPtr map)
         if (virCPUx86DataAddCPUID(feature->data, &x86_kvm_features[i].cpuid))
             goto error;
 
-        if (!map->features) {
-            map->features = feature;
-        } else {
-            feature->next = map->features;
-            map->features = feature;
-        }
-
+        feature->next = map->features;
+        map->features = feature;
         feature = NULL;
     }
 
-- 
2.8.2

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[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]