提交 b8984770 编写于 作者: E Eric Blake

maint: avoid 'const fooPtr' in tests

'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 the testsuite.

* tests/cputest.c (cpuTestCompareXML): Use intended type.
* tests/qemucapabilitiestest.c (testQemuCaps): Likewise.
* tests/qemumonitorjsontest.c: Drop const.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 1b7ec657
/* /*
* cputest.c: Test the libvirtd internal CPU APIs * cputest.c: Test the libvirtd internal CPU APIs
* *
* Copyright (C) 2010-2012 Red Hat, Inc. * Copyright (C) 2010-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
...@@ -153,7 +153,7 @@ cleanup_cpus: ...@@ -153,7 +153,7 @@ cleanup_cpus:
static int static int
cpuTestCompareXML(const char *arch, cpuTestCompareXML(const char *arch,
const virCPUDefPtr cpu, virCPUDef *cpu,
const char *name, const char *name,
unsigned int flags) unsigned int flags)
{ {
......
...@@ -163,7 +163,7 @@ static int ...@@ -163,7 +163,7 @@ static int
testQemuCaps(const void *opaque) testQemuCaps(const void *opaque)
{ {
int ret = -1; int ret = -1;
const testQemuDataPtr data = (const testQemuDataPtr) opaque; const testQemuData *data = opaque;
char *repliesFile = NULL, *capsFile = NULL; char *repliesFile = NULL, *capsFile = NULL;
char *replies = NULL, *caps = NULL; char *replies = NULL, *caps = NULL;
qemuMonitorTestPtr mon = NULL; qemuMonitorTestPtr mon = NULL;
......
...@@ -524,7 +524,7 @@ cleanup: ...@@ -524,7 +524,7 @@ cleanup:
static int static int
testQemuMonitorJSONGetTPMModels(const void *data) testQemuMonitorJSONGetTPMModels(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
char **tpmmodels = NULL; char **tpmmodels = NULL;
...@@ -577,7 +577,7 @@ cleanup: ...@@ -577,7 +577,7 @@ cleanup:
static int static int
testQemuMonitorJSONGetCommandLineOptionParameters(const void *data) testQemuMonitorJSONGetCommandLineOptionParameters(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
char **params = NULL; char **params = NULL;
...@@ -678,7 +678,7 @@ cleanup: ...@@ -678,7 +678,7 @@ cleanup:
static int static int
testQemuMonitorJSONAttachChardev(const void *data) testQemuMonitorJSONAttachChardev(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
virDomainChrSourceDef chr; virDomainChrSourceDef chr;
int ret = 0; int ret = 0;
...@@ -759,7 +759,7 @@ cleanup: ...@@ -759,7 +759,7 @@ cleanup:
static int static int
testQemuMonitorJSONDetachChardev(const void *data) testQemuMonitorJSONDetachChardev(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
...@@ -792,7 +792,7 @@ cleanup: ...@@ -792,7 +792,7 @@ cleanup:
static int static int
testQemuMonitorJSONGetListPaths(const void *data) testQemuMonitorJSONGetListPaths(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
qemuMonitorJSONListPathPtr *paths; qemuMonitorJSONListPathPtr *paths;
...@@ -870,7 +870,7 @@ cleanup: ...@@ -870,7 +870,7 @@ cleanup:
static int static int
testQemuMonitorJSONGetObjectProperty(const void *data) testQemuMonitorJSONGetObjectProperty(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
qemuMonitorJSONObjectProperty prop; qemuMonitorJSONObjectProperty prop;
...@@ -913,7 +913,7 @@ cleanup: ...@@ -913,7 +913,7 @@ cleanup:
static int static int
testQemuMonitorJSONSetObjectProperty(const void *data) testQemuMonitorJSONSetObjectProperty(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
qemuMonitorJSONObjectProperty prop; qemuMonitorJSONObjectProperty prop;
...@@ -965,7 +965,7 @@ cleanup: ...@@ -965,7 +965,7 @@ cleanup:
static int static int
testQemuMonitorJSONGetDeviceAliases(const void *data) testQemuMonitorJSONGetDeviceAliases(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
char **aliases = NULL; char **aliases = NULL;
...@@ -1025,7 +1025,7 @@ cleanup: ...@@ -1025,7 +1025,7 @@ cleanup:
static int static int
testQemuMonitorJSONCPU(const void *data) testQemuMonitorJSONCPU(const void *data)
{ {
const virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data; virDomainXMLOptionPtr xmlopt = (virDomainXMLOptionPtr)data;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
int ret = -1; int ret = -1;
bool running = false; bool running = false;
...@@ -1084,7 +1084,8 @@ cleanup: ...@@ -1084,7 +1084,8 @@ cleanup:
static int static int
testQemuMonitorJSONSimpleFunc(const void *opaque) testQemuMonitorJSONSimpleFunc(const void *opaque)
{ {
const testQemuMonitorJSONSimpleFuncDataPtr data = (const testQemuMonitorJSONSimpleFuncDataPtr) opaque; testQemuMonitorJSONSimpleFuncDataPtr data =
(testQemuMonitorJSONSimpleFuncDataPtr) opaque;
virDomainXMLOptionPtr xmlopt = data->xmlopt; virDomainXMLOptionPtr xmlopt = data->xmlopt;
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt);
const char *reply = data->reply; const char *reply = data->reply;
...@@ -1112,8 +1113,7 @@ cleanup: ...@@ -1112,8 +1113,7 @@ cleanup:
static int \ static int \
testQemuMonitorJSON ## funcName(const void *opaque) \ testQemuMonitorJSON ## funcName(const void *opaque) \
{ \ { \
const testQemuMonitorJSONSimpleFuncDataPtr data = \ const testQemuMonitorJSONSimpleFuncData *data = opaque; \
(const testQemuMonitorJSONSimpleFuncDataPtr) opaque; \
virDomainXMLOptionPtr xmlopt = data->xmlopt; \ virDomainXMLOptionPtr xmlopt = data->xmlopt; \
qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); \ qemuMonitorTestPtr test = qemuMonitorTestNewSimple(true, xmlopt); \
const char *reply = data->reply; \ const char *reply = data->reply; \
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册