Patchwork [4,of,6,v2] parsers: ensure correct return type for inline_scan

login
register
mail settings
Submitter Henrik Stuart
Date Sept. 9, 2014, 5:51 p.m.
Message ID <257dfbd95ce8f9318560.1410285100@yggdrasil>
Download mbox | patch
Permalink /patch/5742/
State Accepted
Headers show

Comments

Henrik Stuart - Sept. 9, 2014, 5:51 p.m.
# HG changeset patch
# User Henrik Stuart <hg@hstuart.dk>
# Date 1410200417 -7200
#      Mon Sep 08 20:20:17 2014 +0200
# Node ID 257dfbd95ce8f9318560a5747f35de59467c7e94
# Parent  620d7f5d8ff74d46159e8fb83ebf3c9e401216b7
parsers: ensure correct return type for inline_scan

The returned data type for inline_scan should be Py_ssize_t rather than long.
Based on warning from Microsoft Visual C++ 2008.

Patch

diff -r 620d7f5d8ff7 -r 257dfbd95ce8 mercurial/parsers.c
--- a/mercurial/parsers.c	Mon Sep 08 20:13:15 2014 +0200
+++ b/mercurial/parsers.c	Mon Sep 08 20:20:17 2014 +0200
@@ -524,7 +524,7 @@ 
 static PyObject *nullentry;
 static const char nullid[20];
 
-static long inline_scan(indexObject *self, const char **offsets);
+static Py_ssize_t inline_scan(indexObject *self, const char **offsets);
 
 #if LONG_MAX == 0x7fffffffL
 static char *tuple_format = "Kiiiiiis#";
@@ -1853,7 +1853,7 @@ 
  * Find all RevlogNG entries in an index that has inline data. Update
  * the optional "offsets" table with those entries.
  */
-static long inline_scan(indexObject *self, const char **offsets)
+static Py_ssize_t inline_scan(indexObject *self, const char **offsets)
 {
 	const char *data = PyString_AS_STRING(self->data);
 	Py_ssize_t pos = 0;
@@ -1913,7 +1913,7 @@ 
 	Py_INCREF(self->data);
 
 	if (self->inlined) {
-		long len = inline_scan(self, NULL);
+		Py_ssize_t len = inline_scan(self, NULL);
 		if (len == -1)
 			goto bail;
 		self->raw_length = len;