cogl: Avoid pointer arithmetic on void* pointers
authorNeil Roberts <neil@linux.intel.com>
Tue, 15 Feb 2011 12:43:26 +0000 (12:43 +0000)
committerNeil Roberts <neil@linux.intel.com>
Tue, 15 Feb 2011 14:26:17 +0000 (14:26 +0000)
Some code was doing pointer arithmetic on the return value from
cogl_buffer_map which is void* pointer. This is a GCC extension so we
should try to avoid it. This patch adds casts to guint8* where
appropriate.

Based on a patch by Fan, Chun-wei.

http://bugzilla.clutter-project.org/show_bug.cgi?id=2561

clutter/cogl/cogl/cogl-attribute.c
clutter/cogl/cogl/cogl-journal.c

index 4be7e8d..2e22116 100644 (file)
@@ -600,7 +600,7 @@ enable_gl_state (CoglDrawFlags flags,
       CoglAttribute *attribute = attributes[i];
       CoglVertexArray *vertex_array;
       CoglBuffer *buffer;
-      void *base;
+      guint8 *base;
 #ifdef HAVE_COGL_GLES2
       int attrib_location;
 #endif
@@ -1186,7 +1186,7 @@ _cogl_draw_indexed_attributes_array (CoglVerticesMode mode,
   ValidateLayerState state;
   CoglPipeline *source;
   CoglBuffer *buffer;
-  void *base;
+  guint8 *base;
   size_t array_offset;
   size_t index_size;
   GLenum indices_gl_type = 0;
index cdfb3c7..7370dd6 100644 (file)
@@ -628,8 +628,8 @@ _cogl_journal_flush_vbo_offsets_and_entries (CoglJournalEntry *batch_start,
       /* Mapping a buffer for read is probably a really bad thing to
          do but this will only happen during debugging so it probably
          doesn't matter */
-      verts = (cogl_buffer_map (COGL_BUFFER (state->vertex_array),
-                                COGL_BUFFER_ACCESS_READ, 0) +
+      verts = ((guint8 *) cogl_buffer_map (COGL_BUFFER (state->vertex_array),
+                                           COGL_BUFFER_ACCESS_READ, 0) +
                state->array_offset);
 
       _cogl_journal_dump_quad_batch (verts,