From 52a78a7220650f4d8b1da75ff942cfede1248d20 Mon Sep 17 00:00:00 2001 From: Damien Lespiau Date: Thu, 27 May 2010 08:28:29 +0100 Subject: [PATCH] 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. --- clutter/clutter-actor.c | 2 +- clutter/clutter-backend.c | 4 ++-- clutter/clutter-path.c | 2 +- clutter/clutter-script-parser.c | 2 +- clutter/clutter-script.c | 4 ++-- clutter/clutter-shader-types.c | 6 +++--- clutter/cogl/cogl/cogl-buffer.c | 2 +- clutter/cogl/cogl/cogl-journal.c | 2 +- clutter/cogl/cogl/cogl-path.c | 4 ++-- clutter/cogl/cogl/cogl-texture-2d-sliced.c | 2 +- clutter/cogl/cogl/cogl-vertex-buffer.c | 14 +++++++------- clutter/cogl/cogl/driver/gl/cogl-program.c | 2 +- clutter/x11/clutter-x11-texture-pixmap.c | 8 ++++---- 13 files changed, 27 insertions(+), 27 deletions(-) diff --git a/clutter/clutter-actor.c b/clutter/clutter-actor.c index 9558a52dd..cb5dd1775 100644 --- a/clutter/clutter-actor.c +++ b/clutter/clutter-actor.c @@ -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; diff --git a/clutter/clutter-backend.c b/clutter/clutter-backend.c index 21b93f1b3..e50133636 100644 --- a/clutter/clutter-backend.c +++ b/clutter/clutter-backend.c @@ -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 (); diff --git a/clutter/clutter-path.c b/clutter/clutter-path.c index 61797f3e1..a391e26df 100644 --- a/clutter/clutter-path.c +++ b/clutter/clutter-path.c @@ -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; diff --git a/clutter/clutter-script-parser.c b/clutter/clutter-script-parser.c index 94a3b1c44..7195f4793 100644 --- a/clutter/clutter-script-parser.c +++ b/clutter/clutter-script-parser.c @@ -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; diff --git a/clutter/clutter-script.c b/clutter/clutter-script.c index bf66f99bc..d865d8cee 100644 --- a/clutter/clutter-script.c +++ b/clutter/clutter-script.c @@ -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); diff --git a/clutter/clutter-shader-types.c b/clutter/clutter-shader-types.c index 7eb027a29..2c35cb8d7 100644 --- a/clutter/clutter-shader-types.c +++ b/clutter/clutter-shader-types.c @@ -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; diff --git a/clutter/cogl/cogl/cogl-buffer.c b/clutter/cogl/cogl/cogl-buffer.c index 5b9e00e4f..c54d52c34 100644 --- a/clutter/cogl/cogl/cogl-buffer.c +++ b/clutter/cogl/cogl/cogl-buffer.c @@ -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; diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index 078a66f19..9c185c891 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -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; } diff --git a/clutter/cogl/cogl/cogl-path.c b/clutter/cogl/cogl/cogl-path.c index 27787acfd..7b8023e1e 100644 --- a/clutter/cogl/cogl/cogl-path.c +++ b/clutter/cogl/cogl/cogl-path.c @@ -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; diff --git a/clutter/cogl/cogl/cogl-texture-2d-sliced.c b/clutter/cogl/cogl/cogl-texture-2d-sliced.c index 29f346e68..c2268dff1 100644 --- a/clutter/cogl/cogl/cogl-texture-2d-sliced.c +++ b/clutter/cogl/cogl/cogl-texture-2d-sliced.c @@ -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) ); } } diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c index 9c21d91c0..47e11a5bd 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.c +++ b/clutter/cogl/cogl/cogl-vertex-buffer.c @@ -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; diff --git a/clutter/cogl/cogl/driver/gl/cogl-program.c b/clutter/cogl/cogl/driver/gl/cogl-program.c index 3fdff0e69..33691c918 100644 --- a/clutter/cogl/cogl/driver/gl/cogl-program.c +++ b/clutter/cogl/cogl/driver/gl/cogl-program.c @@ -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 (); diff --git a/clutter/x11/clutter-x11-texture-pixmap.c b/clutter/x11/clutter-x11-texture-pixmap.c index 036419af6..eef4cfcbd 100644 --- a/clutter/x11/clutter-x11-texture-pixmap.c +++ b/clutter/x11/clutter-x11-texture-pixmap.c @@ -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,