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 9d428278f7
commit 52a78a7220
13 changed files with 27 additions and 27 deletions

View File

@ -9224,7 +9224,7 @@ clutter_actor_get_shader (ClutterActor *self)
ClutterActorPrivate *actor_priv;
ShaderData *shader_data;
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), FALSE);
g_return_val_if_fail (CLUTTER_IS_ACTOR (self), NULL);
actor_priv = self->priv;
shader_data = actor_priv->shader_data;

View File

@ -280,8 +280,8 @@ _clutter_backend_create_stage (ClutterBackend *backend,
ClutterStageManager *stage_manager;
ClutterStageWindow *stage_window;
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), FALSE);
g_return_val_if_fail (CLUTTER_IS_STAGE (wrapper), FALSE);
g_return_val_if_fail (CLUTTER_IS_BACKEND (backend), NULL);
g_return_val_if_fail (CLUTTER_IS_STAGE (wrapper), NULL);
stage_manager = clutter_stage_manager_get_default ();

View File

@ -1174,7 +1174,7 @@ clutter_path_get_description (ClutterPath *path)
GString *str;
GSList *l;
g_return_val_if_fail (CLUTTER_IS_PATH (path), FALSE);
g_return_val_if_fail (CLUTTER_IS_PATH (path), NULL);
priv = path->priv;

View File

@ -207,7 +207,7 @@ clutter_script_flags_from_string (GType type,
const gchar *flag;
g_return_val_if_fail (G_TYPE_IS_FLAGS (type), 0);
g_return_val_if_fail (string != 0, 0);
g_return_val_if_fail (string != NULL, 0);
ret = TRUE;

View File

@ -1091,8 +1091,8 @@ clutter_script_lookup_filename (ClutterScript *script,
gchar *dirname;
gchar *retval;
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), FALSE);
g_return_val_if_fail (filename != NULL, FALSE);
g_return_val_if_fail (CLUTTER_IS_SCRIPT (script), NULL);
g_return_val_if_fail (filename != NULL, NULL);
if (g_path_is_absolute (filename))
return g_strdup (filename);

View File

@ -488,7 +488,7 @@ clutter_value_get_shader_float (const GValue *value,
{
ClutterShaderFloat *shader_float;
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value), 0);
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_SHADER_FLOAT (value), NULL);
shader_float = value->data[0].v_pointer;
@ -520,7 +520,7 @@ clutter_value_get_shader_int (const GValue *value,
{
ClutterShaderInt *shader_int;
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_SHADER_INT (value), 0);
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_SHADER_INT (value), NULL);
shader_int = value->data[0].v_pointer;
@ -552,7 +552,7 @@ clutter_value_get_shader_matrix (const GValue *value,
{
ClutterShaderMatrix *shader_matrix;
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value), 0);
g_return_val_if_fail (CLUTTER_VALUE_HOLDS_SHADER_MATRIX (value), NULL);
shader_matrix = value->data[0].v_pointer;

View File

@ -236,7 +236,7 @@ cogl_buffer_map_EXP (CoglBuffer *buffer,
CoglBufferAccess access)
{
if (!cogl_is_buffer (buffer))
return FALSE;
return NULL;
if (COGL_BUFFER_FLAG_IS_SET (buffer, MAPPED))
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
* above VBO starting at offset 0... */
state->vbo_offset = 0;
state->vbo_offset = NULL;
return journal_vbo;
}

View File

@ -1065,7 +1065,7 @@ cogl_path_rel_curve_to (float x_1,
CoglHandle
cogl_path_get (void)
{
_COGL_GET_CONTEXT (ctx, FALSE);
_COGL_GET_CONTEXT (ctx, NULL);
return ctx->current_path;
}
@ -1106,7 +1106,7 @@ cogl_path_copy (CoglHandle handle)
{
CoglPath *old_path, *new_path;
_COGL_GET_CONTEXT (ctx, FALSE);
_COGL_GET_CONTEXT (ctx, NULL);
if (!cogl_is_path (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 */
GE( glTexImage2D (tex_2ds->gl_target, 0, gl_intformat,
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->vbo_name = 0;
new_cogl_vbo->vbo_name = NULL;
new_cogl_vbo->attributes = NULL;
new_cogl_vbo->attributes =
g_list_prepend (new_cogl_vbo->attributes, attribute);
@ -1059,7 +1059,7 @@ upload_gl_vbo (CoglVertexBufferVBO *cogl_vbo)
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,
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->vbo_name = 0;
new_multipack_vbo->vbo_name = NULL;
new_multipack_vbo->flags =
COGL_VERTEX_BUFFER_VBO_FLAG_MULTIPACK
| 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
*/
cogl_vbo->vbo_name = 0;
cogl_vbo->vbo_name = NULL;
cogl_vbo->flags =
COGL_VERTEX_BUFFER_VBO_FLAG_UNSTRIDED
| COGL_VERTEX_BUFFER_VBO_FLAG_FREQUENT_RESUBMIT;
@ -1546,7 +1546,7 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer)
{
GE (glBindBuffer (GL_ARRAY_BUFFER,
GPOINTER_TO_UINT (cogl_vbo->vbo_name)));
base = 0;
base = NULL;
}
else
base = cogl_vbo->vbo_name;
@ -1832,7 +1832,7 @@ cogl_vertex_buffer_indices_new (CoglIndicesType indices_type,
gsize indices_bytes;
CoglVertexBufferIndices *indices;
_COGL_GET_CONTEXT (ctx, 0);
_COGL_GET_CONTEXT (ctx, NULL);
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_slice_free (CoglVertexBufferIndices, indices);
return 0;
return NULL;
}
indices_bytes = get_indices_type_size (indices->type) * indices_len;

View File

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

View File

@ -163,7 +163,7 @@ free_shm_resources (ClutterX11TexturePixmap *texture)
XShmDetach(clutter_x11_get_default_display(),
&priv->shminfo);
shmdt(priv->shminfo.shmaddr);
shmctl(priv->shminfo.shmid, IPC_RMID, 0);
shmctl(priv->shminfo.shmid, IPC_RMID, NULL);
priv->shminfo.shmid = -1;
}
}
@ -219,7 +219,7 @@ try_alloc_shm (ClutterX11TexturePixmap *texture)
if (priv->shminfo.shmid == -1)
goto failed_shmget;
priv->shminfo.shmaddr = shmat (priv->shminfo.shmid, 0, 0);
priv->shminfo.shmaddr = shmat (priv->shminfo.shmid, NULL, 0);
if (priv->shminfo.shmaddr == (void *) -1)
goto failed_shmat;
@ -243,7 +243,7 @@ failed_xshmattach:
failed_shmat:
g_warning ("shmat failed");
shmctl (priv->shminfo.shmid, IPC_RMID, 0);
shmctl (priv->shminfo.shmid, IPC_RMID, NULL);
failed_shmget:
g_warning ("shmget failed");
@ -274,7 +274,7 @@ check_for_pixmap_damage (ClutterX11TexturePixmap *texture)
* rectangles so we do not have to update the whole shebang.
*/
dpy = clutter_x11_get_default_display();
parts = XFixesCreateRegion (dpy, 0, 0);
parts = XFixesCreateRegion (dpy, NULL, 0);
XDamageSubtract (dpy, priv->damage, None, parts);
r_damage = XFixesFetchRegionAndBounds (dpy,