mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-08 16:54:49 +00:00
qemuMonitorJSONBlockInfoAdd: Refactor hash table addition
Open code virHashAddEntry so that the error code path can be avoided. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
04a248eb01
commit
a1ef0b129a
@ -2220,27 +2220,21 @@ qemuMonitorJSONBlockInfoAdd(GHashTable *table,
|
||||
const char *entryname)
|
||||
{
|
||||
struct qemuDomainDiskInfo *tmp = NULL;
|
||||
int ret = -1;
|
||||
|
||||
if (g_hash_table_contains(table, entryname)) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("Duplicate block info for '%s'"), entryname);
|
||||
return -1;
|
||||
}
|
||||
|
||||
tmp = g_new0(struct qemuDomainDiskInfo, 1);
|
||||
|
||||
*tmp = *info;
|
||||
tmp->nodename = NULL;
|
||||
|
||||
if (info->nodename)
|
||||
tmp->nodename = g_strdup(info->nodename);
|
||||
|
||||
if (virHashAddEntry(table, entryname, tmp) < 0)
|
||||
goto cleanup;
|
||||
g_hash_table_insert(table, g_strdup(entryname), tmp);
|
||||
|
||||
tmp = NULL;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (tmp)
|
||||
VIR_FREE(tmp->nodename);
|
||||
VIR_FREE(tmp);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user