]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
virDomainMomentAssignDef: Simplify error handling
authorPeter Krempa <pkrempa@redhat.com>
Wed, 12 Jan 2022 09:28:23 +0000 (10:28 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Fri, 14 Jan 2022 17:05:29 +0000 (18:05 +0100)
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>
src/conf/virdomainmomentobjlist.c

index 8993c2310bc8aec21f711d78c0bbeaa79e62eeb1..2f2467d13f14234ffa4433d63bdb3633e4198156 100644 (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;
 }