From e9aafb9d4728d7b3806fb0866dc3927dd04691e2 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 8 Feb 2023 22:32:35 +0100 Subject: Fix warnings and infinite loop bug MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- draw_linear_bezier_reference.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/draw_linear_bezier_reference.c b/draw_linear_bezier_reference.c index 63a978f..dbfb87f 100644 --- a/draw_linear_bezier_reference.c +++ b/draw_linear_bezier_reference.c @@ -35,8 +35,8 @@ draw_linear_bezier_reference(RASTER *restrict raster, double x1, double y1, doub /* Find next vertical and next hozitonal grid line */ x = xdir < 0 ? floor(prevX) : xdir > 0 ? ceil(prevX) : prevX; y = ydir < 0 ? floor(prevY) : ydir > 0 ? ceil(prevY) : prevY; - x = x == prevX ? x + xdir : x; - y = y == prevY ? y + ydir : y; + x = iszeroish(x - prevX) ? x + xdir : x; + y = iszeroish(y - prevY) ? y + ydir : y; /* Limit to the extend of the drawn line segment */ if ((xdir < 0 && x < x2) || (xdir > 0 && x > x2)) @@ -540,13 +540,13 @@ check_random_line(double rand_xmin, double rand_xmax, double rand_ymin, double r if (!dy) continue; - hit = x >= floor(xmin) && x <= ceil(xmax); + hit = (double)x >= floor(xmin) && (double)x <= ceil(xmax); hit |= !x && xmin < 0; - hit &= y >= floor(ymin) && y <= ceil(ymax); + hit &= (double)y >= floor(ymin) && (double)y <= ceil(ymax); ASSERT(hit || !raster->cells[y * 10 + x].cell_coverage); - hit = x >= floor(xmin) && x <= ceil(xmax); - hit &= y >= floor(ymin) && y <= ceil(ymax); + hit = (double)x >= floor(xmin) && (double)x <= ceil(xmax); + hit &= (double)y >= floor(ymin) && (double)y <= ceil(ymax); if (!hit || !dx || !x) continue; -- cgit v1.2.3-70-g09d2