Patchwork bdiff: avoid pointer arithmetic on void*

login
register
mail settings
Submitter Matt Harbison
Date March 4, 2018, 4:31 a.m.
Message ID <8b9334b59784246d5a09.1520137872@Envy>
Download mbox | patch
Permalink /patch/28906/
State Accepted
Headers show

Comments

Matt Harbison - March 4, 2018, 4:31 a.m.
# HG changeset patch
# User Matt Harbison <matt_harbison@yahoo.com>
# Date 1520137780 18000
#      Sat Mar 03 23:29:40 2018 -0500
# Node ID 8b9334b59784246d5a09bad537d6e15a0f190c97
# Parent  3f829cbdfe3a89c28c8807d3a933159fb2d93992
bdiff: avoid pointer arithmetic on void*

MSVC 2008 complains:

  mercurial/cext/bdiff.c(106) : error C2036: 'void *' : unknown size
  mercurial/cext/bdiff.c(107) : error C2036: 'void *' : unknown size

Maybe it's a gcc extension?

https://stackoverflow.com/questions/37460579/error-c2036-void-unknown-size
Yuya Nishihara - March 4, 2018, 12:10 p.m.
On Sat, 03 Mar 2018 23:31:12 -0500, Matt Harbison wrote:
> # HG changeset patch
> # User Matt Harbison <matt_harbison@yahoo.com>
> # Date 1520137780 18000
> #      Sat Mar 03 23:29:40 2018 -0500
> # Node ID 8b9334b59784246d5a09bad537d6e15a0f190c97
> # Parent  3f829cbdfe3a89c28c8807d3a933159fb2d93992
> bdiff: avoid pointer arithmetic on void*

Queued, thanks.

> diff --git a/mercurial/cext/bdiff.c b/mercurial/cext/bdiff.c
> --- a/mercurial/cext/bdiff.c
> +++ b/mercurial/cext/bdiff.c
> @@ -103,8 +103,8 @@
>  	}
>  	/* we can almost add: if (li == lmax) lcommon = li; */
>  
> -	an = bdiff_splitlines(ba.buf + lcommon, la - lcommon, &al);
> -	bn = bdiff_splitlines(bb.buf + lcommon, lb - lcommon, &bl);
> +	an = bdiff_splitlines(((char *)ba.buf) + lcommon, la - lcommon, &al);
> +	bn = bdiff_splitlines(((char *)ba.buf) + lcommon, lb - lcommon, &bl);
                                        ^
Fixed typo.

Patch

diff --git a/mercurial/cext/bdiff.c b/mercurial/cext/bdiff.c
--- a/mercurial/cext/bdiff.c
+++ b/mercurial/cext/bdiff.c
@@ -103,8 +103,8 @@ 
 	}
 	/* we can almost add: if (li == lmax) lcommon = li; */
 
-	an = bdiff_splitlines(ba.buf + lcommon, la - lcommon, &al);
-	bn = bdiff_splitlines(bb.buf + lcommon, lb - lcommon, &bl);
+	an = bdiff_splitlines(((char *)ba.buf) + lcommon, la - lcommon, &al);
+	bn = bdiff_splitlines(((char *)ba.buf) + lcommon, lb - lcommon, &bl);
 	if (!al || !bl) {
 		PyErr_NoMemory();
 		goto cleanup;