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

The comparisons all involve comparisons against unsigned values. 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 a3b56f5f431d2421b575f329d401361e3196b467
1 file changed +2 -4
xdiff/xutils.c
+2 -4
@@ -20,8 +20,6 @@
20 *
21 */
22
23 -#define DISABLE_SIGN_COMPARE_WARNINGS
24 -
23 #include "xinclude.h"
24
25
@@ -377,7 +375,7 @@ static int xdl_format_hunk_hdr(long s1, long c1, long s2, long c2,
375 nb += 3;
376 if (func && funclen) {
377 buf[nb++] = ' ';
380 - if (funclen > sizeof(buf) - nb - 1)
378 + if ((size_t)funclen > sizeof(buf) - nb - 1)
379 funclen = sizeof(buf) - nb - 1;
380 memcpy(buf + nb, func, funclen);
381 nb += funclen;
@@ -439,7 +437,7 @@ void* xdl_alloc_grow_helper(void *p, long nr, long *alloc, size_t size)
437 {
438 void *tmp = NULL;
439 size_t n = ((LONG_MAX - 16) / 2 >= *alloc) ? 2 * *alloc + 16 : LONG_MAX;
442 - if (nr > n)
440 + if ((size_t)nr > n)
441 n = nr;
442 if (SIZE_MAX / size >= n)
443 tmp = xdl_realloc(p, n * size);