From b7f360b8e3a6275b5a031fd74cc0991d4621a70f Mon Sep 17 00:00:00 2001 From: Matthew Fernandez Date: Sun, 8 May 2022 16:41:17 -0700 Subject: [PATCH] dotgen: squash -Wsign-conversion warnings in 'medians' The compiler says: mincross.c: In function 'medians': mincross.c:1803:25: warning: conversion to 'size_t' {aka 'long unsigned int'} from 'int' may change the sign of the result [-Wsign-conversion] 1803 | qsort(list, j, sizeof(int), (qsort_cmpf) ordercmpf); | ^ By doing array indexing in this function universally as `size_t` we can avoid this. --- lib/dotgen/mincross.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/dotgen/mincross.c b/lib/dotgen/mincross.c index 943cac615..89557aa64 100644 --- a/lib/dotgen/mincross.c +++ b/lib/dotgen/mincross.c @@ -1769,7 +1769,7 @@ static bool flat_mval(node_t * n) static bool medians(graph_t * g, int r0, int r1) { - int i, j, j0, lm, rm, lspan, rspan, *list; + int i, j0, lspan, rspan, *list; node_t *n, **v; edge_t *e; bool hasfixed = false; @@ -1778,7 +1778,7 @@ static bool medians(graph_t * g, int r0, int r1) v = GD_rank(g)[r0].v; for (i = 0; i < GD_rank(g)[r0].n; i++) { n = v[i]; - j = 0; + size_t j = 0; if (r1 > r0) for (j0 = 0; (e = ND_out(n).list[j0]); j0++) { if (ED_xpenalty(e) > 0) @@ -1804,8 +1804,8 @@ static bool medians(graph_t * g, int r0, int r1) ND_mval(n) = list[j / 2]; else { /* weighted median */ - rm = j / 2; - lm = rm - 1; + size_t rm = j / 2; + size_t lm = rm - 1; rspan = list[j - 1] - list[rm]; lspan = list[lm] - list[0]; if (lspan == rspan) -- 2.40.0