From 44a09f462c8ff59f864967f45f9b31e473632b7a Mon Sep 17 00:00:00 2001 From: Bryce Harrington Date: Tue, 18 Feb 2014 21:13:53 -0800 Subject: [PATCH] mesh: Avoid theoretical infinite loops This quells this warning: src/cairo-mesh-pattern-rasterizer.c:731:5: warning: cannot optimize possibly infinite loops I guess the compiler's complaining because if vsteps were negative or equal to UINT_MAX the loop could cycle infinitely. Silly compiler. Fix as suggested by Chris Wilson --- src/cairo-mesh-pattern-rasterizer.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/cairo-mesh-pattern-rasterizer.c b/src/cairo-mesh-pattern-rasterizer.c index 6f0dd6667..548e88056 100644 --- a/src/cairo-mesh-pattern-rasterizer.c +++ b/src/cairo-mesh-pattern-rasterizer.c @@ -697,9 +697,9 @@ rasterize_bezier_patch (unsigned char *data, int width, int height, int stride, cairo_point_double_t p[4][4], double col[4][4]) { double pv[4][2][4], cstart[4], cend[4], dcstart[4], dcend[4]; - int vsteps, v, i, k; + int v, i, k; - vsteps = 1 << vshift; + v = 1 << vshift; /* * pv[i][0] is the function (represented using forward @@ -724,11 +724,11 @@ rasterize_bezier_patch (unsigned char *data, int width, int height, int stride, for (i = 0; i < 4; ++i) { cstart[i] = col[0][i]; cend[i] = col[1][i]; - dcstart[i] = (col[2][i] - col[0][i]) / vsteps; - dcend[i] = (col[3][i] - col[1][i]) / vsteps; + dcstart[i] = (col[2][i] - col[0][i]) / v; + dcend[i] = (col[3][i] - col[1][i]) / v; } - for (v = 0; v <= vsteps; ++v) { + while (v--) { cairo_point_double_t nodes[4]; for (i = 0; i < 4; ++i) { nodes[i].x = pv[i][0][0];