Fix compiler warnings

When dereferencing GArray.data to a C structure you need a double cast
from guint8* to void*, and then from void* to the actual type. This
avoids compiler warnings, especially when using clang on OSX.
This commit is contained in:
Emmanuele Bassi 2012-01-16 23:49:49 +00:00
parent eb489a40de
commit 1dfc503df1
4 changed files with 26 additions and 24 deletions

View File

@ -2000,6 +2000,7 @@ _clutter_script_construct_object (ClutterScript *script,
else else
{ {
GList *properties = oinfo->properties; GList *properties = oinfo->properties;
GParameter *parameters = (GParameter *) (void *) params->data;
/* every other object: first, we get the construction parameters */ /* every other object: first, we get the construction parameters */
oinfo->properties = oinfo->properties =
@ -2011,7 +2012,7 @@ _clutter_script_construct_object (ClutterScript *script,
oinfo->object = g_object_newv (oinfo->gtype, oinfo->object = g_object_newv (oinfo->gtype,
params->len, params->len,
(GParameter *) params->data); parameters);
/* by sinking the floating reference, we make sure that the reference /* by sinking the floating reference, we make sure that the reference
* count is correct whether the object is referenced from somewhere * count is correct whether the object is referenced from somewhere

View File

@ -1537,9 +1537,8 @@ clutter_state_get_animator (ClutterState *state,
const gchar *source_state_name, const gchar *source_state_name,
const gchar *target_state_name) const gchar *target_state_name)
{ {
State *target_state; State *target_state;
StateAnimator *animators; guint i;
gint i;
g_return_val_if_fail (CLUTTER_IS_STATE (state), NULL); g_return_val_if_fail (CLUTTER_IS_STATE (state), NULL);
@ -1552,13 +1551,14 @@ clutter_state_get_animator (ClutterState *state,
target_state = clutter_state_fetch_state (state, target_state_name, FALSE); target_state = clutter_state_fetch_state (state, target_state_name, FALSE);
if (target_state == NULL) if (target_state == NULL)
return NULL; return NULL;
animators = (StateAnimator*)target_state->animators->data;
for (i = 0; animators[i].animator; i++) for (i = 0; i < target_state->animators->len; i++)
{ {
if (animators[i].source_state_name == source_state_name) const StateAnimator *animator;
return animators[i].animator;
animator = &g_array_index (target_state->animators, StateAnimator, i);
if (animator->source_state_name == source_state_name)
return animator->animator;
} }
return NULL; return NULL;
@ -1592,8 +1592,7 @@ clutter_state_set_animator (ClutterState *state,
ClutterAnimator *animator) ClutterAnimator *animator)
{ {
State *target_state; State *target_state;
StateAnimator *animators; guint i;
gint i;
g_return_if_fail (CLUTTER_IS_STATE (state)); g_return_if_fail (CLUTTER_IS_STATE (state));
@ -1604,15 +1603,17 @@ clutter_state_set_animator (ClutterState *state,
if (target_state == NULL) if (target_state == NULL)
return; return;
animators = (StateAnimator *) target_state->animators->data; for (i = 0; target_state->animators->len; i++)
for (i = 0; animators[i].animator; i++)
{ {
if (animators[i].source_state_name == source_state_name) StateAnimator *a;
a = &g_array_index (target_state->animators, StateAnimator, i);
if (a->source_state_name == source_state_name)
{ {
g_object_unref (animators[i].animator); g_object_unref (a->animator);
if (animator != NULL) if (animator != NULL)
animators[i].animator = g_object_ref (animator); a->animator = g_object_ref (animator);
else else
{ {
/* remove the matched animator if passed NULL */ /* remove the matched animator if passed NULL */

View File

@ -759,7 +759,7 @@ calculate_col_widths (ClutterTableLayout *self,
update_row_col (self, container); update_row_col (self, container);
g_array_set_size (priv->columns, 0); g_array_set_size (priv->columns, 0);
g_array_set_size (priv->columns, priv->n_cols); g_array_set_size (priv->columns, priv->n_cols);
columns = (DimensionData *) priv->columns->data; columns = (DimensionData *) (void *) priv->columns->data;
/* reset the visibility of all columns */ /* reset the visibility of all columns */
priv->visible_cols = 0; priv->visible_cols = 0;
@ -1032,8 +1032,8 @@ calculate_row_heights (ClutterTableLayout *self,
g_array_set_size (priv->rows, 0); g_array_set_size (priv->rows, 0);
g_array_set_size (priv->rows, self->priv->n_rows); g_array_set_size (priv->rows, self->priv->n_rows);
rows = (DimensionData *) priv->rows->data; rows = (DimensionData *) (void *) priv->rows->data;
columns = (DimensionData *) priv->columns->data; columns = (DimensionData *) (void *) priv->columns->data;
/* reset the visibility of all rows */ /* reset the visibility of all rows */
priv->visible_rows = 0; priv->visible_rows = 0;
@ -1334,7 +1334,7 @@ clutter_table_layout_get_preferred_width (ClutterLayoutManager *layout,
} }
calculate_table_dimensions (self, container, -1, for_height); calculate_table_dimensions (self, container, -1, for_height);
columns = (DimensionData *) priv->columns->data; columns = (DimensionData *) (void *) priv->columns->data;
total_min_width = (priv->visible_cols - 1) * (float) priv->col_spacing; total_min_width = (priv->visible_cols - 1) * (float) priv->col_spacing;
total_pref_width = total_min_width; total_pref_width = total_min_width;
@ -1374,7 +1374,7 @@ clutter_table_layout_get_preferred_height (ClutterLayoutManager *layout,
} }
calculate_table_dimensions (self, container, for_width, -1); calculate_table_dimensions (self, container, for_width, -1);
rows = (DimensionData *) priv->rows->data; rows = (DimensionData *) (void *) priv->rows->data;
total_min_height = (priv->visible_rows - 1) * (float) priv->row_spacing; total_min_height = (priv->visible_rows - 1) * (float) priv->row_spacing;
total_pref_height = total_min_height; total_pref_height = total_min_height;
@ -1439,8 +1439,8 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
box->x2 - box->x1, box->x2 - box->x1,
box->y2 - box->y1); box->y2 - box->y1);
rows = (DimensionData *) priv->rows->data; rows = (DimensionData *) (void *) priv->rows->data;
columns = (DimensionData *) priv->columns->data; columns = (DimensionData *) (void *) priv->columns->data;
for (child = clutter_actor_get_first_child (actor); for (child = clutter_actor_get_first_child (actor);
child != NULL; child != NULL;

View File

@ -1631,7 +1631,7 @@ clutter_timeline_list_markers (ClutterTimeline *timeline,
&data); &data);
i = data.markers->len; i = data.markers->len;
retval = (gchar **) g_array_free (data.markers, FALSE); retval = (gchar **) (void *) g_array_free (data.markers, FALSE);
} }
if (n_markers) if (n_markers)