# HG changeset patch # User Abhay Kadam # Date 1384885151 -19800 # Node ID 40b7c6e4b9934c59c244f0a8b8a44258065b1174 # Parent af12f58e2aa081ce512cc4a8b87dd354a45123e5 mercurial/parsers.c: fix compiler warning When try to compile on x64 OS X, I get this warning: mercurial/parsers.c:931:27: warning: implicit conversion loses integer precision : 'long' to 'int' [-Wshorten-64-to-32] ? 4 : self->raw_length / 2; The patch verifies if value of self->raw_length falls bellow INT_MAX; if not, it raises the ValueError exception. If value of self->raw_length is greater than 4, it's casted to int type, to eliminate the warning. diff -r af12f58e2aa0 -r 40b7c6e4b993 mercurial/parsers.c --- a/mercurial/parsers.c Mon Nov 25 16:15:44 2013 -0600 +++ b/mercurial/parsers.c Tue Nov 19 23:49:11 2013 +0530 @@ -927,8 +927,13 @@ static int nt_init(indexObject *self) { if (self->nt == NULL) { + if (self->raw_length > INT_MAX) { + PyErr_SetString(PyExc_ValueError, "overflow in nt_init"); + return -1; + } self->ntcapacity = self->raw_length < 4 - ? 4 : self->raw_length / 2; + ? 4 : (int)self->raw_length / 2; + self->nt = calloc(self->ntcapacity, sizeof(nodetree)); if (self->nt == NULL) { PyErr_NoMemory();