Skip to content

Commit 2dc6cf2

Browse files
davvidgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 46fb084 commit 2dc6cf2

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

xdiff/xhistogram.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@
4141
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4242
*/
4343

44-
#define DISABLE_SIGN_COMPARE_WARNINGS
45-
4644
#include "xinclude.h"
4745

4846
#define MAX_PTR UINT_MAX
@@ -108,7 +106,7 @@ static int scanA(struct histindex *index, int line1, int count1)
108106
unsigned int chain_len;
109107
struct record **rec_chain, *rec;
110108

111-
for (ptr = LINE_END(1); line1 <= ptr; ptr--) {
109+
for (ptr = LINE_END(1); (unsigned int)line1 <= ptr; ptr--) {
112110
tbl_idx = TABLE_HASH(index, 1, ptr);
113111
rec_chain = index->records + tbl_idx;
114112
rec = *rec_chain;
@@ -183,14 +181,14 @@ static int try_lcs(struct histindex *index, struct region *lcs, int b_ptr,
183181
be = bs;
184182
rc = rec->cnt;
185183

186-
while (line1 < as && line2 < bs
184+
while ((unsigned int)line1 < as && (unsigned int)line2 < bs
187185
&& CMP(index, 1, as - 1, 2, bs - 1)) {
188186
as--;
189187
bs--;
190188
if (1 < rc)
191189
rc = XDL_MIN(rc, CNT(index, as));
192190
}
193-
while (ae < LINE_END(1) && be < LINE_END(2)
191+
while (ae < (unsigned int)LINE_END(1) && be < (unsigned int)LINE_END(2)
194192
&& CMP(index, 1, ae + 1, 2, be + 1)) {
195193
ae++;
196194
be++;
@@ -315,7 +313,7 @@ static int histogram_diff(xpparam_t const *xpp, xdfenv_t *env,
315313
if (count1 <= 0 && count2 <= 0)
316314
return 0;
317315

318-
if (LINE_END(1) >= MAX_PTR)
316+
if ((unsigned int)LINE_END(1) >= MAX_PTR)
319317
return -1;
320318

321319
if (!count1) {

0 commit comments

Comments
 (0)