xdiff: avoid signed vs. unsigned comparisons in xhistogram.c

The comparisons all involve unsigned variables. Cast the comparison to unsigned to eliminate the mismatch. Signed-off-by: David Aguilar <davvid@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

David Aguilar committed Feb 11, 2025 at 22:04 UTC 2dc6cf247e907009950a46c400cbd5efc563a3a2
1 file changed +4 -6
xdiff/xhistogram.c
+4 -6
@@ -41,8 +41,6 @@
41 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
42 */
43
44 -#define DISABLE_SIGN_COMPARE_WARNINGS
45 -
44 #include "xinclude.h"
45
46 #define MAX_PTR UINT_MAX
@@ -108,7 +106,7 @@ static int scanA(struct histindex *index, int line1, int count1)
106 unsigned int chain_len;
107 struct record **rec_chain, *rec;
108
111 - for (ptr = LINE_END(1); line1 <= ptr; ptr--) {
109 + for (ptr = LINE_END(1); (unsigned int)line1 <= ptr; ptr--) {
110 tbl_idx = TABLE_HASH(index, 1, ptr);
111 rec_chain = index->records + tbl_idx;
112 rec = *rec_chain;
@@ -183,14 +181,14 @@ static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
181 be = bs;
182 rc = rec->cnt;
183
186 - while (line1 < as && line2 < bs
184 + while ((unsigned int)line1 < as && (unsigned int)line2 < bs
185 && CMP(index, 1, as - 1, 2, bs - 1)) {
186 as--;
187 bs--;
188 if (1 < rc)
189 rc = XDL_MIN(rc, CNT(index, as));
190 }
193 - while (ae < LINE_END(1) && be < LINE_END(2)
191 + while (ae < (unsigned int)LINE_END(1) && be < (unsigned int)LINE_END(2)
192 && CMP(index, 1, ae + 1, 2, be + 1)) {
193 ae++;
194 be++;
@@ -315,7 +313,7 @@ redo:
313 if (count1 <= 0 && count2 <= 0)
314 return 0;
315
318 - if (LINE_END(1) >= MAX_PTR)
316 + if ((unsigned int)LINE_END(1) >= MAX_PTR)
317 return -1;
318
319 if (!count1) {