mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
tests: use g_autoptr instead of virJSONValueFree
Signed-off-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Laine Stump <laine@redhat.com>
This commit is contained in:
parent
296f7173ed
commit
24b5739682
@ -87,7 +87,7 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
|
||||
const char *line,
|
||||
qemuMonitorMessage *msg)
|
||||
{
|
||||
virJSONValue *value = NULL;
|
||||
g_autoptr(virJSONValue) value = NULL;
|
||||
g_autofree char *json = NULL;
|
||||
int ret;
|
||||
|
||||
@ -115,6 +115,5 @@ qemuMonitorJSONIOProcessLine(qemuMonitor *mon,
|
||||
}
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(value);
|
||||
return ret;
|
||||
}
|
||||
|
@ -37,7 +37,7 @@ static int
|
||||
testQemuCommandBuildFromJSON(const void *opaque)
|
||||
{
|
||||
const testQemuCommandBuildObjectFromJSONData *data = opaque;
|
||||
virJSONValue *val = NULL;
|
||||
g_autoptr(virJSONValue) val = NULL;
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
g_autofree char *result = NULL;
|
||||
int ret = -1;
|
||||
@ -65,7 +65,6 @@ testQemuCommandBuildFromJSON(const void *opaque)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virJSONValueFree(val);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -2507,8 +2507,8 @@ testBlockNodeNameDetect(const void *opaque)
|
||||
const char *pathprefix = "qemumonitorjsondata/qemumonitorjson-nodename-";
|
||||
g_autofree char *resultFile = NULL;
|
||||
g_autofree char *actual = NULL;
|
||||
virJSONValue *namedNodesJson = NULL;
|
||||
virJSONValue *blockstatsJson = NULL;
|
||||
g_autoptr(virJSONValue) namedNodesJson = NULL;
|
||||
g_autoptr(virJSONValue) blockstatsJson = NULL;
|
||||
GHashTable *nodedata = NULL;
|
||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||
int ret = -1;
|
||||
@ -2541,8 +2541,6 @@ testBlockNodeNameDetect(const void *opaque)
|
||||
|
||||
cleanup:
|
||||
virHashFree(nodedata);
|
||||
virJSONValueFree(namedNodesJson);
|
||||
virJSONValueFree(blockstatsJson);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -2584,7 +2582,7 @@ testQAPISchemaValidate(const void *opaque)
|
||||
const struct testQAPISchemaData *data = opaque;
|
||||
g_auto(virBuffer) debug = VIR_BUFFER_INITIALIZER;
|
||||
virJSONValue *schemaroot;
|
||||
virJSONValue *json = NULL;
|
||||
g_autoptr(virJSONValue) json = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (virQEMUQAPISchemaPathGet(data->query, data->schema, &schemaroot) < 0)
|
||||
@ -2610,7 +2608,6 @@ testQAPISchemaValidate(const void *opaque)
|
||||
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(json);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -2927,7 +2924,7 @@ mymain(void)
|
||||
virQEMUDriver driver;
|
||||
testQemuMonitorJSONSimpleFuncData simpleFunc;
|
||||
struct testQAPISchemaData qapiData;
|
||||
virJSONValue *metaschema = NULL;
|
||||
g_autoptr(virJSONValue) metaschema = NULL;
|
||||
g_autofree char *metaschemastr = NULL;
|
||||
|
||||
if (qemuTestDriverInit(&driver) < 0)
|
||||
@ -3220,7 +3217,6 @@ mymain(void)
|
||||
DO_TEST(qemuMonitorJSONGetCPUModelBaseline);
|
||||
|
||||
cleanup:
|
||||
virJSONValueFree(metaschema);
|
||||
virHashFree(qapiData.schema);
|
||||
qemuTestDriverFree(&driver);
|
||||
return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
@ -188,7 +188,7 @@ static char *testGenerateJSON(const char *server_name)
|
||||
{
|
||||
virNetDaemon *dmn = NULL;
|
||||
virNetServer *srv = NULL;
|
||||
virJSONValue *json = NULL;
|
||||
g_autoptr(virJSONValue) json = NULL;
|
||||
char *jsonstr = NULL;
|
||||
bool has_ipv4, has_ipv6;
|
||||
|
||||
@ -226,7 +226,6 @@ static char *testGenerateJSON(const char *server_name)
|
||||
virNetServerClose(srv);
|
||||
virObjectUnref(srv);
|
||||
virObjectUnref(dmn);
|
||||
virJSONValueFree(json);
|
||||
if (!jsonstr)
|
||||
virDispatchError(NULL);
|
||||
return jsonstr;
|
||||
|
Loading…
Reference in New Issue
Block a user