summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2005-09-03 07:49:48 (GMT)
committerGeorg Brandl <georg@python.org>2005-09-03 07:49:48 (GMT)
commitede0c6680e4aee5756f346bca0396825cd4f172d (patch)
tree7e22595b9ac807953a9faaf8f8a632c358b7c8c4
parent93660676bc54c354665095d2c36742527db7be3e (diff)
downloadcpython-ede0c6680e4aee5756f346bca0396825cd4f172d.zip
cpython-ede0c6680e4aee5756f346bca0396825cd4f172d.tar.gz
cpython-ede0c6680e4aee5756f346bca0396825cd4f172d.tar.bz2
bug [ 1274069 ] bz2module.c compiler warning
-rw-r--r--Modules/bz2module.c17
1 files changed, 12 insertions, 5 deletions
diff --git a/Modules/bz2module.c b/Modules/bz2module.c
index 59597b5..fca8498 100644
--- a/Modules/bz2module.c
+++ b/Modules/bz2module.c
@@ -110,8 +110,8 @@ typedef struct {
BZFILE *fp;
int mode;
- long pos;
- long size;
+ Py_off_t pos;
+ Py_off_t size;
#ifdef WITH_THREAD
PyThread_type_lock lock;
#endif
@@ -982,7 +982,7 @@ BZ2File_seek(BZ2FileObject *self, PyObject *args)
char *buffer = small_buffer;
size_t buffersize = SMALLCHUNK;
int bytesread = 0;
- int readsize;
+ size_t readsize;
int chunksize;
int bzerror;
int rewind = 0;
@@ -1089,10 +1089,13 @@ BZ2File_seek(BZ2FileObject *self, PyObject *args)
/* Before getting here, offset must be set to the number of bytes
* to walk forward. */
for (;;) {
- if ((size_t)offset-bytesread > buffersize)
+ if (offset-bytesread > buffersize)
readsize = buffersize;
else
- readsize = offset-bytesread;
+ /* offset might be wider that readsize, but the result
+ * of the subtraction is bound by buffersize (see the
+ * condition above). buffersize is 8192. */
+ readsize = (size_t)(offset-bytesread);
Py_BEGIN_ALLOW_THREADS
chunksize = Util_UnivNewlineRead(&bzerror, self->fp,
buffer, readsize, self);
@@ -1137,7 +1140,11 @@ BZ2File_tell(BZ2FileObject *self, PyObject *args)
goto cleanup;
}
+#if !defined(HAVE_LARGEFILE_SUPPORT)
ret = PyInt_FromLong(self->pos);
+#else
+ ret = PyLong_FromLongLong(self->pos);
+#endif
cleanup:
return ret;