From: Peter Krempa Date: Wed, 12 Jan 2022 09:28:23 +0000 (+0100) Subject: virDomainMomentAssignDef: Simplify error handling X-Git-Tag: v8.1.0-rc1~458 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ebfe9b1a158a917f89bda45e4d93b9a8d88339ad;p=thirdparty%2Flibvirt.git 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 Reviewed-by: Ján Tomko --- diff --git a/src/conf/virdomainmomentobjlist.c b/src/conf/virdomainmomentobjlist.c index 8993c2310b..2f2467d13f 100644 --- a/src/conf/virdomainmomentobjlist.c +++ b/src/conf/virdomainmomentobjlist.c @@ -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; }