mirror of https://gitee.com/openkylin/libvirt.git
qemu_monitor_json: Don't check for qemuMonitorNextCommandID() retval
The qemuMonitorNextCommandID() function can never fail. There's no need to check for its retval then. Moreover, the temporary variable used to hold the retval can be declared in the inner most block. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Tim Wiederhake <twiederh@redhat.com>
This commit is contained in:
parent
857df2fe50
commit
139338ab33
|
@ -302,15 +302,14 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
qemuMonitorMessage msg;
|
qemuMonitorMessage msg;
|
||||||
g_auto(virBuffer) cmdbuf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) cmdbuf = VIR_BUFFER_INITIALIZER;
|
||||||
char *id = NULL;
|
|
||||||
|
|
||||||
*reply = NULL;
|
*reply = NULL;
|
||||||
|
|
||||||
memset(&msg, 0, sizeof(msg));
|
memset(&msg, 0, sizeof(msg));
|
||||||
|
|
||||||
if (virJSONValueObjectHasKey(cmd, "execute") == 1) {
|
if (virJSONValueObjectHasKey(cmd, "execute") == 1) {
|
||||||
if (!(id = qemuMonitorNextCommandID(mon)))
|
g_autofree char *id = qemuMonitorNextCommandID(mon);
|
||||||
goto cleanup;
|
|
||||||
if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
|
if (virJSONValueObjectAppendString(cmd, "id", id) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
|
||||||
_("Unable to append command 'id' string"));
|
_("Unable to append command 'id' string"));
|
||||||
|
@ -339,7 +338,6 @@ qemuMonitorJSONCommandWithFd(qemuMonitor *mon,
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
VIR_FREE(id);
|
|
||||||
VIR_FREE(msg.txBuffer);
|
VIR_FREE(msg.txBuffer);
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in New Issue