gstpromise: Don't use g_return_* for internal checks

If assertion/checks are disabled bad things will happen and the function won't
return as expected

Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6993>
This commit is contained in:
Edward Hervey 2024-06-05 10:38:57 +02:00 committed by GStreamer Marge Bot
parent df33ae2da6
commit 4f94749665
2 changed files with 10 additions and 12 deletions

View file

@ -174,10 +174,9 @@ gst_promise_reply (GstPromise * promise, GstStructure * s)
g_mutex_lock (GST_PROMISE_LOCK (promise));
if (GST_PROMISE_RESULT (promise) != GST_PROMISE_RESULT_PENDING &&
GST_PROMISE_RESULT (promise) != GST_PROMISE_RESULT_INTERRUPTED) {
GstPromiseResult result = GST_PROMISE_RESULT (promise);
g_warning ("Promise result isn't PENDING or INTERRUPTED");
g_mutex_unlock (GST_PROMISE_LOCK (promise));
g_return_if_fail (result == GST_PROMISE_RESULT_PENDING ||
result == GST_PROMISE_RESULT_INTERRUPTED);
return;
}
/* XXX: is this necessary and valid? */
@ -232,9 +231,9 @@ gst_promise_get_reply (GstPromise * promise)
g_mutex_lock (GST_PROMISE_LOCK (promise));
if (GST_PROMISE_RESULT (promise) != GST_PROMISE_RESULT_REPLIED) {
GstPromiseResult result = GST_PROMISE_RESULT (promise);
g_warning ("Promise result isn't REPLIED");
g_mutex_unlock (GST_PROMISE_LOCK (promise));
g_return_val_if_fail (result == GST_PROMISE_RESULT_REPLIED, NULL);
return NULL;
}
g_mutex_unlock (GST_PROMISE_LOCK (promise));
@ -263,10 +262,9 @@ gst_promise_interrupt (GstPromise * promise)
g_mutex_lock (GST_PROMISE_LOCK (promise));
if (GST_PROMISE_RESULT (promise) != GST_PROMISE_RESULT_PENDING &&
GST_PROMISE_RESULT (promise) != GST_PROMISE_RESULT_REPLIED) {
GstPromiseResult result = GST_PROMISE_RESULT (promise);
g_warning ("Promise result isn't PENDING or REPLIED");
g_mutex_unlock (GST_PROMISE_LOCK (promise));
g_return_if_fail (result == GST_PROMISE_RESULT_PENDING ||
result == GST_PROMISE_RESULT_REPLIED);
return;
}
/* only interrupt if we are currently in pending */
if (GST_PROMISE_RESULT (promise) == GST_PROMISE_RESULT_PENDING) {

View file

@ -315,7 +315,7 @@ GST_START_TEST (test_reply_reply)
gst_promise_reply (r, s);
fail_unless (data.result == GST_PROMISE_RESULT_REPLIED);
fail_unless (data.change_count == 1);
ASSERT_CRITICAL (gst_promise_reply (r, NULL));
ASSERT_WARNING (gst_promise_reply (r, NULL));
fail_unless (gst_promise_wait (r) == GST_PROMISE_RESULT_REPLIED);
ret = gst_promise_get_reply (r);
fail_unless (gst_structure_is_equal (ret, s));
@ -372,7 +372,7 @@ GST_START_TEST (test_interrupt_interrupt)
gst_promise_interrupt (r);
fail_unless (data.result == GST_PROMISE_RESULT_INTERRUPTED);
fail_unless (data.change_count == 1);
ASSERT_CRITICAL (gst_promise_interrupt (r));
ASSERT_WARNING (gst_promise_interrupt (r));
fail_unless (data.result == GST_PROMISE_RESULT_INTERRUPTED);
fail_unless (data.change_count == 1);
@ -408,7 +408,7 @@ GST_START_TEST (test_expire_interrupt)
gst_promise_expire (r);
fail_unless (data.result == GST_PROMISE_RESULT_EXPIRED);
fail_unless (data.change_count == 1);
ASSERT_CRITICAL (gst_promise_interrupt (r));
ASSERT_WARNING (gst_promise_interrupt (r));
fail_unless (data.result == GST_PROMISE_RESULT_EXPIRED);
fail_unless (data.change_count == 1);
@ -426,7 +426,7 @@ GST_START_TEST (test_expire_reply)
gst_promise_expire (r);
fail_unless (data.result == GST_PROMISE_RESULT_EXPIRED);
fail_unless (data.change_count == 1);
ASSERT_CRITICAL (gst_promise_reply (r, NULL));
ASSERT_WARNING (gst_promise_reply (r, NULL));
fail_unless (data.result == GST_PROMISE_RESULT_EXPIRED);
fail_unless (data.change_count == 1);