]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
nwfilter: Introduce virNWFilterObjNew
authorJohn Ferlan <jferlan@redhat.com>
Thu, 20 Apr 2017 15:15:28 +0000 (11:15 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Wed, 26 Apr 2017 17:13:18 +0000 (13:13 -0400)
Perform the object initialization in a helper rather than inline.

Signed-off-by: John Ferlan <jferlan@redhat.com>
src/conf/virnwfilterobj.c

index 77d5c1e0d3063f96be5fd768197181182045b565..7c21327249a25a8d40756d02c4dd736a0aed9c44 100644 (file)
@@ -43,6 +43,26 @@ struct _virNWFilterObj {
 };
 
 
+static virNWFilterObjPtr
+virNWFilterObjNew(void)
+{
+    virNWFilterObjPtr obj;
+
+    if (VIR_ALLOC(obj) < 0)
+        return NULL;
+
+    if (virMutexInitRecursive(&obj->lock) < 0) {
+        virReportError(VIR_ERR_INTERNAL_ERROR,
+                       "%s", _("cannot initialize mutex"));
+        VIR_FREE(obj);
+        return NULL;
+    }
+
+    virNWFilterObjLock(obj);
+    return obj;
+}
+
+
 virNWFilterDefPtr
 virNWFilterObjGetDef(virNWFilterObjPtr obj)
 {
@@ -321,16 +341,8 @@ virNWFilterObjAssignDef(virNWFilterObjListPtr nwfilters,
         return obj;
     }
 
-    if (VIR_ALLOC(obj) < 0)
-        return NULL;
-
-    if (virMutexInitRecursive(&obj->lock) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       "%s", _("cannot initialize mutex"));
-        VIR_FREE(obj);
+    if (!(obj = virNWFilterObjNew()))
         return NULL;
-    }
-    virNWFilterObjLock(obj);
 
     if (VIR_APPEND_ELEMENT_COPY(nwfilters->objs,
                                 nwfilters->count, obj) < 0) {