mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-10 14:57:42 +00:00
virMACMapHashDumper: Refactor array addition
Use automatic memory freeing and don't check return value of virJSONValueNewString as it can't fail. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
83a50fe2a5
commit
d4e369a4c3
@ -214,13 +214,11 @@ virMACMapHashDumper(void *payload,
|
|||||||
GSList *next;
|
GSList *next;
|
||||||
|
|
||||||
for (next = macs; next; next = next->next) {
|
for (next = macs; next; next = next->next) {
|
||||||
virJSONValuePtr m = virJSONValueNewString((const char *) next->data);
|
g_autoptr(virJSONValue) m = virJSONValueNewString((const char *) next->data);
|
||||||
|
|
||||||
if (!m ||
|
if (virJSONValueArrayAppend(arr, m) < 0)
|
||||||
virJSONValueArrayAppend(arr, m) < 0) {
|
|
||||||
virJSONValueFree(m);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
m = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (virJSONValueObjectAppendString(obj, "domain", name) < 0 ||
|
if (virJSONValueObjectAppendString(obj, "domain", name) < 0 ||
|
||||||
|
Loading…
Reference in New Issue
Block a user