analysis: FALSE/0 used in pointer context

While this is totally fine (0 in the pointer context will be converted
in the right internal NULL representation, which could be a value with
some bits to 1), I believe it's clearer to use NULL in the pointer
context.

It seems that, in most case, it's more an overlook than a deliberate
choice to use FALSE/0 as NULL, eg. copying a _COGL_GET_CONTEXT (ctx, 0)
or a g_return_val_if_fail (cond, 0) from a function returning a
gboolean.
This commit is contained in:
Damien Lespiau 2010-05-27 08:28:29 +01:00
parent 3aaef72e50
commit 58b0028b52
6 changed files with 13 additions and 13 deletions

View File

@ -236,7 +236,7 @@ cogl_buffer_map_EXP (CoglBuffer *buffer,
CoglBufferAccess access) CoglBufferAccess access)
{ {
if (!cogl_is_buffer (buffer)) if (!cogl_is_buffer (buffer))
return FALSE; return NULL;
if (COGL_BUFFER_FLAG_IS_SET (buffer, MAPPED)) if (COGL_BUFFER_FLAG_IS_SET (buffer, MAPPED))
return buffer->data; return buffer->data;

View File

@ -537,7 +537,7 @@ upload_vertices_to_vbo (GArray *vertices, CoglJournalFlushState *state)
/* As we flush the journal entries in batches we walk forward through the /* As we flush the journal entries in batches we walk forward through the
* above VBO starting at offset 0... */ * above VBO starting at offset 0... */
state->vbo_offset = 0; state->vbo_offset = NULL;
return journal_vbo; return journal_vbo;
} }

View File

@ -1065,7 +1065,7 @@ cogl_path_rel_curve_to (float x_1,
CoglHandle CoglHandle
cogl_path_get (void) cogl_path_get (void)
{ {
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, NULL);
return ctx->current_path; return ctx->current_path;
} }
@ -1106,7 +1106,7 @@ cogl_path_copy (CoglHandle handle)
{ {
CoglPath *old_path, *new_path; CoglPath *old_path, *new_path;
_COGL_GET_CONTEXT (ctx, FALSE); _COGL_GET_CONTEXT (ctx, NULL);
if (!cogl_is_path (handle)) if (!cogl_is_path (handle))
return COGL_INVALID_HANDLE; return COGL_INVALID_HANDLE;

View File

@ -864,7 +864,7 @@ _cogl_texture_2d_sliced_slices_create (CoglTexture2DSliced *tex_2ds,
/* Pass NULL data to init size and internal format */ /* Pass NULL data to init size and internal format */
GE( glTexImage2D (tex_2ds->gl_target, 0, gl_intformat, GE( glTexImage2D (tex_2ds->gl_target, 0, gl_intformat,
x_span->size, y_span->size, 0, x_span->size, y_span->size, 0,
gl_format, gl_type, 0) ); gl_format, gl_type, NULL) );
} }
} }

View File

@ -800,7 +800,7 @@ filter_strided_attribute (CoglVertexBufferAttrib *attribute,
} }
} }
new_cogl_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO)); new_cogl_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO));
new_cogl_vbo->vbo_name = 0; new_cogl_vbo->vbo_name = NULL;
new_cogl_vbo->attributes = NULL; new_cogl_vbo->attributes = NULL;
new_cogl_vbo->attributes = new_cogl_vbo->attributes =
g_list_prepend (new_cogl_vbo->attributes, attribute); g_list_prepend (new_cogl_vbo->attributes, attribute);
@ -1059,7 +1059,7 @@ upload_gl_vbo (CoglVertexBufferVBO *cogl_vbo)
if (!fallback) if (!fallback)
{ {
g_return_if_fail (cogl_vbo->vbo_name != 0); g_return_if_fail (cogl_vbo->vbo_name != NULL);
GE (glBindBuffer (GL_ARRAY_BUFFER, GE (glBindBuffer (GL_ARRAY_BUFFER,
GPOINTER_TO_UINT (cogl_vbo->vbo_name))); GPOINTER_TO_UINT (cogl_vbo->vbo_name)));
@ -1352,7 +1352,7 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
*/ */
new_multipack_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO)); new_multipack_vbo = g_slice_alloc (sizeof (CoglVertexBufferVBO));
new_multipack_vbo->vbo_name = 0; new_multipack_vbo->vbo_name = NULL;
new_multipack_vbo->flags = new_multipack_vbo->flags =
COGL_VERTEX_BUFFER_VBO_FLAG_MULTIPACK COGL_VERTEX_BUFFER_VBO_FLAG_MULTIPACK
| COGL_VERTEX_BUFFER_VBO_FLAG_INFREQUENT_RESUBMIT; | COGL_VERTEX_BUFFER_VBO_FLAG_INFREQUENT_RESUBMIT;
@ -1400,7 +1400,7 @@ cogl_vertex_buffer_submit_real (CoglVertexBuffer *buffer)
* in their own VBO so that updates don't impact other attributes * in their own VBO so that updates don't impact other attributes
*/ */
cogl_vbo->vbo_name = 0; cogl_vbo->vbo_name = NULL;
cogl_vbo->flags = cogl_vbo->flags =
COGL_VERTEX_BUFFER_VBO_FLAG_UNSTRIDED COGL_VERTEX_BUFFER_VBO_FLAG_UNSTRIDED
| COGL_VERTEX_BUFFER_VBO_FLAG_FREQUENT_RESUBMIT; | COGL_VERTEX_BUFFER_VBO_FLAG_FREQUENT_RESUBMIT;
@ -1546,7 +1546,7 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
{ {
GE (glBindBuffer (GL_ARRAY_BUFFER, GE (glBindBuffer (GL_ARRAY_BUFFER,
GPOINTER_TO_UINT (cogl_vbo->vbo_name))); GPOINTER_TO_UINT (cogl_vbo->vbo_name)));
base = 0; base = NULL;
} }
else else
base = cogl_vbo->vbo_name; base = cogl_vbo->vbo_name;
@ -1832,7 +1832,7 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type,
gsize indices_bytes; gsize indices_bytes;
CoglVertexBufferIndices *indices; CoglVertexBufferIndices *indices;
_COGL_GET_CONTEXT (ctx, 0); _COGL_GET_CONTEXT (ctx, NULL);
indices = g_slice_alloc (sizeof (CoglVertexBufferIndices)); indices = g_slice_alloc (sizeof (CoglVertexBufferIndices));
@ -1852,7 +1852,7 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type,
{ {
g_critical ("unknown indices type %d", indices_type); g_critical ("unknown indices type %d", indices_type);
g_slice_free (CoglVertexBufferIndices, indices); g_slice_free (CoglVertexBufferIndices, indices);
return 0; return NULL;
} }
indices_bytes = get_indices_type_size (indices->type) * indices_len; indices_bytes = get_indices_type_size (indices->type) * indices_len;

View File

@ -78,7 +78,7 @@ CoglHandle
cogl_create_program (void) cogl_create_program (void)
{ {
CoglProgram *program; CoglProgram *program;
_COGL_GET_CONTEXT (ctx, 0); _COGL_GET_CONTEXT (ctx, NULL);
program = g_slice_new (CoglProgram); program = g_slice_new (CoglProgram);
program->gl_handle = glCreateProgramObject (); program->gl_handle = glCreateProgramObject ();