mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
tests: qemuMonitorTestAddErrorResponse: use VIR_AUTOFREE
Use VIR_AUTOFREE. Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
6806051078
commit
87bd437777
@ -124,11 +124,10 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
|
|||||||
const char *usermsg)
|
const char *usermsg)
|
||||||
{
|
{
|
||||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *escapemsg = NULL;
|
VIR_AUTOFREE(char *) escapemsg = NULL;
|
||||||
char *jsonmsg = NULL;
|
VIR_AUTOFREE(char *) jsonmsg = NULL;
|
||||||
const char *monmsg = NULL;
|
const char *monmsg = NULL;
|
||||||
char *tmp;
|
char *tmp;
|
||||||
int ret = -1;
|
|
||||||
|
|
||||||
if (!usermsg)
|
if (!usermsg)
|
||||||
usermsg = "unexpected command";
|
usermsg = "unexpected command";
|
||||||
@ -136,7 +135,7 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
|
|||||||
if (test->json || test->agent) {
|
if (test->json || test->agent) {
|
||||||
virBufferEscape(&buf, '\\', "\"", "%s", usermsg);
|
virBufferEscape(&buf, '\\', "\"", "%s", usermsg);
|
||||||
if (virBufferCheckError(&buf) < 0)
|
if (virBufferCheckError(&buf) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
escapemsg = virBufferContentAndReset(&buf);
|
escapemsg = virBufferContentAndReset(&buf);
|
||||||
|
|
||||||
/* replace newline/carriage return with space */
|
/* replace newline/carriage return with space */
|
||||||
@ -153,19 +152,14 @@ qemuMonitorTestAddErrorResponse(qemuMonitorTestPtr test,
|
|||||||
" { \"desc\": \"%s\", "
|
" { \"desc\": \"%s\", "
|
||||||
" \"class\": \"UnexpectedCommand\" } }",
|
" \"class\": \"UnexpectedCommand\" } }",
|
||||||
escapemsg) < 0)
|
escapemsg) < 0)
|
||||||
goto error;
|
return -1;
|
||||||
|
|
||||||
monmsg = jsonmsg;
|
monmsg = jsonmsg;
|
||||||
} else {
|
} else {
|
||||||
monmsg = usermsg;
|
monmsg = usermsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = qemuMonitorTestAddResponse(test, monmsg);
|
return qemuMonitorTestAddResponse(test, monmsg);
|
||||||
|
|
||||||
error:
|
|
||||||
VIR_FREE(escapemsg);
|
|
||||||
VIR_FREE(jsonmsg);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user