mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +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;
|
||||
tmp->nodename = g_strdup(info->nodename);
|
||||
|
||||
if (info->nodename)
|
||||
tmp->nodename = g_strdup(info->nodename);
|
||||
g_hash_table_insert(table, g_strdup(entryname), tmp);
|
||||
|
||||
if (virHashAddEntry(table, entryname, tmp) < 0)
|
||||
goto cleanup;
|
||||
|
||||
tmp = NULL;
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
if (tmp)
|
||||
VIR_FREE(tmp->nodename);
|
||||
VIR_FREE(tmp);
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user