From eaae7789cdbe882af150c74f7bf73f0a72d724e7 Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Fri, 20 Jan 2023 08:25:15 -0800 Subject: [PATCH] gvmap plot_dot_polygons: use a 'size_t' for 'maxlen' Squashes some -Wsign-conversion warnings. --- cmd/gvmap/make_map.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmd/gvmap/make_map.c b/cmd/gvmap/make_map.c index 220a4f091..50e920250 100644 --- a/cmd/gvmap/make_map.c +++ b/cmd/gvmap/make_map.c @@ -277,13 +277,19 @@ static void plot_dot_polygons(agxbuf *sbuff, double line_width, double *x_poly, int *polys_groups, float *r, float *g, float *b, const char *opacity) { int i, j, *ia = polys->ia, *ja = polys->ja, *a = polys->a, npolys = polys->m, nverts = polys->n, ipoly,first; - int np = 0, maxlen = 0; + int np = 0; float *xp, *yp; int fill = -1; char cstring[] = "#aaaaaaff"; int use_line = (line_width >= 0); - for (i = 0; i < npolys; i++) maxlen = MAX(maxlen, ia[i+1]-ia[i]); + size_t maxlen = 0; + for (i = 0; i < npolys; i++) { + int len = ia[i + 1] - ia[i]; + if (len > 0 && (size_t)len > maxlen) { + maxlen = (size_t)len; + } + } xp = gv_calloc(maxlen, sizeof(float)); yp = gv_calloc(maxlen, sizeof(float)); -- 2.40.0