virDomainMomentAssignDef: Simplify error handling

Remove error handling from the call to 'virDomainMomentObjNew' as it
can't return NULL and replace 'virHashAddEntry' by 'g_hash_table_insert'
as we've already checked that snapshot with such name doesn't exist in
the hash table. This removes handling for two impossible errors.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
Peter Krempa 2022-01-12 10:28:23 +01:00
parent abf9eac87c
commit ebfe9b1a15

View File

@ -245,14 +245,9 @@ virDomainMomentAssignDef(virDomainMomentObjList *moments,
return NULL;
}
if (!(moment = virDomainMomentObjNew()))
return NULL;
if (virHashAddEntry(moments->objs, def->name, moment) < 0) {
VIR_FREE(moment);
return NULL;
}
moment = virDomainMomentObjNew();
moment->def = def;
g_hash_table_insert(moments->objs, g_strdup(def->name), moment);
return moment;
}