mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +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;
|
||||
|
||||
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 ||
|
||||
virJSONValueArrayAppend(arr, m) < 0) {
|
||||
virJSONValueFree(m);
|
||||
if (virJSONValueArrayAppend(arr, m) < 0)
|
||||
return -1;
|
||||
}
|
||||
m = NULL;
|
||||
}
|
||||
|
||||
if (virJSONValueObjectAppendString(obj, "domain", name) < 0 ||
|
||||
|
Loading…
Reference in New Issue
Block a user