utils: Add some attributes and reorganize code to fix compiler warnings
authorSebastian Dröge <sebastian@centricular.com>
Wed, 30 Oct 2013 20:53:36 +0000 (21:53 +0100)
committerSebastian Dröge <sebastian@centricular.com>
Wed, 30 Oct 2013 20:53:36 +0000 (21:53 +0100)
gstutils.c:3659:41: error: format string is not a string literal
[-Werror,-Wformat-nonliteral]
    gchar *expanded = g_strdup_vprintf (stream_id, var_args);

https://bugzilla.gnome.org/show_bug.cgi?id=710621

gst/gstutils.c
gst/gstutils.h

index 33f518c..b9ceb07 100644 (file)
@@ -3563,32 +3563,9 @@ gst_util_fraction_compare (gint a_n, gint a_d, gint b_n, gint b_d)
   g_return_val_if_reached (0);
 }
 
-/**
- * gst_pad_create_stream_id_printf_valist:
- * @pad: A source #GstPad
- * @parent: Parent #GstElement of @pad
- * @stream_id: (allow-none): The stream-id
- * @var_args: parameters for the @stream_id format string
- *
- * Creates a stream-id for the source #GstPad @pad by combining the
- * upstream information with the optional @stream_id of the stream
- * of @pad. @pad must have a parent #GstElement and which must have zero
- * or one sinkpad. @stream_id can only be %NULL if the parent element
- * of @pad has only a single source pad.
- *
- * This function generates an unique stream-id by getting the upstream
- * stream-start event stream ID and appending @stream_id to it. If the
- * element has no sinkpad it will generate an upstream stream-id by
- * doing an URI query on the element and in the worst case just uses
- * a random number. Source elements that don't implement the URI
- * handler interface should ideally generate a unique, deterministic
- * stream-id manually instead.
- *
- * Returns: A stream-id for @pad. g_free() after usage.
- */
-gchar *
-gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
-    const gchar * stream_id, va_list var_args)
+static gchar *
+gst_pad_create_stream_id_internal (GstPad * pad, GstElement * parent,
+    const gchar * stream_id)
 {
   GstEvent *upstream_event;
   gchar *upstream_stream_id = NULL, *new_stream_id;
@@ -3656,9 +3633,7 @@ gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
   }
 
   if (stream_id) {
-    gchar *expanded = g_strdup_vprintf (stream_id, var_args);
-    new_stream_id = g_strconcat (upstream_stream_id, "/", expanded, NULL);
-    g_free (expanded);
+    new_stream_id = g_strconcat (upstream_stream_id, "/", stream_id, NULL);
   } else {
     new_stream_id = g_strdup (upstream_stream_id);
   }
@@ -3669,6 +3644,45 @@ gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
 }
 
 /**
+ * gst_pad_create_stream_id_printf_valist:
+ * @pad: A source #GstPad
+ * @parent: Parent #GstElement of @pad
+ * @stream_id: (allow-none): The stream-id
+ * @var_args: parameters for the @stream_id format string
+ *
+ * Creates a stream-id for the source #GstPad @pad by combining the
+ * upstream information with the optional @stream_id of the stream
+ * of @pad. @pad must have a parent #GstElement and which must have zero
+ * or one sinkpad. @stream_id can only be %NULL if the parent element
+ * of @pad has only a single source pad.
+ *
+ * This function generates an unique stream-id by getting the upstream
+ * stream-start event stream ID and appending @stream_id to it. If the
+ * element has no sinkpad it will generate an upstream stream-id by
+ * doing an URI query on the element and in the worst case just uses
+ * a random number. Source elements that don't implement the URI
+ * handler interface should ideally generate a unique, deterministic
+ * stream-id manually instead.
+ *
+ * Returns: A stream-id for @pad. g_free() after usage.
+ */
+gchar *
+gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent,
+    const gchar * stream_id, va_list var_args)
+{
+  gchar *expanded = NULL, *new_stream_id;
+
+  if (stream_id)
+    expanded = g_strdup_vprintf (stream_id, var_args);
+
+  new_stream_id = gst_pad_create_stream_id_internal (pad, parent, expanded);
+
+  g_free (expanded);
+
+  return new_stream_id;
+}
+
+/**
  * gst_pad_create_stream_id_printf:
  * @pad: A source #GstPad
  * @parent: Parent #GstElement of @pad
@@ -3736,7 +3750,7 @@ gchar *
 gst_pad_create_stream_id (GstPad * pad, GstElement * parent,
     const gchar * stream_id)
 {
-  return gst_pad_create_stream_id_printf (pad, parent, stream_id, NULL);
+  return gst_pad_create_stream_id_internal (pad, parent, stream_id);
 }
 
 /**
index 1530807..b9097b1 100644 (file)
@@ -934,9 +934,9 @@ gboolean                gst_pad_peer_query_convert      (GstPad *pad, GstFormat
 GstCaps *               gst_pad_peer_query_caps         (GstPad * pad, GstCaps *filter);
 gboolean                gst_pad_peer_query_accept_caps  (GstPad * pad, GstCaps *caps);
 
-gchar *                 gst_pad_create_stream_id               (GstPad * pad, GstElement * parent, const gchar *stream_id);
-gchar *                 gst_pad_create_stream_id_printf        (GstPad * pad, GstElement * parent, const gchar *stream_id, ...);
-gchar *                 gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent, const gchar *stream_id, va_list var_args);
+gchar *                 gst_pad_create_stream_id               (GstPad * pad, GstElement * parent, const gchar *stream_id) G_GNUC_MALLOC;
+gchar *                 gst_pad_create_stream_id_printf        (GstPad * pad, GstElement * parent, const gchar *stream_id, ...) G_GNUC_PRINTF (3, 4) G_GNUC_MALLOC;
+gchar *                 gst_pad_create_stream_id_printf_valist (GstPad * pad, GstElement * parent, const gchar *stream_id, va_list var_args) G_GNUC_PRINTF (3, 0) G_GNUC_MALLOC;
 
 gchar *                 gst_pad_get_stream_id           (GstPad * pad);