mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-06 20:00:05 +00:00
qemuMonitorTestAddItemVerbatim: Simplify cleanup
Reformat the JSON string before allocating the test data structure so that we don't have to free it if the reformatting fails. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2380242928
commit
d74f8e95e3
@ -673,24 +673,21 @@ qemuMonitorTestAddItemVerbatim(qemuMonitorTest *test,
|
||||
const char *response)
|
||||
{
|
||||
struct qemuMonitorTestHandlerData *data;
|
||||
char *reformatted = NULL;
|
||||
|
||||
if (!(reformatted = virJSONStringReformat(command, false)))
|
||||
return -1;
|
||||
|
||||
data = g_new0(struct qemuMonitorTestHandlerData, 1);
|
||||
|
||||
data->response = g_strdup(response);
|
||||
data->cmderr = g_strdup(cmderr);
|
||||
|
||||
data->command_name = virJSONStringReformat(command, false);
|
||||
if (!data->command_name)
|
||||
goto error;
|
||||
data->command_name = g_steal_pointer(&reformatted);
|
||||
|
||||
return qemuMonitorTestAddHandler(test,
|
||||
command,
|
||||
qemuMonitorTestProcessCommandVerbatim,
|
||||
data, qemuMonitorTestHandlerDataFree);
|
||||
|
||||
error:
|
||||
qemuMonitorTestHandlerDataFree(data);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user