Patchwork [STABLE,RESEND] rust: fix signature of rustlazyancestors_init() function

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 2, 2018, 12:44 p.m.
Message ID <41f48262b845632a1fca.1541162680@mimosa>
Download mbox | patch
Permalink /patch/36333/
State New
Headers show

Comments

Yuya Nishihara - Nov. 2, 2018, 12:44 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@tcha.org>
# Date 1540728996 -32400
#      Sun Oct 28 21:16:36 2018 +0900
# Branch stable
# Node ID 41f48262b845632a1fca09e79d72fdb8eb1eb624
# Parent  324ba8b14d7836a5cd4c5586f270391725168c0a
rust: fix signature of rustlazyancestors_init() function

Obviously, sizeof(int) != mem::size_of::<usize>() on amd64, though the
argument would be passed in 64-bit register anyway.
Augie Fackler - Nov. 2, 2018, 5:31 p.m.
On Fri, Nov 02, 2018 at 09:44:40PM +0900, Yuya Nishihara wrote:
> # HG changeset patch
> # User Yuya Nishihara <yuya@tcha.org>
> # Date 1540728996 -32400
> #      Sun Oct 28 21:16:36 2018 +0900
> # Branch stable
> # Node ID 41f48262b845632a1fca09e79d72fdb8eb1eb624
> # Parent  324ba8b14d7836a5cd4c5586f270391725168c0a
> rust: fix signature of rustlazyancestors_init() function

queued for stable, thanks

Patch

diff --git a/mercurial/cext/revlog.c b/mercurial/cext/revlog.c
--- a/mercurial/cext/revlog.c
+++ b/mercurial/cext/revlog.c
@@ -2311,7 +2311,7 @@  rustlazyancestorsObject *rustlazyancesto
 	/* to pass index_get_parents() */
 	int (*)(indexObject *, Py_ssize_t, int*, int),
 	/* intrevs vector */
-	int initrevslen, long *initrevs,
+	Py_ssize_t initrevslen, long *initrevs,
 	long stoprev,
 	int inclusive);
 void rustlazyancestors_drop(rustlazyancestorsObject *self);
diff --git a/rust/hg-direct-ffi/src/ancestors.rs b/rust/hg-direct-ffi/src/ancestors.rs
--- a/rust/hg-direct-ffi/src/ancestors.rs
+++ b/rust/hg-direct-ffi/src/ancestors.rs
@@ -60,15 +60,16 @@  impl Graph for Index {
 pub extern "C" fn rustlazyancestors_init(
     index: IndexPtr,
     parents: IndexParentsFn,
-    initrevslen: usize,
+    initrevslen: ssize_t,
     initrevs: *mut c_long,
     stoprev: c_long,
     inclusive: c_int,
 ) -> *mut AncestorsIterator<Index> {
+    assert!(initrevslen >= 0);
     unsafe {
         raw_init(
             Index::new(index, parents),
-            initrevslen,
+            initrevslen as usize,
             initrevs,
             stoprev,
             inclusive,