mirror of
https://github.com/python/cpython.git
synced 2025-10-03 05:35:59 +00:00
Fix new compiler warnings. Also boost "start" from (C) int to long and
return a (C) long: PyArg_ParseTuple and Py_BuildValue may not let us get at the size_t we really want, but C int is clearly too small for a 64-bit box, and both the start parameter and the return value should work for large mapped files even on 32-bit boxes. The code really needs to be rethought from scratch (not by me, though ...).
This commit is contained in:
parent
58e0a8c130
commit
d401eddf91
1 changed files with 5 additions and 5 deletions
|
@ -224,12 +224,12 @@ static PyObject *
|
||||||
mmap_find_method(mmap_object *self,
|
mmap_find_method(mmap_object *self,
|
||||||
PyObject *args)
|
PyObject *args)
|
||||||
{
|
{
|
||||||
int start = self->pos;
|
long start = self->pos;
|
||||||
char *needle;
|
char *needle;
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
CHECK_VALID(NULL);
|
CHECK_VALID(NULL);
|
||||||
if (!PyArg_ParseTuple (args, "s#|i:find", &needle, &len, &start)) {
|
if (!PyArg_ParseTuple (args, "s#|l:find", &needle, &len, &start)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
} else {
|
} else {
|
||||||
char *p;
|
char *p;
|
||||||
|
@ -239,7 +239,7 @@ mmap_find_method(mmap_object *self,
|
||||||
start += self->size;
|
start += self->size;
|
||||||
if (start < 0)
|
if (start < 0)
|
||||||
start = 0;
|
start = 0;
|
||||||
else if (start > self->size)
|
else if ((size_t)start > self->size)
|
||||||
start = self->size;
|
start = self->size;
|
||||||
p = self->data + start;
|
p = self->data + start;
|
||||||
|
|
||||||
|
@ -251,8 +251,8 @@ mmap_find_method(mmap_object *self,
|
||||||
}
|
}
|
||||||
if (!*n) {
|
if (!*n) {
|
||||||
return Py_BuildValue (
|
return Py_BuildValue (
|
||||||
"i",
|
"l",
|
||||||
(int) (p - self->data));
|
(long) (p - self->data));
|
||||||
}
|
}
|
||||||
p++;
|
p++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue