mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
qemuAgentMakeCommand: Refactor memory cleanup
Switch to using the 'g_auto*' helpers. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
9a1651f64d
commit
a3f237cb00
@ -1149,33 +1149,28 @@ static virJSONValuePtr G_GNUC_NULL_TERMINATED
|
|||||||
qemuAgentMakeCommand(const char *cmdname,
|
qemuAgentMakeCommand(const char *cmdname,
|
||||||
...)
|
...)
|
||||||
{
|
{
|
||||||
virJSONValuePtr obj = virJSONValueNewObject();
|
g_autoptr(virJSONValue) obj = NULL;
|
||||||
virJSONValuePtr jargs = NULL;
|
g_autoptr(virJSONValue) jargs = NULL;
|
||||||
va_list args;
|
va_list args;
|
||||||
|
|
||||||
va_start(args, cmdname);
|
va_start(args, cmdname);
|
||||||
|
|
||||||
if (virJSONValueObjectAppendString(obj, "execute", cmdname) < 0)
|
if (virJSONValueObjectCreateVArgs(&jargs, args) < 0) {
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (virJSONValueObjectCreateVArgs(&jargs, args) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
if (jargs &&
|
|
||||||
virJSONValueObjectAppend(obj, "arguments", jargs) < 0)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
va_end(args);
|
|
||||||
|
|
||||||
return obj;
|
|
||||||
|
|
||||||
error:
|
|
||||||
virJSONValueFree(obj);
|
|
||||||
virJSONValueFree(jargs);
|
|
||||||
va_end(args);
|
va_end(args);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
va_end(args);
|
||||||
|
|
||||||
|
if (virJSONValueObjectCreate(&obj,
|
||||||
|
"s:execute", cmdname,
|
||||||
|
"A:arguments", &jargs,
|
||||||
|
NULL) < 0)
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return g_steal_pointer(&obj);
|
||||||
|
}
|
||||||
|
|
||||||
static virJSONValuePtr
|
static virJSONValuePtr
|
||||||
qemuAgentMakeStringsArray(const char **strings, unsigned int len)
|
qemuAgentMakeStringsArray(const char **strings, unsigned int len)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user