[clutter] Fix compiler warnings
- From: Emmanuele Bassi <ebassi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [clutter] Fix compiler warnings
- Date: Mon, 16 Jan 2012 23:59:16 +0000 (UTC)
commit 1dfc503df1085e197f291bc92a3af5495ec7f11d
Author: Emmanuele Bassi <ebassi gnome org>
Date: Mon Jan 16 23:49:49 2012 +0000
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.
clutter/clutter-script-parser.c | 3 ++-
clutter/clutter-state.c | 31 ++++++++++++++++---------------
clutter/clutter-table-layout.c | 14 +++++++-------
clutter/clutter-timeline.c | 2 +-
4 files changed, 26 insertions(+), 24 deletions(-)
---
diff --git a/clutter/clutter-script-parser.c b/clutter/clutter-script-parser.c
index 43c26bf..8fa7ddd 100644
--- a/clutter/clutter-script-parser.c
+++ b/clutter/clutter-script-parser.c
@@ -2000,6 +2000,7 @@ _clutter_script_construct_object (ClutterScript *script,
else
{
GList *properties = oinfo->properties;
+ GParameter *parameters = (GParameter *) (void *) params->data;
/* every other object: first, we get the construction parameters */
oinfo->properties =
@@ -2011,7 +2012,7 @@ _clutter_script_construct_object (ClutterScript *script,
oinfo->object = g_object_newv (oinfo->gtype,
params->len,
- (GParameter *) params->data);
+ parameters);
/* by sinking the floating reference, we make sure that the reference
* count is correct whether the object is referenced from somewhere
diff --git a/clutter/clutter-state.c b/clutter/clutter-state.c
index 223d03a..6085b3a 100644
--- a/clutter/clutter-state.c
+++ b/clutter/clutter-state.c
@@ -1537,9 +1537,8 @@ clutter_state_get_animator (ClutterState *state,
const gchar *source_state_name,
const gchar *target_state_name)
{
- State *target_state;
- StateAnimator *animators;
- gint i;
+ State *target_state;
+ guint i;
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);
if (target_state == 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)
- return animators[i].animator;
+ const StateAnimator *animator;
+
+ animator = &g_array_index (target_state->animators, StateAnimator, i);
+ if (animator->source_state_name == source_state_name)
+ return animator->animator;
}
return NULL;
@@ -1592,8 +1592,7 @@ clutter_state_set_animator (ClutterState *state,
ClutterAnimator *animator)
{
State *target_state;
- StateAnimator *animators;
- gint i;
+ guint i;
g_return_if_fail (CLUTTER_IS_STATE (state));
@@ -1604,15 +1603,17 @@ clutter_state_set_animator (ClutterState *state,
if (target_state == NULL)
return;
- animators = (StateAnimator *) target_state->animators->data;
- for (i = 0; animators[i].animator; i++)
+ for (i = 0; target_state->animators->len; 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)
- animators[i].animator = g_object_ref (animator);
+ a->animator = g_object_ref (animator);
else
{
/* remove the matched animator if passed NULL */
diff --git a/clutter/clutter-table-layout.c b/clutter/clutter-table-layout.c
index 7a29308..68cccf5 100644
--- a/clutter/clutter-table-layout.c
+++ b/clutter/clutter-table-layout.c
@@ -759,7 +759,7 @@ calculate_col_widths (ClutterTableLayout *self,
update_row_col (self, container);
g_array_set_size (priv->columns, 0);
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 */
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, self->priv->n_rows);
- rows = (DimensionData *) priv->rows->data;
- columns = (DimensionData *) priv->columns->data;
+ rows = (DimensionData *) (void *) priv->rows->data;
+ columns = (DimensionData *) (void *) priv->columns->data;
/* reset the visibility of all rows */
priv->visible_rows = 0;
@@ -1334,7 +1334,7 @@ clutter_table_layout_get_preferred_width (ClutterLayoutManager *layout,
}
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_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);
- rows = (DimensionData *) priv->rows->data;
+ rows = (DimensionData *) (void *) priv->rows->data;
total_min_height = (priv->visible_rows - 1) * (float) priv->row_spacing;
total_pref_height = total_min_height;
@@ -1439,8 +1439,8 @@ clutter_table_layout_allocate (ClutterLayoutManager *layout,
box->x2 - box->x1,
box->y2 - box->y1);
- rows = (DimensionData *) priv->rows->data;
- columns = (DimensionData *) priv->columns->data;
+ rows = (DimensionData *) (void *) priv->rows->data;
+ columns = (DimensionData *) (void *) priv->columns->data;
for (child = clutter_actor_get_first_child (actor);
child != NULL;
diff --git a/clutter/clutter-timeline.c b/clutter/clutter-timeline.c
index 204173e..c6f68ca 100644
--- a/clutter/clutter-timeline.c
+++ b/clutter/clutter-timeline.c
@@ -1631,7 +1631,7 @@ clutter_timeline_list_markers (ClutterTimeline *timeline,
&data);
i = data.markers->len;
- retval = (gchar **) g_array_free (data.markers, FALSE);
+ retval = (gchar **) (void *) g_array_free (data.markers, FALSE);
}
if (n_markers)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]