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)
virCPUDefCopyModel(virCPUDefPtr dst,
const virCPUDefPtr src,
const virCPUDef *src,
bool resetPolicy)
{
size_t i;
@ -126,7 +126,7 @@ virCPUDefCopyModel(virCPUDefPtr dst,
}
virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu)
virCPUDefCopy(const virCPUDef *cpu)
{
virCPUDefPtr copy;
size_t i;
@ -174,7 +174,7 @@ error:
}
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
virCPUDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt,
enum virCPUType mode)
{

View File

@ -1,7 +1,7 @@
/*
* 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
* 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)
virCPUDefCopyModel(virCPUDefPtr dst,
const virCPUDefPtr src,
const virCPUDef *src,
bool resetPolicy);
virCPUDefPtr
virCPUDefCopy(const virCPUDefPtr cpu);
virCPUDefCopy(const virCPUDef *cpu);
virCPUDefPtr
virCPUDefParseXML(const xmlNodePtr node,
virCPUDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt,
enum virCPUType mode);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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