maint: avoid 'const fooPtr' in cpu files

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/cpu.

* src/cpu/cpu.h (cpuArchDecode, cpuArchEncode, cpuArchUpdate)
(cpuArchHasFeature, cpuDecode, cpuEncode, cpuUpdate)
(cpuHasFeature): Use intended type.
* src/conf/cpu_conf.h (virCPUDefCopyModel, virCPUDefCopy):
Likewise.
(virCPUDefParseXML): Drop const.
* src/cpu/cpu.c (cpuDecode, cpuEncode, cpuUpdate, cpuHasFeature):
Fix fallout.
* src/cpu/cpu_x86.c (x86ModelFromCPU, x86ModelSubtractCPU)
(x86DecodeCPUData, x86EncodePolicy, x86Encode, x86UpdateCustom)
(x86UpdateHostModel, x86Update, x86HasFeature): Likewise.
* src/cpu/cpu_s390.c (s390Decode): Likewise.
* src/cpu/cpu_arm.c (ArmDecode): Likewise.
* src/cpu/cpu_powerpc.c (ppcModelFromCPU, ppcCompute, ppcDecode)
(ppcUpdate): Likewise.
* src/conf/cpu_conf.c (virCPUDefCopyModel, virCPUDefCopy)
(virCPUDefParseXML): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
Eric Blake 2013-10-05 14:01:02 -06:00
parent 955af4d4c1
commit d694ae0c55
8 changed files with 37 additions and 34 deletions

View File

@ -94,7 +94,7 @@ virCPUDefFree(virCPUDefPtr def)
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
virCPUDefCopyModel(virCPUDefPtr dst, virCPUDefCopyModel(virCPUDefPtr dst,
const virCPUDefPtr src, const virCPUDef *src,
bool resetPolicy) bool resetPolicy)
{ {
size_t i; size_t i;
@ -126,7 +126,7 @@ virCPUDefCopyModel(virCPUDefPtr dst,
} }
virCPUDefPtr virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu) virCPUDefCopy(const virCPUDef *cpu)
{ {
virCPUDefPtr copy; virCPUDefPtr copy;
size_t i; size_t i;
@ -174,7 +174,7 @@ error:
} }
virCPUDefPtr virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node, virCPUDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
enum virCPUType mode) enum virCPUType mode)
{ {

View File

@ -1,7 +1,7 @@
/* /*
* cpu_conf.h: CPU XML handling * cpu_conf.h: CPU XML handling
* *
* Copyright (C) 2009-2011 Red Hat, Inc. * Copyright (C) 2009-2011, 2013 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
@ -131,14 +131,14 @@ virCPUDefFree(virCPUDefPtr def);
int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) int ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2)
virCPUDefCopyModel(virCPUDefPtr dst, virCPUDefCopyModel(virCPUDefPtr dst,
const virCPUDefPtr src, const virCPUDef *src,
bool resetPolicy); bool resetPolicy);
virCPUDefPtr virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu); virCPUDefCopy(const virCPUDef *cpu);
virCPUDefPtr virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node, virCPUDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
enum virCPUType mode); enum virCPUType mode);

View File

@ -132,7 +132,7 @@ cpuCompare(virCPUDefPtr host,
int int
cpuDecode(virCPUDefPtr cpu, cpuDecode(virCPUDefPtr cpu,
const virCPUDataPtr data, const virCPUData *data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred) const char *preferred)
@ -175,7 +175,7 @@ cpuDecode(virCPUDefPtr cpu,
int int
cpuEncode(virArch arch, cpuEncode(virArch arch,
const virCPUDefPtr cpu, const virCPUDef *cpu,
virCPUDataPtr *forced, virCPUDataPtr *forced,
virCPUDataPtr *required, virCPUDataPtr *required,
virCPUDataPtr *optional, virCPUDataPtr *optional,
@ -402,7 +402,7 @@ cpuBaseline(virCPUDefPtr *cpus,
int int
cpuUpdate(virCPUDefPtr guest, cpuUpdate(virCPUDefPtr guest,
const virCPUDefPtr host) const virCPUDef *host)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;
@ -422,7 +422,7 @@ cpuUpdate(virCPUDefPtr guest,
} }
int int
cpuHasFeature(const virCPUDataPtr data, cpuHasFeature(const virCPUData *data,
const char *feature) const char *feature)
{ {
struct cpuArchDriver *driver; struct cpuArchDriver *driver;

View File

@ -50,7 +50,7 @@ typedef virCPUCompareResult
typedef int typedef int
(*cpuArchDecode) (virCPUDefPtr cpu, (*cpuArchDecode) (virCPUDefPtr cpu,
const virCPUDataPtr data, const virCPUData *data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred, const char *preferred,
@ -58,7 +58,7 @@ typedef int
typedef int typedef int
(*cpuArchEncode) (virArch arch, (*cpuArchEncode) (virArch arch,
const virCPUDefPtr cpu, const virCPUDef *cpu,
virCPUDataPtr *forced, virCPUDataPtr *forced,
virCPUDataPtr *required, virCPUDataPtr *required,
virCPUDataPtr *optional, virCPUDataPtr *optional,
@ -87,10 +87,10 @@ typedef virCPUDefPtr
typedef int typedef int
(*cpuArchUpdate) (virCPUDefPtr guest, (*cpuArchUpdate) (virCPUDefPtr guest,
const virCPUDefPtr host); const virCPUDef *host);
typedef int typedef int
(*cpuArchHasFeature) (const virCPUDataPtr data, (*cpuArchHasFeature) (const virCPUData *data,
const char *feature); const char *feature);
@ -120,14 +120,14 @@ cpuCompare (virCPUDefPtr host,
extern int extern int
cpuDecode (virCPUDefPtr cpu, cpuDecode (virCPUDefPtr cpu,
const virCPUDataPtr data, const virCPUData *data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred); const char *preferred);
extern int extern int
cpuEncode (virArch arch, cpuEncode (virArch arch,
const virCPUDefPtr cpu, const virCPUDef *cpu,
virCPUDataPtr *forced, virCPUDataPtr *forced,
virCPUDataPtr *required, virCPUDataPtr *required,
virCPUDataPtr *optional, virCPUDataPtr *optional,
@ -163,10 +163,10 @@ cpuBaseline (virCPUDefPtr *cpus,
extern int extern int
cpuUpdate (virCPUDefPtr guest, cpuUpdate (virCPUDefPtr guest,
const virCPUDefPtr host); const virCPUDef *host);
extern int extern int
cpuHasFeature(const virCPUDataPtr data, cpuHasFeature(const virCPUData *data,
const char *feature); const char *feature);

View File

@ -1,6 +1,7 @@
/* /*
* cpu_arm.c: CPU driver for arm CPUs * cpu_arm.c: CPU driver for arm CPUs
* *
* Copyright (C) 2013 Red Hat, Inc.
* Copyright (C) Canonical Ltd. 2012 * Copyright (C) Canonical Ltd. 2012
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -45,7 +46,7 @@ ArmNodeData(virArch arch)
static int static int
ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, ArmDecode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
const virCPUDataPtr data ATTRIBUTE_UNUSED, const virCPUData *data ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED, const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED, unsigned int nmodels ATTRIBUTE_UNUSED,
const char *preferred ATTRIBUTE_UNUSED, const char *preferred ATTRIBUTE_UNUSED,

View File

@ -1,6 +1,7 @@
/* /*
* cpu_powerpc.c: CPU driver for PowerPC CPUs * cpu_powerpc.c: CPU driver for PowerPC CPUs
* *
* Copyright (C) 2013 Red Hat, Inc.
* Copyright (C) IBM Corporation, 2010 * Copyright (C) IBM Corporation, 2010
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -144,7 +145,7 @@ ppcVendorFree(struct ppc_vendor *vendor)
} }
static struct ppc_model * static struct ppc_model *
ppcModelFromCPU(const virCPUDefPtr cpu, ppcModelFromCPU(const virCPUDef *cpu,
const struct ppc_map *map) const struct ppc_map *map)
{ {
struct ppc_model *model = NULL; struct ppc_model *model = NULL;
@ -345,7 +346,7 @@ ppcMakeCPUData(virArch arch, struct cpuPPCData *data)
static virCPUCompareResult static virCPUCompareResult
ppcCompute(virCPUDefPtr host, ppcCompute(virCPUDefPtr host,
const virCPUDefPtr cpu, const virCPUDef *cpu,
virCPUDataPtr *guestData, virCPUDataPtr *guestData,
char **message) char **message)
@ -448,7 +449,7 @@ ppcCompare(virCPUDefPtr host,
static int static int
ppcDecode(virCPUDefPtr cpu, ppcDecode(virCPUDefPtr cpu,
const virCPUDataPtr data, const virCPUData *data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred ATTRIBUTE_UNUSED, const char *preferred ATTRIBUTE_UNUSED,
@ -529,7 +530,7 @@ ppcGuestData(virCPUDefPtr host,
static int static int
ppcUpdate(virCPUDefPtr guest, ppcUpdate(virCPUDefPtr guest,
const virCPUDefPtr host) const virCPUDef *host)
{ {
switch ((enum virCPUMode) guest->mode) { switch ((enum virCPUMode) guest->mode) {
case VIR_CPU_MODE_HOST_MODEL: case VIR_CPU_MODE_HOST_MODEL:

View File

@ -1,6 +1,7 @@
/* /*
* cpu_s390.c: CPU driver for s390(x) CPUs * cpu_s390.c: CPU driver for s390(x) CPUs
* *
* Copyright (C) 2013 Red Hat, Inc.
* Copyright IBM Corp. 2012 * Copyright IBM Corp. 2012
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
@ -47,7 +48,7 @@ s390NodeData(virArch arch)
static int static int
s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED, s390Decode(virCPUDefPtr cpu ATTRIBUTE_UNUSED,
const virCPUDataPtr data ATTRIBUTE_UNUSED, const virCPUData *data ATTRIBUTE_UNUSED,
const char **models ATTRIBUTE_UNUSED, const char **models ATTRIBUTE_UNUSED,
unsigned int nmodels ATTRIBUTE_UNUSED, unsigned int nmodels ATTRIBUTE_UNUSED,
const char *preferred ATTRIBUTE_UNUSED, const char *preferred ATTRIBUTE_UNUSED,

View File

@ -814,7 +814,7 @@ x86ModelFind(const struct x86_map *map,
static struct x86_model * static struct x86_model *
x86ModelFromCPU(const virCPUDefPtr cpu, x86ModelFromCPU(const virCPUDef *cpu,
const struct x86_map *map, const struct x86_map *map,
int policy) int policy)
{ {
@ -863,7 +863,7 @@ error:
static int static int
x86ModelSubtractCPU(struct x86_model *model, x86ModelSubtractCPU(struct x86_model *model,
const virCPUDefPtr cpu, const virCPUDef *cpu,
const struct x86_map *map) const struct x86_map *map)
{ {
const struct x86_model *cpu_model; const struct x86_model *cpu_model;
@ -1457,7 +1457,7 @@ out:
static int static int
x86DecodeCPUData(virCPUDefPtr cpu, x86DecodeCPUData(virCPUDefPtr cpu,
const virCPUDataPtr data, const virCPUData *data,
const char **models, const char **models,
unsigned int nmodels, unsigned int nmodels,
const char *preferred, const char *preferred,
@ -1468,7 +1468,7 @@ x86DecodeCPUData(virCPUDefPtr cpu,
static struct cpuX86Data * static struct cpuX86Data *
x86EncodePolicy(const virCPUDefPtr cpu, x86EncodePolicy(const virCPUDef *cpu,
const struct x86_map *map, const struct x86_map *map,
enum virCPUFeaturePolicy policy) enum virCPUFeaturePolicy policy)
{ {
@ -1488,7 +1488,7 @@ x86EncodePolicy(const virCPUDefPtr cpu,
static int static int
x86Encode(virArch arch, x86Encode(virArch arch,
const virCPUDefPtr cpu, const virCPUDef *cpu,
virCPUDataPtr *forced, virCPUDataPtr *forced,
virCPUDataPtr *required, virCPUDataPtr *required,
virCPUDataPtr *optional, virCPUDataPtr *optional,
@ -1815,7 +1815,7 @@ error:
static int static int
x86UpdateCustom(virCPUDefPtr guest, x86UpdateCustom(virCPUDefPtr guest,
const virCPUDefPtr host) const virCPUDef *host)
{ {
int ret = -1; int ret = -1;
size_t i; size_t i;
@ -1862,7 +1862,7 @@ cleanup:
static int static int
x86UpdateHostModel(virCPUDefPtr guest, x86UpdateHostModel(virCPUDefPtr guest,
const virCPUDefPtr host) const virCPUDef *host)
{ {
virCPUDefPtr oldguest; virCPUDefPtr oldguest;
size_t i; size_t i;
@ -1896,7 +1896,7 @@ x86UpdateHostModel(virCPUDefPtr guest,
static int static int
x86Update(virCPUDefPtr guest, x86Update(virCPUDefPtr guest,
const virCPUDefPtr host) const virCPUDef *host)
{ {
switch ((enum virCPUMode) guest->mode) { switch ((enum virCPUMode) guest->mode) {
case VIR_CPU_MODE_CUSTOM: case VIR_CPU_MODE_CUSTOM:
@ -1919,7 +1919,7 @@ x86Update(virCPUDefPtr guest,
return -1; return -1;
} }
static int x86HasFeature(const virCPUDataPtr data, static int x86HasFeature(const virCPUData *data,
const char *name) const char *name)
{ {
struct x86_map *map; struct x86_map *map;