Having the functions grouped together this way will avoid further
shuffling around down the line.
No functional changes.
---
src/cpu/cpu_ppc64.c | 127 +++++++++++++++++++++++++---------------------------
1 file changed, 62 insertions(+), 65 deletions(-)
diff --git a/src/cpu/cpu_ppc64.c b/src/cpu/cpu_ppc64.c
index 18dbf86..5921263 100644
--- a/src/cpu/cpu_ppc64.c
+++ b/src/cpu/cpu_ppc64.c
@@ -57,6 +57,32 @@ struct ppc64_map {
struct ppc64_model *models;
};
+static void
+ppc64VendorFree(struct ppc64_vendor *vendor)
+{
+ if (!vendor)
+ return;
+
+ VIR_FREE(vendor->name);
+ VIR_FREE(vendor);
+}
+
+static struct ppc64_vendor *
+ppc64VendorFind(const struct ppc64_map *map,
+ const char *name)
+{
+ struct ppc64_vendor *vendor;
+
+ vendor = map->vendors;
+ while (vendor) {
+ if (STREQ(vendor->name, name))
+ return vendor;
+
+ vendor = vendor->next;
+ }
+
+ return NULL;
+}
static void
ppc64ModelFree(struct ppc64_model *model)
@@ -69,6 +95,23 @@ ppc64ModelFree(struct ppc64_model *model)
}
static struct ppc64_model *
+ppc64ModelCopy(const struct ppc64_model *model)
+{
+ struct ppc64_model *copy;
+
+ if (VIR_ALLOC(copy) < 0 ||
+ VIR_STRDUP(copy->name, model->name) < 0) {
+ ppc64ModelFree(copy);
+ return NULL;
+ }
+
+ copy->data.pvr = model->data.pvr;
+ copy->vendor = model->vendor;
+
+ return copy;
+}
+
+static struct ppc64_model *
ppc64ModelFind(const struct ppc64_map *map,
const char *name)
{
@@ -111,65 +154,41 @@ ppc64ModelFindPVR(const struct ppc64_map *map,
}
static struct ppc64_model *
-ppc64ModelCopy(const struct ppc64_model *model)
+ppc64ModelFromCPU(const virCPUDef *cpu,
+ const struct ppc64_map *map)
{
- struct ppc64_model *copy;
+ struct ppc64_model *model;
- if (VIR_ALLOC(copy) < 0 ||
- VIR_STRDUP(copy->name, model->name) < 0) {
- ppc64ModelFree(copy);
+ if (!(model = ppc64ModelFind(map, cpu->model))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Unknown CPU model %s"), cpu->model);
return NULL;
}
- copy->data.pvr = model->data.pvr;
- copy->vendor = model->vendor;
-
- return copy;
-}
-
-static struct ppc64_vendor *
-ppc64VendorFind(const struct ppc64_map *map,
- const char *name)
-{
- struct ppc64_vendor *vendor;
-
- vendor = map->vendors;
- while (vendor) {
- if (STREQ(vendor->name, name))
- return vendor;
-
- vendor = vendor->next;
- }
-
- return NULL;
+ return ppc64ModelCopy(model);
}
static void
-ppc64VendorFree(struct ppc64_vendor *vendor)
+ppc64MapFree(struct ppc64_map *map)
{
- if (!vendor)
+ if (!map)
return;
- VIR_FREE(vendor->name);
- VIR_FREE(vendor);
-}
-
-static struct ppc64_model *
-ppc64ModelFromCPU(const virCPUDef *cpu,
- const struct ppc64_map *map)
-{
- struct ppc64_model *model;
+ while (map->models) {
+ struct ppc64_model *model = map->models;
+ map->models = model->next;
+ ppc64ModelFree(model);
+ }
- if (!(model = ppc64ModelFind(map, cpu->model))) {
- virReportError(VIR_ERR_INTERNAL_ERROR,
- _("Unknown CPU model %s"), cpu->model);
- return NULL;
+ while (map->vendors) {
+ struct ppc64_vendor *vendor = map->vendors;
+ map->vendors = vendor->next;
+ ppc64VendorFree(vendor);
}
- return ppc64ModelCopy(model);
+ VIR_FREE(map);
}
-
static int
ppc64VendorLoad(xmlXPathContextPtr ctxt,
struct ppc64_map *map)
@@ -293,27 +312,6 @@ ppc64MapLoadCallback(cpuMapElement element,
return 0;
}
-static void
-ppc64MapFree(struct ppc64_map *map)
-{
- if (!map)
- return;
-
- while (map->models) {
- struct ppc64_model *model = map->models;
- map->models = model->next;
- ppc64ModelFree(model);
- }
-
- while (map->vendors) {
- struct ppc64_vendor *vendor = map->vendors;
- map->vendors = vendor->next;
- ppc64VendorFree(vendor);
- }
-
- VIR_FREE(map);
-}
-
static struct ppc64_map *
ppc64LoadMap(void)
{
@@ -500,7 +498,6 @@ ppc64DriverDecode(virCPUDefPtr cpu,
return ret;
}
-
static void
ppc64DriverFree(virCPUDataPtr data)
{
--
2.4.3