Menu

Warnings suppression patch

Help
2008-06-11
2013-04-03
  • It's just me

    It's just me - 2008-06-11

    Hello,

    I am using GooCanvas on a Windows application and some warnings are found in the code of the last version of GooCanvas (GooCanvas-0.10). I don't know if it is interresting for you to modify it but, this is the diff :

    Index: goocanvasstyle.c

    --- goocanvasstyle.c    (revision 614)
    +++ goocanvasstyle.c    (revision 615)
    @@ -185,7 +185,7 @@
    {
       GooCanvasStyle *style = (GooCanvasStyle*) object;
       GooCanvasStyleProperty *property;
    -  gint i;
    +  guint i;

       if (style->parent)
         {
    @@ -230,7 +230,7 @@
    {
       GooCanvasStyle *copy;
       GooCanvasStyleProperty *property;
    -  gint i;
    +  guint i;

       copy = goo_canvas_style_new ();

    @@ -303,7 +303,7 @@
                          GQuark          property_id)
    {
       GooCanvasStyleProperty *property;
    -  gint i;
    +  guint i;

       /* Step up the hierarchy of styles until we find the property. Note that
          if style is passed in as NULL we simply return NULL. */
    @@ -341,7 +341,7 @@
                          const GValue   *value)
    {
       GooCanvasStyleProperty *property, new_property = { 0 };
    -  gint i;
    +  guint i;

       /* See if the property is already set. */
       for (i = 0; i < style->properties->len; i++)
    @@ -396,7 +396,7 @@
       gboolean line_cap_set = FALSE, line_join_set = FALSE;
       gboolean miter_limit_set = FALSE, line_dash_set = FALSE;
       gboolean source_set = FALSE, need_stroke = TRUE;
    -  gint i;
    +  guint i;

       if (!style)
         return TRUE;
    @@ -493,7 +493,7 @@
       gboolean operator_set = FALSE, antialias_set = FALSE;
       gboolean fill_rule_set = FALSE, fill_pattern_set = FALSE;
       gboolean need_fill = FALSE;
    -  gint i;
    +  guint i;

       if (!style)
         return FALSE;
    Index: goocanvasutils.c
    ===================================================================
    --- goocanvasutils.c    (revision 614)
    +++ goocanvasutils.c    (revision 615)
    @@ -75,7 +75,7 @@
    goo_canvas_util_ptr_array_find_index (GPtrArray *ptr_array,
                           gpointer   data)
    {
    -  gint i;
    +  guint i;

       for (i = 0; i < ptr_array->len; i++)
         {
    @@ -1052,7 +1052,7 @@
       GooCanvasPathCommandType prev_cmd_type = GOO_CANVAS_PATH_CLOSE_PATH;
       gdouble x = 0, y = 0, path_start_x = 0, path_start_y = 0;
       gdouble last_control_point_x = 0.0, last_control_point_y = 0.0;
    -  gint i;
    +  guint i;

       cairo_new_path (cr);

    Index: goocanvasatk.c

    --- goocanvasatk.c    (revision 614)
    +++ goocanvasatk.c    (revision 615)
    @@ -61,10 +61,10 @@
       bounds.y2 -= canvas->vadjustment->value;

       /* Round up or down to integers. */
    -  rect->x = floor (bounds.x1);
    -  rect->y = floor (bounds.y1);
    -  rect->width = ceil (bounds.x1) - rect->x;
    -  rect->height = ceil (bounds.y1) - rect->y;
    +  rect->x = (gint)floor (bounds.x1);
    +  rect->y = (gint)floor (bounds.y1);
    +  rect->width = (gint)(ceil (bounds.x1) - rect->x);
    +  rect->height = (gint)(ceil (bounds.y1) - rect->y);
    }

    Index: goocanvaspolyline.c

    --- goocanvaspolyline.c    (revision 614)
    +++ goocanvaspolyline.c    (revision 615)
    @@ -662,7 +662,7 @@
    {
       GooCanvasPolylineData *polyline_data = polyline->polyline_data;
       GooCanvasPolylineArrowData *arrow = polyline_data->arrow_data;
    -  gint i;
    +  guint i;

       cairo_new_path (cr);

    @@ -678,7 +678,7 @@

       if (polyline_data->end_arrow && polyline_data->num_points >= 2)
         {
    -      gint last_point = polyline_data->num_points - 1;
    +      guint last_point = polyline_data->num_points - 1;

           if (!polyline_data->close_path)
         last_point--;
    Index: goocanvasgroup.c
    ===================================================================
    --- goocanvasgroup.c    (revision 614)
    +++ goocanvasgroup.c    (revision 615)
    @@ -119,7 +119,7 @@
    goo_canvas_group_dispose (GObject *object)
    {
       GooCanvasGroup *group = (GooCanvasGroup*) object;
    -  gint i;
    +  guint i;

       /* Unref all the items in the group. */
       for (i = 0; i < group->items->len; i++)
    @@ -204,7 +204,7 @@
       GooCanvasItem *child;
       GooCanvasBounds bounds;

    -  g_return_if_fail (child_num < group->items->len);
    +  g_return_if_fail (child_num < (gint)group->items->len);

       /* Request a redraw of the item's bounds. */
       child = group->items->pdata[child_num];
    @@ -250,7 +250,7 @@
    {
       GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
       GooCanvasGroup *group = (GooCanvasGroup*) item;
    -  gint i;
    +  guint i;

       simple->canvas = canvas;

    @@ -355,7 +355,7 @@
       GooCanvasGroup *group = (GooCanvasGroup*) item;
       GooCanvasBounds child_bounds;
       gboolean initial_bounds = TRUE;
    -  gint i;
    +  guint i;

       if (entire_tree || simple->need_update)
         {
    @@ -421,7 +421,7 @@
       GooCanvasItemSimpleData *simple_data = simple->simple_data;
       GooCanvasGroup *group = (GooCanvasGroup*) item;
       gboolean visible = parent_visible;
    -  int i;
    +  guint i;

       if (simple->need_update)
         goo_canvas_item_ensure_updated (item);
    @@ -487,7 +487,7 @@
       GooCanvasItemSimple *simple = (GooCanvasItemSimple*) item;
       GooCanvasItemSimpleData *simple_data = simple->simple_data;
       GooCanvasGroup *group = (GooCanvasGroup*) item;
    -  gint i;
    +  guint i;

       /* Skip the item if the bounds don't intersect the expose rectangle. */
       if (simple->bounds.x1 > bounds->x2 || simple->bounds.x2 < bounds->x1
    @@ -641,7 +641,7 @@
    goo_canvas_group_model_dispose (GObject *object)
    {
       GooCanvasGroupModel *gmodel = (GooCanvasGroupModel*) object;
    -  gint i;
    +  guint i;

       /* Unref all the items in the group. */
       for (i = 0; i < gmodel->children->len; i++)
    Index: goocanvasitemsimple.c
    ===================================================================
    --- goocanvasitemsimple.c    (revision 614)
    +++ goocanvasitemsimple.c    (revision 615)
    @@ -437,16 +437,16 @@
    {
       guint red_byte, green_byte, blue_byte, alpha_byte;

    -  red_byte = red * 256;
    +  red_byte = (guint)(red * 256);
       red_byte -= red_byte >> 8;

    -  green_byte = green * 256;
    +  green_byte = (guint)(green * 256);
       green_byte -= green_byte >> 8;

    -  blue_byte = blue * 256;
    +  blue_byte = (guint)(blue * 256);
       blue_byte -= blue_byte >> 8;

    -  alpha_byte = alpha * 256;
    +  alpha_byte = (guint)(alpha * 256);
       alpha_byte -= alpha_byte >> 8;

       return (red_byte << 24) + (green_byte << 16) + (blue_byte << 8) + alpha_byte;
    Index: goocanvas.c
    ===================================================================
    --- goocanvas.c    (revision 614)
    +++ goocanvas.c    (revision 615)
    @@ -1208,11 +1208,11 @@
       gdk_window_set_user_data (widget->window, widget);

       /* We want to round the sizes up to the next pixel. */
    -  width_pixels = ((canvas->bounds.x2 - canvas->bounds.x1) * canvas->device_to_pixels_x) + 1;
    -  height_pixels = ((canvas->bounds.y2 - canvas->bounds.y1) * canvas->device_to_pixels_y) + 1;
    +  width_pixels = (gint)(((canvas->bounds.x2 - canvas->bounds.x1) * canvas->device_to_pixels_x) + 1);
    +  height_pixels = (gint)(((canvas->bounds.y2 - canvas->bounds.y1) * canvas->device_to_pixels_y) + 1);

    -  attributes.x = canvas->hadjustment ? - canvas->hadjustment->value : 0,
    -  attributes.y = canvas->vadjustment ? - canvas->vadjustment->value : 0;
    +  attributes.x = (gint)(canvas->hadjustment ? - canvas->hadjustment->value : 0);
    +  attributes.y = (gint)(canvas->vadjustment ? - canvas->vadjustment->value : 0);
       attributes.width = MAX (width_pixels, widget->allocation.width);
       attributes.height = MAX (height_pixels, widget->allocation.height);
       attributes.event_mask = GDK_EXPOSURE_MASK
    @@ -1465,8 +1465,8 @@

       /* This is the natural size of the canvas window in pixels, rounded up to
          the next pixel. */
    -  width_pixels = ((canvas->bounds.x2 - canvas->bounds.x1) * canvas->device_to_pixels_x) + 1;
    -  height_pixels = ((canvas->bounds.y2 - canvas->bounds.y1) * canvas->device_to_pixels_y) + 1;
    +  width_pixels = (gint)(((canvas->bounds.x2 - canvas->bounds.x1) * canvas->device_to_pixels_x) + 1);
    +  height_pixels = (gint)(((canvas->bounds.y2 - canvas->bounds.y1) * canvas->device_to_pixels_y) + 1);

       /* The actual window size is always at least as big as the widget's window.*/
       window_width = MAX (width_pixels, widget->allocation.width);
    @@ -1523,13 +1523,13 @@
       if (canvas->hadjustment)
         {
           goo_canvas_configure_hadjustment (canvas, window_width);
    -      window_x = - canvas->hadjustment->value;
    +      window_x = (gint)(- canvas->hadjustment->value);
         }

       if (canvas->vadjustment)
         {
           goo_canvas_configure_vadjustment (canvas, window_height);
    -      window_y = - canvas->vadjustment->value;
    +      window_y = (gint)(- canvas->vadjustment->value);
         }

       canvas->freeze_count--;
    @@ -1596,10 +1596,10 @@

       /* Note that we only really support integers for the bounds, and we don't
          support scaling of a canvas with widget items in it. */
    -  allocation.x = bounds.x1;
    -  allocation.y = bounds.y1;
    -  allocation.width = bounds.x2 - allocation.x;
    -  allocation.height = bounds.y2 - allocation.y;
    +  allocation.x = (gint)bounds.x1;
    +  allocation.y = (gint)bounds.y1;
    +  allocation.width = (gint)(bounds.x2 - allocation.x);
    +  allocation.height = (gint)(bounds.y2 - allocation.y);
      
       gtk_widget_size_allocate (witem->widget, &allocation);
    }
    @@ -1653,8 +1653,8 @@
       if (!canvas->freeze_count && GTK_WIDGET_REALIZED (canvas))
         {
           gdk_window_move (canvas->canvas_window,
    -               - canvas->hadjustment->value,
    -               - canvas->vadjustment->value);
    +               (gint)(- canvas->hadjustment->value),
    +               (gint)(- canvas->vadjustment->value));
          
           /* If this is callback from a signal for one of the scrollbars, process
          updates here for smoother scrolling. */
    @@ -2207,15 +2207,15 @@

       /* We subtract one from the left & top edges, in case anti-aliasing makes
          the drawing use an extra pixel. */
    -  rect.x = (double) (bounds->x1 - canvas->bounds.x1) * canvas->device_to_pixels_x - 1;
    -  rect.y = (double) (bounds->y1 - canvas->bounds.y1) * canvas->device_to_pixels_y - 1;
    +  rect.x = (gint)((double) (bounds->x1 - canvas->bounds.x1) * canvas->device_to_pixels_x - 1);
    +  rect.y = (gint)((double) (bounds->y1 - canvas->bounds.y1) * canvas->device_to_pixels_y - 1);

       /* We add an extra one here for the same reason. (The other extra one is to
          round up to the next pixel.) And one for luck! */
    -  rect.width = (double) (bounds->x2 - canvas->bounds.x1) * canvas->device_to_pixels_x
    -    - rect.x + 2 + 1;
    -  rect.height = (double) (bounds->y2 - canvas->bounds.y1) * canvas->device_to_pixels_y
    -    - rect.y + 2 + 1;
    +  rect.width = (gint)((double) (bounds->x2 - canvas->bounds.x1) * canvas->device_to_pixels_x
    +    - rect.x + 2 + 1);
    +  rect.height = (gint)((double) (bounds->y2 - canvas->bounds.y1) * canvas->device_to_pixels_y
    +    - rect.y + 2 + 1);

       rect.x += canvas->canvas_x_offset;
       rect.y += canvas->canvas_y_offset;
    Index: goocanvastext.c
    ===================================================================
    --- goocanvastext.c    (revision 614)
    +++ goocanvastext.c    (revision 615)
    @@ -390,7 +390,7 @@
       context = pango_layout_get_context (layout);

       if (layout_width > 0)
    -    pango_layout_set_width (layout, (double) layout_width * PANGO_SCALE);
    +    pango_layout_set_width (layout, (gint)((double) layout_width * PANGO_SCALE));

       if (text_data->use_markup)
         pango_layout_set_markup (layout, string, -1);
    @@ -597,8 +597,8 @@
                           &origin_x, &origin_y);

       /* Convert the coordinates into Pango units. */
    -  px = (x - origin_x) * PANGO_SCALE;
    -  py = (y - origin_y) * PANGO_SCALE;
    +  px = (gint)((x - origin_x) * PANGO_SCALE);
    +  py = (gint)((y - origin_y) * PANGO_SCALE);

       /* We use line extents here. Note that SVG uses character cells to determine
          hits so we have slightly different behavior. */
    Index: goocanvastable.c
    ===================================================================
    --- goocanvastable.c    (revision 614)
    +++ goocanvastable.c    (revision 615)
    @@ -735,7 +735,8 @@
       GooCanvasTableLayoutData *layout_data;
       GooCanvasTableChild *table_child;
       guint32 grid_line_size;
    -  gint d, d2, child_num, i, j;
    +  gint d, d2, i, j;
    +  guint child_num;

       layout_data = table_data->layout_data;
       for (d = 0; d < 2; d++)
    @@ -892,7 +893,7 @@
       GooCanvasGroup *group = (GooCanvasGroup*) item;
       GooCanvasTable *table = (GooCanvasTable*) item;

    -  g_return_if_fail (child_num < group->items->len);
    +  g_return_if_fail (child_num < (gint)group->items->len);

       if (!simple->model)
         g_array_remove_index (table->table_data->children, child_num);
    @@ -977,7 +978,7 @@
       GooCanvasGroup *group = (GooCanvasGroup*) item;
       GooCanvasTable *table = (GooCanvasTable*) item;
       GooCanvasTableChild *table_child;
    -  gint child_num;
    +  guint child_num;

       for (child_num = 0; child_num < group->items->len; child_num++)
         {
    @@ -1095,7 +1096,7 @@
       GooCanvasGroup *group = (GooCanvasGroup*) item;
       GooCanvasTable *table = (GooCanvasTable*) item;
       GooCanvasTableChild *table_child;
    -  gint child_num;
    +  guint child_num;

       for (child_num = 0; child_num < group->items->len; child_num++)
         {
    @@ -1253,7 +1254,8 @@
       GooCanvasItem *child_item;
       GooCanvasBounds bounds;
       gboolean allocate, has_expand, has_shrink;
    -  gint i, j, d, start, end;
    +  gint j, d, start, end;
    +  guint i;
       guint8 flags;

       for (i = 0; i < table_data->children->len; i++)
    @@ -1369,7 +1371,7 @@
           dimension = &table_data->dimensions[d];
           dldata = layout_data->dldata[d];

    -      for (i = 0; i < dimension->size; i++)
    +      for (i = 0; i < (guint)dimension->size; i++)
         {
           if (dldata[i].empty)
             {
    @@ -1401,9 +1403,10 @@
       GooCanvasTableDimensionLayoutData *dldata = layout_data->dldata[d];
       GooCanvasTableChild *child;
       gdouble requested_size;
    -  gint i, start;
    +  gint start;
    +  guint i;

    -  for (i = 0; i < dimension->size; i++)
    +  for (i = 0; i < (guint)dimension->size; i++)
         dldata[i].requisition = 0.0;

       for (i = 0; i < table_data->children->len; i++)
    @@ -1463,7 +1466,8 @@
       GooCanvasTableLayoutData *layout_data = table_data->layout_data;
       GooCanvasTableDimensionLayoutData *dldata;
       GooCanvasTableChild *child;
    -  gint i, j;
    +  gint j;
    +  guint i;
      
       for (i = 0; i < table_data->children->len; i++)
         {
    @@ -1759,7 +1763,8 @@
       GooCanvasTableChildLayoutData *child_data;
       GooCanvasBounds requested_area, allocated_area;
       GtkTextDirection direction = GTK_TEXT_DIR_NONE;
    -  gint start_column, end_column, start_row, end_row, i;
    +  gint start_column, end_column, start_row, end_row;
    +  guint i;
       gdouble x, y, max_width, max_height, width, height;
       gdouble requested_width, requested_height;
       gdouble x_offset, y_offset;
    @@ -1857,7 +1862,8 @@
       GooCanvasTableChild *child;
       GooCanvasItem *child_item;
       GooCanvasTableChildLayoutData *child_data;
    -  gint start_column, end_column, i, row, end;
    +  gint start_column, end_column, row, end;
    +  guint i;
       gdouble x, max_width, width, requested_width, requested_height, height = 0.0;

       /* Just return if we've already calculated requested heights for this exact
    @@ -2399,7 +2405,7 @@

       cairo_restore (cr);

    -  for (i = 0; i < group->items->len; i++)
    +  for (i = 0; i < (gint)group->items->len; i++)
         {
           child = group->items->pdata[i];

    @@ -2489,7 +2495,8 @@
       GooCanvasItem *child;
       gboolean visible = parent_visible, check_clip = FALSE;
       double user_x = x, user_y = y;
    -  gint start_column, end_column, start_row, end_row, i;
    +  gint start_column, end_column, start_row, end_row;
    +  guint i;
       gdouble start_x, end_x, start_y, end_y;

       if (simple->need_update)
    @@ -2598,7 +2605,7 @@
       GooCanvasTable *table = (GooCanvasTable*) item;
       GooCanvasTableChild *table_child;
       gboolean has_transform = FALSE;
    -  gint child_num;
    +  guint child_num;

       if (simple->simple_data->transform)
    @@ -2895,7 +2902,7 @@
       GooCanvasGroupModel *gmodel = (GooCanvasGroupModel*) model;
       GooCanvasTableModel *tmodel = (GooCanvasTableModel*) model;
       GooCanvasTableChild *table_child;
    -  gint child_num;
    +  guint child_num;

       for (child_num = 0; child_num < gmodel->children->len; child_num++)
         {
    @@ -2923,7 +2930,7 @@
       GooCanvasGroupModel *gmodel = (GooCanvasGroupModel*) model;
       GooCanvasTableModel *tmodel = (GooCanvasTableModel*) model;
       GooCanvasTableChild *table_child;
    -  gint child_num;
    +  guint child_num;

       for (child_num = 0; child_num < gmodel->children->len; child_num++)
         {

    Thank you in advance,

    Gorillus

     
    • Damon Chaplin

      Damon Chaplin - 2008-06-11

      Those warnings are a bit too pedantic. I don't really think it is worth fixing them.

       

Log in to post a comment.