Skip to content

Commit a3b56f5

Browse files
davvidgitster
authored andcommitted
xdiff: avoid signed vs. unsigned comparisons in xutils.c
The comparisons all involve comparisons against unsigned values. Signed-off-by: David Aguilar <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 13b67f1 commit a3b56f5

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

xdiff/xutils.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@
2020
*
2121
*/
2222

23-
#define DISABLE_SIGN_COMPARE_WARNINGS
24-
2523
#include "xinclude.h"
2624

2725

@@ -377,7 +375,7 @@ static int xdl_format_hunk_hdr(long s1, long c1, long s2, long c2,
377375
nb += 3;
378376
if (func && funclen) {
379377
buf[nb++] = ' ';
380-
if (funclen > sizeof(buf) - nb - 1)
378+
if ((size_t)funclen > sizeof(buf) - nb - 1)
381379
funclen = sizeof(buf) - nb - 1;
382380
memcpy(buf + nb, func, funclen);
383381
nb += funclen;
@@ -439,7 +437,7 @@ void* xdl_alloc_grow_helper(void *p, long nr, long *alloc, size_t size)
439437
{
440438
void *tmp = NULL;
441439
size_t n = ((LONG_MAX - 16) / 2 >= *alloc) ? 2 * *alloc + 16 : LONG_MAX;
442-
if (nr > n)
440+
if ((size_t)nr > n)
443441
n = nr;
444442
if (SIZE_MAX / size >= n)
445443
tmp = xdl_realloc(p, n * size);

0 commit comments

Comments
 (0)