Fix casts in a bunch of inline functions to maintain correct const-ness

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
This commit is contained in:
Jeffrey S. Smith 2010-09-02 00:01:25 +01:00 committed by Tim-Philipp Müller
parent f9204d5d70
commit 4375e998ee
9 changed files with 12 additions and 10 deletions

View file

@ -1263,6 +1263,7 @@ GST_MINI_OBJECT_GET_CLASS
GST_TYPE_MINI_OBJECT GST_TYPE_MINI_OBJECT
GST_TYPE_MINI_OBJECT_FLAGS GST_TYPE_MINI_OBJECT_FLAGS
GST_MINI_OBJECT_CAST GST_MINI_OBJECT_CAST
GST_MINI_OBJECT_CONST_CAST
GST_IS_PARAM_SPEC_MINI_OBJECT GST_IS_PARAM_SPEC_MINI_OBJECT
GST_PARAM_SPEC_MINI_OBJECT GST_PARAM_SPEC_MINI_OBJECT

View file

@ -380,7 +380,7 @@ G_INLINE_FUNC GstBuffer * gst_buffer_copy (const GstBuffer * buf);
static inline GstBuffer * static inline GstBuffer *
gst_buffer_copy (const GstBuffer * buf) 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)));
} }

View file

@ -179,7 +179,7 @@ G_INLINE_FUNC GstBufferList * gst_buffer_list_copy (const GstBufferList * list);
static inline GstBufferList * static inline GstBufferList *
gst_buffer_list_copy (const GstBufferList * list) 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)));
} }
/** /**

View file

@ -400,7 +400,7 @@ G_INLINE_FUNC GstEvent * gst_event_copy (const GstEvent * event);
static inline GstEvent * static inline GstEvent *
gst_event_copy (const GstEvent * event) 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)));
} }

View file

@ -341,7 +341,7 @@ G_INLINE_FUNC GstMessage * gst_message_copy (const GstMessage * msg);
static inline GstMessage * static inline GstMessage *
gst_message_copy (const GstMessage * msg) 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)));
} }
/** /**

View 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(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_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_CAST(obj) ((GstMiniObject*)(obj))
#define GST_MINI_OBJECT_CONST_CAST(obj) ((const GstMiniObject*)(obj))
typedef struct _GstMiniObject GstMiniObject; typedef struct _GstMiniObject GstMiniObject;
typedef struct _GstMiniObjectClass GstMiniObjectClass; typedef struct _GstMiniObjectClass GstMiniObjectClass;

View file

@ -237,7 +237,7 @@ G_INLINE_FUNC GstQuery * gst_query_copy (const GstQuery * q);
static inline GstQuery * static inline GstQuery *
gst_query_copy (const GstQuery * q) 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)));
} }
/** /**

View file

@ -270,7 +270,7 @@ GST_BOILERPLATE_FULL (type, type_as_function, parent_type, \
/* Define PUT and GET functions for unaligned memory */ /* Define PUT and GET functions for unaligned memory */
#define _GST_GET(__data, __idx, __size, __shift) \ #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) \ #define _GST_PUT(__data, __idx, __size, __shift, __num) \
(((guint8 *) (__data))[__idx] = (((guint##__size) (__num)) >> (__shift)) & 0xff) (((guint8 *) (__data))[__idx] = (((guint##__size) (__num)) >> (__shift)) & 0xff)

View file

@ -94,17 +94,17 @@ GstBuffer *gst_byte_writer_reset_and_get_buffer (GstByteWriter *writer);
*/ */
#ifdef _FOOL_GTK_DOC_ #ifdef _FOOL_GTK_DOC_
G_INLINE_FUNC guint gst_byte_writer_get_pos (const GstByteWriter *writer); 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); G_INLINE_FUNC guint gst_byte_writer_get_size (const GstByteWriter *writer);
#else #else
static inline guint static inline guint
gst_byte_writer_get_pos (const GstByteWriter *writer) 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 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); 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 static inline guint
gst_byte_writer_get_size (const GstByteWriter *writer) 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 #endif