[PATCH 4 of 4 warning-cleanup] parsers: avoid comparing Py_ssize_t (aka long) with unsigned long

Augie Fackler raf at durin42.com
Fri Aug 21 13:36:12 CDT 2015


# HG changeset patch
# User Augie Fackler <augie at google.com>
# Date 1440182108 14400
#      Fri Aug 21 14:35:08 2015 -0400
# Node ID a8abb7badebc5d2fd18189f83b3140aa7af2ac5c
# Parent  c94fce4d889c4f83b6d62bd8a2d4550aa0fb91f0
parsers: avoid comparing Py_ssize_t (aka long) with unsigned long

Detected with
make local CFLAGS='-Wall -Wextra -Wno-missing-field-initializers -Wno-unused-parameter' CC=clang

As of this change, that command no longer emits compiler errors.

diff --git a/mercurial/parsers.c b/mercurial/parsers.c
--- a/mercurial/parsers.c
+++ b/mercurial/parsers.c
@@ -1576,7 +1576,7 @@ static int nt_insert(indexObject *self, 
 static int nt_init(indexObject *self)
 {
 	if (self->nt == NULL) {
-		if (self->raw_length > INT_MAX / sizeof(nodetree)) {
+		if (self->raw_length > (Py_ssize_t) (INT_MAX / sizeof(nodetree))) {
 			PyErr_SetString(PyExc_ValueError, "overflow in nt_init");
 			return -1;
 		}


More information about the Mercurial-devel mailing list