[cairo-commit] 3 commits - perf/cairo-perf-graph-widget.c src/cairo-cff-subset.c src/cairo-path-fill.c src/cairo-path-fixed.c src/cairo-path-in-fill.c src/cairo-path-stroke.c src/cairo-path-stroke-traps.c src/cairo-svg-surface.c src/cairo-type1-subset.c src/cairo-user-font.c test/cairo-test-trace.c test/operator-www.c

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Aug 27 23:41:58 UTC 2021


 perf/cairo-perf-graph-widget.c |    2 --
 src/cairo-cff-subset.c         |    6 +++---
 src/cairo-path-fill.c          |   10 +++++++++-
 src/cairo-path-fixed.c         |   12 ++++++++++--
 src/cairo-path-in-fill.c       |   10 +++++++++-
 src/cairo-path-stroke-traps.c  |   10 +++++++++-
 src/cairo-path-stroke.c        |   24 ++++++++++++++++++++----
 src/cairo-svg-surface.c        |   27 ++++++++++++---------------
 src/cairo-type1-subset.c       |    2 +-
 src/cairo-user-font.c          |    6 +++---
 test/cairo-test-trace.c        |    6 ++++--
 test/operator-www.c            |    4 ++--
 12 files changed, 82 insertions(+), 37 deletions(-)

New commits:
commit 9bb1cbf7249d12dd69c8aca3825711645da20bcb
Merge: 923715f2e 78d267ee7
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Aug 27 23:41:56 2021 +0000

    Merge branch 'fix-warnings' into 'master'
    
    Fix build warnings
    
    See merge request cairo/cairo!239

commit 78d267ee7af3c7cabdef437cd6a670111fc6062b
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Tue Aug 17 06:25:29 2021 +0930

    Fix some warnings

diff --git a/perf/cairo-perf-graph-widget.c b/perf/cairo-perf-graph-widget.c
index 41311f7ee..e56eee1bc 100644
--- a/perf/cairo-perf-graph-widget.c
+++ b/perf/cairo-perf-graph-widget.c
@@ -489,8 +489,6 @@ static gboolean
 graph_view_button_release (GtkWidget	  *w,
 			   GdkEventButton *ev)
 {
-    GraphView *self = (GraphView *) w;
-
     return FALSE;
 }
 
diff --git a/src/cairo-cff-subset.c b/src/cairo-cff-subset.c
index 2b713410e..4bf22e2b7 100644
--- a/src/cairo-cff-subset.c
+++ b/src/cairo-cff-subset.c
@@ -1599,7 +1599,7 @@ cairo_cff_parse_charstring (cairo_cff_font_t *font,
             if (font->is_cid) {
                 fd = font->fdselect[glyph_id];
 		sub_num = font->type2_stack_top_value + font->fd_local_sub_bias[fd];
-		if (sub_num >= _cairo_array_num_elements(&font->fd_local_sub_index[fd]))
+		if (sub_num >= (int)_cairo_array_num_elements(&font->fd_local_sub_index[fd]))
 		    return CAIRO_INT_STATUS_UNSUPPORTED;
                 element = _cairo_array_index (&font->fd_local_sub_index[fd], sub_num);
                 if (! font->fd_local_subs_used[fd][sub_num]) {
@@ -1608,7 +1608,7 @@ cairo_cff_parse_charstring (cairo_cff_font_t *font,
 		}
             } else {
 		sub_num = font->type2_stack_top_value + font->local_sub_bias;
-		if (sub_num >= _cairo_array_num_elements(&font->local_sub_index))
+		if (sub_num >= (int)_cairo_array_num_elements(&font->local_sub_index))
 		    return CAIRO_INT_STATUS_UNSUPPORTED;
                 element = _cairo_array_index (&font->local_sub_index, sub_num);
                 if (! font->local_subs_used[sub_num] ||
@@ -1634,7 +1634,7 @@ cairo_cff_parse_charstring (cairo_cff_font_t *font,
 		font->type2_seen_first_int = FALSE;
 
 	    sub_num = font->type2_stack_top_value + font->global_sub_bias;
-	    if (sub_num >= _cairo_array_num_elements(&font->global_sub_index))
+	    if (sub_num >= (int)_cairo_array_num_elements(&font->global_sub_index))
 		return CAIRO_INT_STATUS_UNSUPPORTED;
 	    element = _cairo_array_index (&font->global_sub_index, sub_num);
             if (! font->global_subs_used[sub_num] ||
diff --git a/src/cairo-svg-surface.c b/src/cairo-svg-surface.c
index fb6081c48..80f3a0eb0 100644
--- a/src/cairo-svg-surface.c
+++ b/src/cairo-svg-surface.c
@@ -1680,8 +1680,7 @@ _cairo_svg_surface_emit_static_filter (cairo_svg_document_t *document, enum cair
 {
     if (!document->filters_emitted[filter]) {
 	document->filters_emitted[filter] = TRUE;
-	switch (filter) {
-	case CAIRO_SVG_FILTER_REMOVE_COLOR:
+	if (filter == CAIRO_SVG_FILTER_REMOVE_COLOR) {
 	    // (r, g, b, a) -> (1, 1, 1, a)
 	    _cairo_svg_stream_printf (&document->xml_node_filters,
 				      "<filter id=\"filter-remove-color\" "
@@ -1692,8 +1691,7 @@ _cairo_svg_surface_emit_static_filter (cairo_svg_document_t *document, enum cair
 				      /*    */ "0 0 0 0 1 "
 				      /*    */ "0 0 0 1 0\" />\n"
 				      "</filter>\n");
-	    break;
-	case CAIRO_SVG_FILTER_REMOVE_COLOR_AND_INVERT_ALPHA:
+	} else if (filter == CAIRO_SVG_FILTER_REMOVE_COLOR_AND_INVERT_ALPHA) {
 	    // (r, g, b, a) -> (1, 1, 1, 1 - a)
 	    _cairo_svg_stream_printf (&document->xml_node_filters,
 				      "<filter id=\"filter-remove-color-and-invert-alpha\" "
@@ -1704,8 +1702,7 @@ _cairo_svg_surface_emit_static_filter (cairo_svg_document_t *document, enum cair
 				      /*    */ "0 0 0 0 1 "
 				      /*    */ "0 0 0 -1 1\"/>\n"
 				      "</filter>\n");
-	    break;
-	case CAIRO_SVG_FILTER_COLOR_TO_ALPHA:
+	} else if (filter ==  CAIRO_SVG_FILTER_COLOR_TO_ALPHA) {
 	    // (r, g, b, a) -> (1, 1, 1, 0.2126 * r + 0.7152 * g + 0.0722 * b)
 	    _cairo_svg_stream_printf (&document->xml_node_filters,
 				      "<filter id=\"filter-color-to-alpha\" "
@@ -1716,23 +1713,19 @@ _cairo_svg_surface_emit_static_filter (cairo_svg_document_t *document, enum cair
 				      /*    */ "0 0 0 0 1 "
 				      /*    */ "0.2126 0.7152 0.0722 0 0\"/>\n"
 				      "</filter>\n");
-	    break;
-	default:
-	    ASSERT_NOT_REACHED;
 	}
     }
 
-    switch (filter) {
-    case CAIRO_SVG_FILTER_REMOVE_COLOR:
+    if (filter == CAIRO_SVG_FILTER_REMOVE_COLOR) {
 	return "remove-color";
-    case CAIRO_SVG_FILTER_REMOVE_COLOR_AND_INVERT_ALPHA:
+    } else if (filter == CAIRO_SVG_FILTER_REMOVE_COLOR_AND_INVERT_ALPHA) {
 	return "remove-color-and-invert-alpha";
-    case CAIRO_SVG_FILTER_COLOR_TO_ALPHA:
+    } else if (filter ==  CAIRO_SVG_FILTER_COLOR_TO_ALPHA) {
 	return "color-to-alpha";
-    default:
+    } else {
 	ASSERT_NOT_REACHED;
-	return FALSE; /* squelch warning */
     }
+    return FALSE; /* squelch warning */
 }
 
 #define _CAIRO_SVG_SURFACE_OUTPUT_FE_COMPOSITE_FILTER(operation) \
@@ -1882,6 +1875,10 @@ _cairo_svg_surface_emit_parametric_filter (cairo_svg_surface_t *surface,
     case CAIRO_SVG_FILTER_LUMINOSITY:
 	_CAIRO_SVG_SURFACE_OUTPUT_FE_BLEND_FILTER ("luminosity")
 	break;
+    case CAIRO_SVG_FILTER_REMOVE_COLOR:
+    case CAIRO_SVG_FILTER_REMOVE_COLOR_AND_INVERT_ALPHA:
+    case CAIRO_SVG_FILTER_COLOR_TO_ALPHA:
+    case CAIRO_SVG_FILTER_LAST_STATIC_FILTER:
     default:
 	ASSERT_NOT_REACHED;
     }
diff --git a/src/cairo-type1-subset.c b/src/cairo-type1-subset.c
index 9565aa625..73f414dc4 100644
--- a/src/cairo-type1-subset.c
+++ b/src/cairo-type1-subset.c
@@ -630,7 +630,7 @@ cairo_type1_font_subset_decrypt_eexec_segment (cairo_type1_font_subset_t *font)
     unsigned char *in, *end;
     char *out;
     int c, p;
-    int i;
+    unsigned int i;
 
     in = (unsigned char *) font->eexec_segment;
     end = (unsigned char *) in + font->eexec_segment_size;
diff --git a/src/cairo-user-font.c b/src/cairo-user-font.c
index 089b64ad2..04c9ee699 100644
--- a/src/cairo-user-font.c
+++ b/src/cairo-user-font.c
@@ -176,13 +176,13 @@ _cairo_user_scaled_glyph_init (void			 *abstract_font,
 		status = face->scaled_font_methods.render_color_glyph ((cairo_scaled_font_t *)scaled_font,
 								       _cairo_scaled_glyph_index(scaled_glyph),
 								       cr, &extents);
-		if (status == CAIRO_STATUS_SUCCESS) {
+		if (status == CAIRO_INT_STATUS_SUCCESS) {
 		    status = cairo_status (cr);
 		    scaled_glyph->has_color = TRUE;
 		}
 	    }
 
-	    if (status == CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED &&
+	    if (status == (cairo_int_status_t)CAIRO_STATUS_USER_FONT_NOT_IMPLEMENTED &&
 		face->scaled_font_methods.render_glyph) {
 		recording_surface = _cairo_user_scaled_font_create_recording_surface (scaled_font, FALSE);
 
@@ -196,7 +196,7 @@ _cairo_user_scaled_glyph_init (void			 *abstract_font,
 		cairo_destroy (cr);
 	    }
 
-	    if (status != CAIRO_STATUS_SUCCESS) {
+	    if (status != CAIRO_INT_STATUS_SUCCESS) {
 		if (recording_surface)
 		    cairo_surface_destroy (recording_surface);
 		return status;
diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c
index 35db4c033..3ca82c4b7 100644
--- a/test/cairo-test-trace.c
+++ b/test/cairo-test-trace.c
@@ -791,7 +791,8 @@ matches_reference (struct slave *slave)
 			int channel;
 
 			for (channel = 0; channel < 4; channel++) {
-			    unsigned va, vb, diff;
+			    int va, vb;
+			    unsigned diff;
 
 			    va = (ua[x] >> (channel*8)) & 0xff;
 			    vb = (ub[x] >> (channel*8)) & 0xff;
@@ -815,7 +816,8 @@ matches_reference (struct slave *slave)
 			int channel;
 
 			for (channel = 0; channel < 3; channel++) {
-			    unsigned va, vb, diff;
+			    int va, vb;
+			    unsigned diff;
 
 			    va = (ua[x] >> (channel*8)) & 0xff;
 			    vb = (ub[x] >> (channel*8)) & 0xff;
diff --git a/test/operator-www.c b/test/operator-www.c
index 8657980ff..4d804fced 100644
--- a/test/operator-www.c
+++ b/test/operator-www.c
@@ -28,8 +28,8 @@
 #define WIDTH 160
 #define HEIGHT 120
 
-void
-example (cairo_t *cr, char *name)
+static void
+example (cairo_t *cr, const char *name)
 {
     cairo_save (cr);
     cairo_push_group_with_content (cr, cairo_surface_get_content (cairo_get_target (cr)));
commit ba3823e6b82c76bfe962f570dbf48e7c6a8126a6
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Mon Aug 16 18:23:17 2021 +0930

    Fix cast between incompatible function types warnings
    
    warning: cast between incompatible function types from ‘cairo_status_t (*)(void *, const cairo_point_t *)’ {aka ‘enum _cairo_status (*)(void *, const struct _cairo_point *)’} to ‘cairo_status_t (*)(void *, const cairo_point_t *, const cairo_slope_t *)’ {aka ‘enum _cairo_status (*)(void *, const struct _cairo_point *, const struct _cairo_slope *)’} [-Wcast-function-type]

diff --git a/src/cairo-path-fill.c b/src/cairo-path-fill.c
index 4000c9c58..d0c8551dc 100644
--- a/src/cairo-path-fill.c
+++ b/src/cairo-path-fill.c
@@ -69,6 +69,14 @@ _cairo_filler_line_to (void *closure,
     return status;
 }
 
+static cairo_status_t
+_cairo_filler_add_point (void *closure,
+			 const cairo_point_t *point,
+			 const cairo_slope_t *tangent)
+{
+    return _cairo_filler_line_to (closure, point);
+};
+
 static cairo_status_t
 _cairo_filler_close (void *closure)
 {
@@ -113,7 +121,7 @@ _cairo_filler_curve_to (void		*closure,
     }
 
     if (! _cairo_spline_init (&spline,
-			      (cairo_spline_add_point_func_t)_cairo_filler_line_to, filler,
+			      _cairo_filler_add_point, filler,
 			      &filler->current_point, p1, p2, p3))
     {
 	return _cairo_filler_line_to (closure, p3);
diff --git a/src/cairo-path-fixed.c b/src/cairo-path-fixed.c
index a6ab4e389..fc146f3b3 100644
--- a/src/cairo-path-fixed.c
+++ b/src/cairo-path-fixed.c
@@ -1134,6 +1134,14 @@ _cpf_line_to (void *closure,
     return cpf->line_to (cpf->closure, point);
 }
 
+static cairo_status_t
+_cpf_add_point (void *closure,
+		const cairo_point_t *point,
+		const cairo_slope_t *tangent)
+{
+    return _cpf_line_to (closure, point);
+};
+
 static cairo_status_t
 _cpf_curve_to (void		*closure,
 	       const cairo_point_t	*p1,
@@ -1146,8 +1154,8 @@ _cpf_curve_to (void		*closure,
     cairo_point_t *p0 = &cpf->current_point;
 
     if (! _cairo_spline_init (&spline,
-			      (cairo_spline_add_point_func_t)cpf->line_to,
-			      cpf->closure,
+			      _cpf_add_point,
+			      cpf,
 			      p0, p1, p2, p3))
     {
 	return _cpf_line_to (closure, p3);
diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
index 1787fb1a3..342d5a28e 100644
--- a/src/cairo-path-in-fill.c
+++ b/src/cairo-path-in-fill.c
@@ -183,6 +183,14 @@ _cairo_in_fill_line_to (void *closure,
     return CAIRO_STATUS_SUCCESS;
 }
 
+static cairo_status_t
+_cairo_in_fill_add_point (void *closure,
+                          const cairo_point_t *point,
+                          const cairo_slope_t *tangent)
+{
+    return _cairo_in_fill_line_to (closure, point);
+};
+
 static cairo_status_t
 _cairo_in_fill_curve_to (void *closure,
 			 const cairo_point_t *b,
@@ -217,7 +225,7 @@ _cairo_in_fill_curve_to (void *closure,
 
     /* XXX Investigate direct inspection of the inflections? */
     if (! _cairo_spline_init (&spline,
-			      (cairo_spline_add_point_func_t)_cairo_in_fill_line_to,
+			      _cairo_in_fill_add_point,
 			      in_fill,
 			      &in_fill->current_point, b, c, d))
     {
diff --git a/src/cairo-path-stroke-traps.c b/src/cairo-path-stroke-traps.c
index 1363ffa86..eab978235 100644
--- a/src/cairo-path-stroke-traps.c
+++ b/src/cairo-path-stroke-traps.c
@@ -930,6 +930,14 @@ line_to_dashed (void *closure, const cairo_point_t *point)
     return CAIRO_STATUS_SUCCESS;
 }
 
+static cairo_status_t
+add_point (void *closure,
+	   const cairo_point_t *point,
+	   const cairo_slope_t *tangent)
+{
+    return line_to_dashed (closure, point);
+};
+
 static cairo_status_t
 spline_to (void *closure,
 	   const cairo_point_t *point,
@@ -1042,7 +1050,7 @@ curve_to_dashed (void *closure,
     cairo_spline_add_point_func_t func;
     cairo_status_t status;
 
-    func = (cairo_spline_add_point_func_t)line_to_dashed;
+    func = add_point;
 
     if (stroker->has_bounds &&
 	! _cairo_spline_intersects (&stroker->current_face.point, b, c, d,
diff --git a/src/cairo-path-stroke.c b/src/cairo-path-stroke.c
index 64cec8f27..837551273 100644
--- a/src/cairo-path-stroke.c
+++ b/src/cairo-path-stroke.c
@@ -995,6 +995,14 @@ _cairo_stroker_line_to (void *closure,
     return CAIRO_STATUS_SUCCESS;
 }
 
+static cairo_status_t
+_cairo_stroker_add_point_line_to (void *closure,
+				  const cairo_point_t *point,
+				  const cairo_slope_t *tangent)
+{
+    return _cairo_stroker_line_to (closure, point);
+};
+
 static cairo_status_t
 _cairo_stroker_spline_to (void *closure,
 			  const cairo_point_t *point,
@@ -1225,6 +1233,14 @@ _cairo_stroker_line_to_dashed (void *closure,
     return CAIRO_STATUS_SUCCESS;
 }
 
+static cairo_status_t
+_cairo_stroker_add_point_line_to_dashed (void *closure,
+					 const cairo_point_t *point,
+					 const cairo_slope_t *tangent)
+{
+    return _cairo_stroker_line_to_dashed (closure, point);
+};
+
 static cairo_status_t
 _cairo_stroker_curve_to (void *closure,
 			 const cairo_point_t *b,
@@ -1241,13 +1257,13 @@ _cairo_stroker_curve_to (void *closure,
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
 
     line_to = stroker->dash.dashed ?
-	(cairo_spline_add_point_func_t) _cairo_stroker_line_to_dashed :
-	(cairo_spline_add_point_func_t) _cairo_stroker_line_to;
+	_cairo_stroker_add_point_line_to_dashed :
+	_cairo_stroker_add_point_line_to;
 
     /* spline_to is only capable of rendering non-degenerate splines. */
     spline_to = stroker->dash.dashed ?
-	(cairo_spline_add_point_func_t) _cairo_stroker_line_to_dashed :
-	(cairo_spline_add_point_func_t) _cairo_stroker_spline_to;
+	_cairo_stroker_add_point_line_to_dashed :
+	_cairo_stroker_spline_to;
 
     if (! _cairo_spline_init (&spline,
 			      spline_to,


More information about the cairo-commit mailing list