Use g_autoptr to get rid of the cleanup section. Signed-off-by: Peter Krempa <pkrempa@xxxxxxxxxx> --- src/qemu/qemu_monitor_json.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index 50d93c0c7e..a2f253f731 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -8742,26 +8742,19 @@ qemuMonitorJSONSetBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr qemuMonitorJSONQueryNamedBlockNodes(qemuMonitorPtr mon) { - virJSONValuePtr cmd; - virJSONValuePtr reply = NULL; - virJSONValuePtr ret = NULL; + g_autoptr(virJSONValue) cmd = NULL; + g_autoptr(virJSONValue) reply = NULL; if (!(cmd = qemuMonitorJSONMakeCommand("query-named-block-nodes", NULL))) return NULL; if (qemuMonitorJSONCommand(mon, cmd, &reply) < 0) - goto cleanup; + return NULL; if (qemuMonitorJSONCheckReply(cmd, reply, VIR_JSON_TYPE_ARRAY) < 0) - goto cleanup; - - ret = virJSONValueObjectStealArray(reply, "return"); - - cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); + return NULL; - return ret; + return virJSONValueObjectStealArray(reply, "return"); } -- 2.24.1