tests: refactor qemuMonitorTestProcessCommandDefault
Use VIR_AUTOPTR and get rid of the 'ret' variable. Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
20d3c483e8
commit
4659a1985c
@ -584,38 +584,29 @@ qemuMonitorTestProcessCommandDefault(qemuMonitorTestPtr test,
|
|||||||
const char *cmdstr)
|
const char *cmdstr)
|
||||||
{
|
{
|
||||||
struct qemuMonitorTestHandlerData *data = item->opaque;
|
struct qemuMonitorTestHandlerData *data = item->opaque;
|
||||||
virJSONValuePtr val = NULL;
|
VIR_AUTOPTR(virJSONValue) val = NULL;
|
||||||
virJSONValuePtr cmdargs = NULL;
|
virJSONValuePtr cmdargs = NULL;
|
||||||
const char *cmdname;
|
const char *cmdname;
|
||||||
int ret = -1;
|
|
||||||
int rc;
|
int rc;
|
||||||
|
|
||||||
if (!(val = virJSONValueFromString(cmdstr)))
|
if (!(val = virJSONValueFromString(cmdstr)))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
if (!(cmdname = virJSONValueObjectGetString(val, "execute"))) {
|
if (!(cmdname = virJSONValueObjectGetString(val, "execute")))
|
||||||
ret = qemuMonitorReportError(test, "Missing command name in %s", cmdstr);
|
return qemuMonitorReportError(test, "Missing command name in %s", cmdstr);
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
|
|
||||||
cmdargs = virJSONValueObjectGet(val, "arguments");
|
cmdargs = virJSONValueObjectGet(val, "arguments");
|
||||||
if ((rc = qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdargs)) < 0)
|
if ((rc = qemuMonitorTestProcessCommandDefaultValidate(test, cmdname, cmdargs)) < 0)
|
||||||
goto cleanup;
|
return -1;
|
||||||
|
if (rc == 1)
|
||||||
|
return 0;
|
||||||
|
|
||||||
if (rc == 1) {
|
if (data->command_name && STRNEQ(data->command_name, cmdname)) {
|
||||||
ret = 0;
|
return qemuMonitorTestAddInvalidCommandResponse(test, data->command_name,
|
||||||
goto cleanup;
|
cmdname);
|
||||||
|
} else {
|
||||||
|
return qemuMonitorTestAddResponse(test, data->response);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (data->command_name && STRNEQ(data->command_name, cmdname))
|
|
||||||
ret = qemuMonitorTestAddInvalidCommandResponse(test, data->command_name,
|
|
||||||
cmdname);
|
|
||||||
else
|
|
||||||
ret = qemuMonitorTestAddResponse(test, data->response);
|
|
||||||
|
|
||||||
cleanup:
|
|
||||||
virJSONValueFree(val);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user