[Python-checkins] python/dist/src/Modules bz2module.c, 1.23.2.2, 1.23.2.3

birkenfeld@users.sourceforge.net birkenfeld at users.sourceforge.net
Sat Sep 3 09:49:59 CEST 2005


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6193/Modules
Modified Files:
 Tag: release24-maint
	bz2module.c 
Log Message:
bug [ 1274069 ] bz2module.c compiler warning
Index: bz2module.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/bz2module.c,v
retrieving revision 1.23.2.2
retrieving revision 1.23.2.3
diff -u -d -r1.23.2.2 -r1.23.2.3
--- bz2module.c	25 Aug 2005 13:10:58 -0000	1.23.2.2
+++ bz2module.c	3 Sep 2005 07:49:48 -0000	1.23.2.3
@@ -110,8 +110,8 @@
 
 	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 @@
 	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 @@
 	/* 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 @@
 		goto cleanup;
 	}
 
+#if !defined(HAVE_LARGEFILE_SUPPORT)
 	ret = PyInt_FromLong(self->pos);
+#else
+	ret = PyLong_FromLongLong(self->pos);
+#endif
 
 cleanup:
 	return ret;


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /