gmime r1249 - in trunk: . gmime



Author: fejj
Date: Sat May 24 02:23:27 2008
New Revision: 1249
URL: http://svn.gnome.org/viewvc/gmime?rev=1249&view=rev

Log:
2008-05-23  Jeffrey Stedfast  <fejj novell com>

	* gmime/gmime-stream-fs.c: Cast offset arguments to lseek() to
	off_t.

	* gmime/gmime-stream-file.c: Cast offset arguments to fseek() to
	long.

	* gmime/gmime-stream-mmap.c (g_mime_stream_mmap_new_with_bounds):
	Don't assign to st.st_size.



Modified:
   trunk/ChangeLog
   trunk/gmime/gmime-stream-file.c
   trunk/gmime/gmime-stream-fs.c
   trunk/gmime/gmime-stream-mmap.c

Modified: trunk/gmime/gmime-stream-file.c
==============================================================================
--- trunk/gmime/gmime-stream-file.c	(original)
+++ trunk/gmime/gmime-stream-file.c	Sat May 24 02:23:27 2008
@@ -138,7 +138,7 @@
 		len = MIN (stream->bound_end - stream->position, (gint64) len);
 	
 	/* make sure we are at the right position */
-	fseek (fstream->fp, stream->position, SEEK_SET);
+	fseek (fstream->fp, (long) stream->position, SEEK_SET);
 	
 	if ((nread = fread (buf, 1, len, fstream->fp)) > 0)
 		stream->position += nread;
@@ -159,7 +159,7 @@
 		len = MIN (stream->bound_end - stream->position, (gint64) len);
 	
 	/* make sure we are at the right position */
-	fseek (fstream->fp, stream->position, SEEK_SET);
+	fseek (fstream->fp, (long) stream->position, SEEK_SET);
 	
 	if ((nwritten = fwrite (buf, 1, len, fstream->fp)) > 0)
 		stream->position += nwritten;
@@ -216,7 +216,7 @@
 	if (stream->position == stream->bound_start)
 		return 0;
 	
-	if (fseek (fstream->fp, stream->bound_start, SEEK_SET) == -1)
+	if (fseek (fstream->fp, (long) stream->bound_start, SEEK_SET) == -1)
 		return -1;
 	
 	return 0;
@@ -244,7 +244,7 @@
 			 * we either don't know the offset of the end
 			 * of the stream and/or don't know if we can
 			 * seek past the end */
-			if (fseek (fp, offset, SEEK_END) == -1 || (real = ftell (fp)) == -1)
+			if (fseek (fp, (long) offset, SEEK_END) == -1 || (real = ftell (fp)) == -1)
 				return -1;
 		} else if (feof (fp) && stream->bound_end == -1) {
 			/* seeking backwards from eos (which happens
@@ -264,7 +264,7 @@
 	if (stream->bound_end != -1 && real > stream->bound_end)
 		return -1;
 	
-	if (fseek (fp, real, SEEK_SET) == -1 || (real = ftell (fp)) == -1)
+	if (fseek (fp, (long) real, SEEK_SET) == -1 || (real = ftell (fp)) == -1)
 		return -1;
 	
 	stream->position = real;
@@ -287,9 +287,9 @@
 	if (stream->bound_start != -1 && stream->bound_end != -1)
 		return stream->bound_end - stream->bound_start;
 	
-	fseek (fstream->fp, 0, SEEK_END);
+	fseek (fstream->fp, (long) 0, SEEK_END);
 	bound_end = ftell (fstream->fp);
-	fseek (fstream->fp, stream->position, SEEK_SET);
+	fseek (fstream->fp, (long) stream->position, SEEK_SET);
 	
 	if (bound_end < stream->bound_start)
 		return -1;

Modified: trunk/gmime/gmime-stream-fs.c
==============================================================================
--- trunk/gmime/gmime-stream-fs.c	(original)
+++ trunk/gmime/gmime-stream-fs.c	Sat May 24 02:23:27 2008
@@ -145,7 +145,7 @@
 		len = MIN (stream->bound_end - stream->position, (gint64) len);
 	
 	/* make sure we are at the right position */
-	lseek (fs->fd, stream->position, SEEK_SET);
+	lseek (fs->fd, (off_t) stream->position, SEEK_SET);
 	
 	do {
 		nread = read (fs->fd, buf, len);
@@ -173,7 +173,7 @@
 		len = MIN (stream->bound_end - stream->position, (gint64) len);
 	
 	/* make sure we are at the right position */
-	lseek (fs->fd, stream->position, SEEK_SET);
+	lseek (fs->fd, (off_t) stream->position, SEEK_SET);
 	
 	do {
 		do {
@@ -248,7 +248,7 @@
 	/* FIXME: if stream_read/write is always going to lseek to
 	 * make sure fd's seek position matches our own, we could just
 	 * set stream->position = stream->bound_start and be done. */
-	if (lseek (fs->fd, stream->bound_start, SEEK_SET) == -1)
+	if (lseek (fs->fd, (off_t) stream->bound_start, SEEK_SET) == -1)
 		return -1;
 	
 	fs->eos = FALSE;
@@ -277,7 +277,7 @@
 			 * we either don't know the offset of the end
 			 * of the stream and/or don't know if we can
 			 * seek past the end */
-			if ((real = lseek (fs->fd, offset, SEEK_END)) == -1)
+			if ((real = lseek (fs->fd, (off_t) offset, SEEK_END)) == -1)
 				return -1;
 		} else if (fs->eos && stream->bound_end == -1) {
 			/* seeking backwards from eos (which happens
@@ -305,7 +305,7 @@
 	if (stream->bound_end != -1 && real > stream->bound_end)
 		return -1;
 	
-	if ((real = lseek (fs->fd, real, SEEK_SET)) == -1)
+	if ((real = lseek (fs->fd, (off_t) real, SEEK_SET)) == -1)
 		return -1;
 	
 	/* reset eos if appropriate */
@@ -333,8 +333,8 @@
 	if (stream->bound_end != -1)
 		return stream->bound_end - stream->bound_start;
 	
-	bound_end = lseek (fs->fd, 0, SEEK_END);
-	lseek (fs->fd, stream->position, SEEK_SET);
+	bound_end = lseek (fs->fd, (off_t) 0, SEEK_END);
+	lseek (fs->fd, (off_t) stream->position, SEEK_SET);
 	
 	if (bound_end < stream->bound_start)
 		return -1;
@@ -371,7 +371,7 @@
 	GMimeStreamFs *fs;
 	gint64 start;
 	
-	if ((start = lseek (fd, 0, SEEK_CUR)) == -1)
+	if ((start = lseek (fd, (off_t) 0, SEEK_CUR)) == -1)
 		start = 0;
 	
 	fs = g_object_new (GMIME_TYPE_STREAM_FS, NULL);

Modified: trunk/gmime/gmime-stream-mmap.c
==============================================================================
--- trunk/gmime/gmime-stream-mmap.c	(original)
+++ trunk/gmime/gmime-stream-mmap.c	Sat May 24 02:23:27 2008
@@ -344,7 +344,7 @@
  * @prot: protection flags
  * @flags: map flags
  *
- * Creates a new GMimeStreamMmap object around @fd.
+ * Creates a new #GMimeStreamMmap object around @fd.
  *
  * Returns a stream using @fd.
  **/
@@ -392,7 +392,7 @@
  * @start: start boundary
  * @end: end boundary
  *
- * Creates a new GMimeStreamMmap object around @fd with bounds @start
+ * Creates a new #GMimeStreamMmap object around @fd with bounds @start
  * and @end.
  *
  * Returns a stream using @fd with bounds @start and @end.
@@ -403,16 +403,18 @@
 #ifdef HAVE_MMAP
 	GMimeStreamMmap *mstream;
 	struct stat st;
+	size_t len;
 	char *map;
 	
 	if (end == -1) {
 		if (fstat (fd, &st) == -1)
 			return NULL;
+		
+		len = st.st_size;
 	} else
-		st.st_size = end /* - start */;
+		len = (size_t) end;
 	
-	map = mmap (NULL, st.st_size, prot, flags, fd, 0);
-	if (map == MAP_FAILED)
+	if ((map = mmap (NULL, len, prot, flags, fd, 0)) == MAP_FAILED)
 		return NULL;
 	
 	mstream = g_object_new (GMIME_TYPE_STREAM_MMAP, NULL);
@@ -420,7 +422,7 @@
 	mstream->eos = FALSE;
 	mstream->fd = fd;
 	mstream->map = map;
-	mstream->maplen = st.st_size;
+	mstream->maplen = len;
 	
 	g_mime_stream_construct (GMIME_STREAM (mstream), start, end);
 	



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]