No statements with side-effects in g_assert() or g_return_*() please
authorTim-Philipp Müller <tim@centricular.net>
Wed, 8 Aug 2012 09:11:48 +0000 (10:11 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Wed, 8 Aug 2012 09:11:48 +0000 (10:11 +0100)
ext/ogg/gstoggmux.c
gst-libs/gst/tag/gstvorbistag.c
gst/tcp/gstmultifdsink.c
tests/check/pipelines/capsfilter-renegotiation.c
tests/examples/playrec/playrec.c

index 943c94a..ae6dc27 100644 (file)
@@ -1209,7 +1209,8 @@ gst_ogg_mux_make_fishead (GstOggMux * mux, ogg_stream_state * os)
 static void
 gst_ogg_mux_byte_writer_put_string_utf8 (GstByteWriter * bw, const char *s)
 {
-  g_assert (gst_byte_writer_put_data (bw, (const guint8 *) s, strlen (s)));
+  if (!gst_byte_writer_put_data (bw, (const guint8 *) s, strlen (s)))
+    GST_ERROR ("put_data failed");
 }
 
 static void
index 38893b1..d45a219 100644 (file)
@@ -513,7 +513,9 @@ gst_tag_list_from_vorbiscomment_buffer (GstBuffer * buffer,
   GstTagList *res;
   GstMapInfo info;
 
-  g_assert (gst_buffer_map (buffer, &info, GST_MAP_READ));
+  if (!gst_buffer_map (buffer, &info, GST_MAP_READ))
+    g_return_val_if_reached (NULL);
+
   res =
       gst_tag_list_from_vorbiscomment (info.data, info.size, id_data,
       id_data_length, vendor_string);
index 8b5b3dc..ffecee1 100644 (file)
@@ -662,7 +662,9 @@ gst_multi_fd_sink_handle_client_write (GstMultiFdSink * sink,
       /* pick first buffer from list */
       head = GST_BUFFER (mhclient->sending->data);
 
-      g_assert (gst_buffer_map (head, &info, GST_MAP_READ));
+      if (!gst_buffer_map (head, &info, GST_MAP_READ))
+        g_return_val_if_reached (FALSE);
+
       data = info.data;
       maxsize = info.size - mhclient->bufoffset;
 
index 15bc608..c1b8a92 100644 (file)
@@ -119,7 +119,7 @@ run_capsfilter_renegotiation (const gchar * launch_line)
 
   bus = gst_pipeline_get_bus (GST_PIPELINE (pipeline));
 
-  g_assert (gst_element_set_state (pipeline, GST_STATE_PLAYING) !=
+  fail_unless (gst_element_set_state (pipeline, GST_STATE_PLAYING) !=
       GST_STATE_CHANGE_FAILURE);
 
   msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
index 352f65a..9f79a03 100644 (file)
@@ -62,8 +62,10 @@ message_handler (GstBus * bus, GstMessage * message, gpointer user_data)
                   ("prerolled, starting synchronized playback and recording\n");
               /* returns ASYNC because the sink linked to the live source is not
                * prerolled */
-              g_assert (gst_element_set_state (pipeline,
-                      GST_STATE_PLAYING) == GST_STATE_CHANGE_ASYNC);
+              if (gst_element_set_state (pipeline,
+                      GST_STATE_PLAYING) != GST_STATE_CHANGE_ASYNC) {
+                g_warning ("State change failed");
+              }
             }
             break;
           default:
@@ -139,19 +141,25 @@ main (int argc, char *argv[])
 
   g_print ("going to PAUSED\n");
   /* returns NO_PREROLL because we have a live element */
-  g_assert (gst_element_set_state (pipeline,
-          GST_STATE_PAUSED) == GST_STATE_CHANGE_NO_PREROLL);
+  if (gst_element_set_state (pipeline,
+          GST_STATE_PAUSED) != GST_STATE_CHANGE_NO_PREROLL) {
+    g_warning ("Expected state change NO_PREROLL result");
+  }
 
   g_print ("waiting for playback preroll\n");
 #ifndef ASYNC_VERSION
   /* sync wait for preroll on the playback bin and then go to PLAYING */
-  g_assert (gst_element_get_state (play_bin, NULL, NULL,
-          GST_CLOCK_TIME_NONE) == GST_STATE_CHANGE_SUCCESS);
+  if (gst_element_get_state (play_bin, NULL, NULL,
+          GST_CLOCK_TIME_NONE) != GST_STATE_CHANGE_SUCCESS) {
+    g_warning ("Error while waiting for state change");
+  }
   g_print ("prerolled, starting synchronized playback and recording\n");
   /* returns ASYNC because the sink linked to the live source is not
    * prerolled */
-  g_assert (gst_element_set_state (pipeline,
-          GST_STATE_PLAYING) == GST_STATE_CHANGE_ASYNC);
+  if (gst_element_set_state (pipeline,
+          GST_STATE_PLAYING) != GST_STATE_CHANGE_ASYNC) {
+    g_warning ("Expected state change NO_PREROLL result");
+  }
 #endif
 
   g_main_loop_run (loop);