Patchwork [5,of,6,v2] parsers: use correct type for file offset

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

Comments

Henrik Stuart - Sept. 9, 2014, 5:51 p.m.
# HG changeset patch
# User Henrik Stuart <hg@hstuart.dk>
# Date 1410200530 -7200
#      Mon Sep 08 20:22:10 2014 +0200
# Node ID 8bfb3cef896c160faec2659c4758fc9d3d28b1c4
# Parent  257dfbd95ce8f9318560a5747f35de59467c7e94
parsers: use correct type for file offset

Now using Py_ssize_t instead of long to denote offset in file whose length is
already measured using Py_ssize_t. Length and offset are now consistent. Based
on warning from Microsoft Visual C++ 2008.

Patch

diff -r 257dfbd95ce8 -r 8bfb3cef896c mercurial/parsers.c
--- a/mercurial/parsers.c	Mon Sep 08 20:20:17 2014 +0200
+++ b/mercurial/parsers.c	Mon Sep 08 20:22:10 2014 +0200
@@ -681,10 +681,9 @@ 
 {
 	PyObject *obj;
 	char *node;
-	long offset;
-	Py_ssize_t len, nodelen;
+	Py_ssize_t offset, len, nodelen;
 
-	if (!PyArg_ParseTuple(args, "lO", &offset, &obj))
+	if (!PyArg_ParseTuple(args, "nO", &offset, &obj))
 		return NULL;
 
 	if (!PyTuple_Check(obj) || PyTuple_GET_SIZE(obj) != 8) {