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>
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 ||