xdiff: resolve signed unsigned comparison warning
authorJun Wu <quark@fb.com>
Fri, 09 Mar 2018 14:52:36 -0800
changeset 36826 e5b14f5b8b94
parent 36825 f1ef0e53e628
child 36827 12492794bf8c
xdiff: resolve signed unsigned comparison warning Since the value won't be changed inside the code (because context lines feature was removed by D2705), let's just remove the variable and inline the 0 value. The code might be potentially further simplified. But I'd like to make sure correctness is easily verifiable in this patch. Differential Revision: https://phab.mercurial-scm.org/D2766
mercurial/thirdparty/xdiff/xdiffi.c
--- a/mercurial/thirdparty/xdiff/xdiffi.c	Fri Mar 09 14:47:29 2018 -0800
+++ b/mercurial/thirdparty/xdiff/xdiffi.c	Fri Mar 09 14:52:36 2018 -0800
@@ -1015,8 +1015,6 @@
 xdchange_t *xdl_get_hunk(xdchange_t **xscr)
 {
 	xdchange_t *xch, *xchp, *lxch;
-	int64_t max_common = 0;
-	int64_t max_ignorable = 0;
 	uint64_t ignored = 0; /* number of ignored blank lines */
 
 	/* remove ignorable changes that are too far before other changes */
@@ -1024,7 +1022,7 @@
 		xch = xchp->next;
 
 		if (xch == NULL ||
-		    xch->i1 - (xchp->i1 + xchp->chg1) >= max_ignorable)
+		    xch->i1 - (xchp->i1 + xchp->chg1) >= 0)
 			*xscr = xch;
 	}
 
@@ -1035,16 +1033,16 @@
 
 	for (xchp = *xscr, xch = xchp->next; xch; xchp = xch, xch = xch->next) {
 		int64_t distance = xch->i1 - (xchp->i1 + xchp->chg1);
-		if (distance > max_common)
+		if (distance > 0)
 			break;
 
-		if (distance < max_ignorable && (!xch->ignore || lxch == xchp)) {
+		if (distance < 0 && (!xch->ignore || lxch == xchp)) {
 			lxch = xch;
 			ignored = 0;
-		} else if (distance < max_ignorable && xch->ignore) {
+		} else if (distance < 0 && xch->ignore) {
 			ignored += xch->chg2;
 		} else if (lxch != xchp &&
-			   xch->i1 + ignored - (lxch->i1 + lxch->chg1) > max_common) {
+			   xch->i1 + ignored - (lxch->i1 + lxch->chg1) > 0) {
 			break;
 		} else if (!xch->ignore) {
 			lxch = xch;