{element,deviceprovider}factory: g_object_new() can't ever return NULL
authorSebastian Dröge <sebastian@centricular.com>
Wed, 19 Oct 2022 10:34:28 +0000 (13:34 +0300)
committerGStreamer Marge Bot <gitlab-merge-bot@gstreamer-foundation.org>
Wed, 19 Oct 2022 12:09:45 +0000 (12:09 +0000)
So treat it as the assertion it is.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/3226>

subprojects/gstreamer/gst/gstdeviceproviderfactory.c
subprojects/gstreamer/gst/gstelementfactory.c

index 13703ba..8f54f88 100644 (file)
@@ -283,8 +283,10 @@ gst_device_provider_factory_get (GstDeviceProviderFactory * factory)
    * also set name as early as we can
    */
   device_provider = g_object_new (factory->type, NULL);
-  if (G_UNLIKELY (device_provider == NULL))
-    goto no_device_provider;
+  if (G_UNLIKELY (!device_provider)) {
+    gst_object_unref (factory);
+    g_return_val_if_fail (device_provider != NULL, NULL);
+  }
 
   /* fill in the pointer to the factory in the device provider class. The
    * class will not be unreffed currently.
@@ -328,12 +330,6 @@ no_type:
     gst_object_unref (factory);
     return NULL;
   }
-no_device_provider:
-  {
-    GST_WARNING_OBJECT (factory, "could not create device provider");
-    gst_object_unref (factory);
-    return NULL;
-  }
 }
 
 /**
index b94b576..ea3427a 100644 (file)
@@ -493,9 +493,10 @@ gst_element_factory_create_with_properties (GstElementFactory * factory,
 
   element = (GstElement *) g_object_new_with_properties (factory->type, n,
       names, values);
-
-  if (G_UNLIKELY (element == NULL))
-    goto no_element;
+  if (G_UNLIKELY (!element)) {
+    gst_object_unref (factory);
+    g_return_val_if_fail (element != NULL, NULL);
+  }
 
   /* fill in the pointer to the factory in the element class. The
    * class will not be unreffed currently.
@@ -535,12 +536,6 @@ no_type:
     gst_object_unref (factory);
     return NULL;
   }
-no_element:
-  {
-    GST_WARNING_OBJECT (factory, "could not create element");
-    gst_object_unref (factory);
-    return NULL;
-  }
 }
 
 /**