Patchwork [1,of,5] cext: fix compilation failure in revlog on Windows

login
register
mail settings
Submitter Matt Harbison
Date Aug. 10, 2018, 5:01 a.m.
Message ID <36b8875f1f317742e391.1533877275@Envy>
Download mbox | patch
Permalink /patch/33626/
State Accepted
Headers show

Comments

Matt Harbison - Aug. 10, 2018, 5:01 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1533872514 14400
#      Thu Aug 09 23:41:54 2018 -0400
# Node ID 36b8875f1f317742e3914b1dacde6af73a15a045
# Parent  751caa6a293664aa0296ab52f634872442f2bb5c
cext: fix compilation failure in revlog on Windows
via Mercurial-devel - Aug. 10, 2018, 5:18 a.m.
Sorry about that. I also fixed it in D4166. I'd prefer if that gets
accepted instead since I'll be away for a week now and won't be able to
rebase my series if this patch gets queued.

On Thu, Aug 9, 2018, 22:01 Matt Harbison <mharbison72@gmail.com> wrote:

> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1533872514 14400
> #      Thu Aug 09 23:41:54 2018 -0400
> # Node ID 36b8875f1f317742e3914b1dacde6af73a15a045
> # Parent  751caa6a293664aa0296ab52f634872442f2bb5c
> cext: fix compilation failure in revlog on Windows
>
> diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
> --- a/mercurial/cext/revlog.c
> +++ b/mercurial/cext/revlog.c
> @@ -1139,6 +1139,8 @@ static int nt_shortest(nodetree *self, c
>  static int index_init_nt(indexObject *self)
>  {
>         if (self->nt == NULL) {
> +               unsigned capacity;
> +
>                 if ((size_t)self->raw_length > INT_MAX /
> sizeof(nodetreenode)) {
>                         PyErr_SetString(PyExc_ValueError, "overflow in
> index_init_nt");
>                         return -1;
> @@ -1148,7 +1150,7 @@ static int index_init_nt(indexObject *se
>                         PyErr_NoMemory();
>                         return -1;
>                 }
> -               unsigned capacity = (self->raw_length < 4 ? 4 :
> (int)self->raw_length / 2);
> +               capacity = (self->raw_length < 4 ? 4 :
> (int)self->raw_length / 2);
>                 if (nt_init(self->nt, self, capacity) == -1) {
>                         PyMem_Free(self->nt);
>                         self->nt = NULL;
> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel@mercurial-scm.org
> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel
>
Matt Harbison - Aug. 10, 2018, 5:44 a.m.
No problem.  I didn’t see it until I got the buildbot fixed.  I’m fine with dropping this patch.

> On Aug 10, 2018, at 1:18 AM, Martin von Zweigbergk <martinvonz@google.com> wrote:
> 
> Sorry about that. I also fixed it in D4166. I'd prefer if that gets accepted instead since I'll be away for a week now and won't be able to rebase my series if this patch gets queued.
> 
>> On Thu, Aug 9, 2018, 22:01 Matt Harbison <mharbison72@gmail.com> wrote:
>> # HG changeset patch
>> # User Matt Harbison <matt_harbison@yahoo.com>
>> # Date 1533872514 14400
>> #      Thu Aug 09 23:41:54 2018 -0400
>> # Node ID 36b8875f1f317742e3914b1dacde6af73a15a045
>> # Parent  751caa6a293664aa0296ab52f634872442f2bb5c
>> cext: fix compilation failure in revlog on Windows
>> 
>> diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
>> --- a/mercurial/cext/revlog.c
>> +++ b/mercurial/cext/revlog.c
>> @@ -1139,6 +1139,8 @@ static int nt_shortest(nodetree *self, c
>>  static int index_init_nt(indexObject *self)
>>  {
>>         if (self->nt == NULL) {
>> +               unsigned capacity;
>> +
>>                 if ((size_t)self->raw_length > INT_MAX / sizeof(nodetreenode)) {
>>                         PyErr_SetString(PyExc_ValueError, "overflow in index_init_nt");
>>                         return -1;
>> @@ -1148,7 +1150,7 @@ static int index_init_nt(indexObject *se
>>                         PyErr_NoMemory();
>>                         return -1;
>>                 }
>> -               unsigned capacity = (self->raw_length < 4 ? 4 : (int)self->raw_length / 2);
>> +               capacity = (self->raw_length < 4 ? 4 : (int)self->raw_length / 2);
>>                 if (nt_init(self->nt, self, capacity) == -1) {
>>                         PyMem_Free(self->nt);
>>                         self->nt = NULL;
>> _______________________________________________
>> Mercurial-devel mailing list
>> Mercurial-devel@mercurial-scm.org
>> https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -1139,6 +1139,8 @@  static int nt_shortest(nodetree *self, c
 static int index_init_nt(indexObject *self)
 {
 	if (self->nt == NULL) {
+		unsigned capacity;
+
 		if ((size_t)self->raw_length > INT_MAX / sizeof(nodetreenode)) {
 			PyErr_SetString(PyExc_ValueError, "overflow in index_init_nt");
 			return -1;
@@ -1148,7 +1150,7 @@  static int index_init_nt(indexObject *se
 			PyErr_NoMemory();
 			return -1;
 		}
-		unsigned capacity = (self->raw_length < 4 ? 4 : (int)self->raw_length / 2);
+		capacity = (self->raw_length < 4 ? 4 : (int)self->raw_length / 2);
 		if (nt_init(self->nt, self, capacity) == -1) {
 			PyMem_Free(self->nt);
 			self->nt = NULL;