Fix casts in a bunch of inline functions to maintain correct const-ness
authorJeffrey S. Smith <whydoubt@yahoo.com>
Wed, 1 Sep 2010 23:01:25 +0000 (00:01 +0100)
committerTim-Philipp Müller <tim.muller@collabora.co.uk>
Wed, 1 Sep 2010 23:09:08 +0000 (00:09 +0100)
Make code including GStreamer headers compile with -Wcast-qual by
maintaining const-ness when casting. Also fix function signature of
gst_byte_writer_set_pos(): the byte writer should not be marked as
const.

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

docs/gst/gstreamer-sections.txt
gst/gstbuffer.h
gst/gstbufferlist.h
gst/gstevent.h
gst/gstmessage.h
gst/gstminiobject.h
gst/gstquery.h
gst/gstutils.h
libs/gst/base/gstbytewriter.h

index 4488983..361ed23 100644 (file)
@@ -1263,6 +1263,7 @@ GST_MINI_OBJECT_GET_CLASS
 GST_TYPE_MINI_OBJECT
 GST_TYPE_MINI_OBJECT_FLAGS
 GST_MINI_OBJECT_CAST
+GST_MINI_OBJECT_CONST_CAST
 
 GST_IS_PARAM_SPEC_MINI_OBJECT
 GST_PARAM_SPEC_MINI_OBJECT
index 44c3210..730ff81 100644 (file)
@@ -380,7 +380,7 @@ G_INLINE_FUNC GstBuffer * gst_buffer_copy (const GstBuffer * buf);
 static inline GstBuffer *
 gst_buffer_copy (const GstBuffer * buf)
 {
-  return GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT_CAST (buf)));
+  return GST_BUFFER (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (buf)));
 }
 
 
index c75a07b..635817e 100644 (file)
@@ -179,7 +179,7 @@ G_INLINE_FUNC GstBufferList * gst_buffer_list_copy (const GstBufferList * list);
 static inline GstBufferList *
 gst_buffer_list_copy (const GstBufferList * list)
 {
-  return GST_BUFFER_LIST_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (list)));
+  return GST_BUFFER_LIST_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (list)));
 }
 
 /**
index 6fc809f..7ee460d 100644 (file)
@@ -400,7 +400,7 @@ G_INLINE_FUNC GstEvent * gst_event_copy (const GstEvent * event);
 static inline GstEvent *
 gst_event_copy (const GstEvent * event)
 {
-  return GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (event)));
+  return GST_EVENT_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (event)));
 }
 
 
index 83c280f..d845c32 100644 (file)
@@ -341,7 +341,7 @@ G_INLINE_FUNC GstMessage * gst_message_copy (const GstMessage * msg);
 static inline GstMessage *
 gst_message_copy (const GstMessage * msg)
 {
-  return GST_MESSAGE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (msg)));
+  return GST_MESSAGE_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (msg)));
 }
 
 /**
index da05a31..9bb56d6 100644 (file)
@@ -36,6 +36,7 @@ G_BEGIN_DECLS
 #define GST_MINI_OBJECT(obj)          (G_TYPE_CHECK_INSTANCE_CAST ((obj), GST_TYPE_MINI_OBJECT, GstMiniObject))
 #define GST_MINI_OBJECT_CLASS(klass)  (G_TYPE_CHECK_CLASS_CAST ((klass), GST_TYPE_MINI_OBJECT, GstMiniObjectClass))
 #define GST_MINI_OBJECT_CAST(obj)     ((GstMiniObject*)(obj))
+#define GST_MINI_OBJECT_CONST_CAST(obj) ((const GstMiniObject*)(obj))
 
 typedef struct _GstMiniObject GstMiniObject;
 typedef struct _GstMiniObjectClass GstMiniObjectClass;
index ae9b07b..7077dc6 100644 (file)
@@ -237,7 +237,7 @@ G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
 static inline GstQuery *
 gst_query_copy (const GstQuery * q)
 {
-  return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CAST (q)));
+  return GST_QUERY_CAST (gst_mini_object_copy (GST_MINI_OBJECT_CONST_CAST (q)));
 }
 
 /**
index f91b777..fad4ff5 100644 (file)
@@ -270,7 +270,7 @@ GST_BOILERPLATE_FULL (type, type_as_function, parent_type,              \
 
 /* Define PUT and GET functions for unaligned memory */
 #define _GST_GET(__data, __idx, __size, __shift) \
-    (((guint##__size) (((guint8 *) (__data))[__idx])) << (__shift))
+    (((guint##__size) (((const guint8 *) (__data))[__idx])) << (__shift))
 
 #define _GST_PUT(__data, __idx, __size, __shift, __num) \
     (((guint8 *) (__data))[__idx] = (((guint##__size) (__num)) >> (__shift)) & 0xff)
index 743e9db..fe1881f 100644 (file)
@@ -94,17 +94,17 @@ GstBuffer *gst_byte_writer_reset_and_get_buffer (GstByteWriter *writer);
  */
 #ifdef _FOOL_GTK_DOC_
 G_INLINE_FUNC guint gst_byte_writer_get_pos (const GstByteWriter *writer);
-G_INLINE_FUNC gboolean gst_byte_writer_set_pos (const GstByteWriter *writer, guint pos);
+G_INLINE_FUNC gboolean gst_byte_writer_set_pos (GstByteWriter *writer, guint pos);
 G_INLINE_FUNC guint gst_byte_writer_get_size (const GstByteWriter *writer);
 #else
 static inline guint
 gst_byte_writer_get_pos (const GstByteWriter *writer)
 {
-  return gst_byte_reader_get_pos (GST_BYTE_READER (writer));
+  return gst_byte_reader_get_pos ((const GstByteReader *) writer);
 }
 
 static inline gboolean
-gst_byte_writer_set_pos (const GstByteWriter *writer, guint pos)
+gst_byte_writer_set_pos (GstByteWriter *writer, guint pos)
 {
   return gst_byte_reader_set_pos (GST_BYTE_READER (writer), pos);
 }
@@ -112,7 +112,7 @@ gst_byte_writer_set_pos (const GstByteWriter *writer, guint pos)
 static inline guint
 gst_byte_writer_get_size (const GstByteWriter *writer)
 {
-  return gst_byte_reader_get_size (GST_BYTE_READER (writer));
+  return gst_byte_reader_get_size ((const GstByteReader *) writer);
 }
 #endif