Thu Mar 10 03:42:49 ART 2005  Alberto Bertogli (albertogli@telpin.com.ar)
  * Fix some datatypes to avoid overflows and losses.
diff -rN -u old-libjio/ansi.c new-libjio/ansi.c
--- old-libjio/ansi.c	2005-03-10 15:15:11.590705478 -0300
+++ new-libjio/ansi.c	2005-03-10 03:40:38.000000000 -0300
@@ -175,7 +175,7 @@
 /* fseek wrapper */
 int jfseek(struct jfs *stream, long offset, int whence)
 {
-	long pos;
+	off_t pos;
 
 	pthread_mutex_lock(&(stream->lock));
 	pos = lseek(stream->fd, offset, whence);
@@ -189,9 +189,10 @@
 }
 
 /* ftell wrapper */
-int jftell(struct jfs *stream)
+long jftell(struct jfs *stream)
 {
-	return lseek(stream->fd, 0, SEEK_CUR);
+	/* forced conversion to long to meet the prototype */
+	return (long) lseek(stream->fd, 0, SEEK_CUR);
 }
 
 /* rewind wrapper */
diff -rN -u old-libjio/check.c new-libjio/check.c
--- old-libjio/check.c	2005-03-10 15:15:11.590705478 -0300
+++ new-libjio/check.c	2005-03-10 03:37:20.000000000 -0300
@@ -106,7 +106,7 @@
 	DIR *dir;
 	struct dirent *dent;
 	unsigned char *map;
-	off_t filelen;
+	off_t filelen, lr;
 
 	tfd = -1;
 	filelen = 0;
@@ -239,13 +239,15 @@
 
 		/* try to lock the transaction file, if it's locked then it is
 		 * currently being used so we skip it */
-		rv = plockf(tfd, F_TLOCKW, 0, 0);
-		if (rv == -1) {
+		lr = plockf(tfd, F_TLOCKW, 0, 0);
+		if (lr == -1) {
 			res->in_progress++;
 			goto loop;
 		}
 
 		filelen = lseek(tfd, 0, SEEK_END);
+		/* no overflow problems because we know the transaction size
+		 * is limited to SSIZE_MAX */
 		map = mmap(0, filelen, PROT_READ, MAP_SHARED, tfd, 0);
 		if (map == MAP_FAILED) {
 			res->broken++;
diff -rN -u old-libjio/jiofsck.c new-libjio/jiofsck.c
--- old-libjio/jiofsck.c	2005-03-10 15:15:11.589705585 -0300
+++ new-libjio/jiofsck.c	2005-03-10 03:40:59.000000000 -0300
@@ -9,7 +9,7 @@
 #include "libjio.h"
 
 
-void usage()
+static void usage()
 {
 	printf("\
 Use: jiofsck [clean=1] [dir=DIR] FILE\n\
diff -rN -u old-libjio/libjio.h new-libjio/libjio.h
--- old-libjio/libjio.h	2005-03-10 15:15:11.588705692 -0300
+++ new-libjio/libjio.h	2005-03-10 03:40:09.000000000 -0300
@@ -141,7 +141,7 @@
 void jclearerr(struct jfs *stream);
 int jferror(struct jfs *stream);
 int jfseek(struct jfs *stream, long offset, int whence);
-int jftell(struct jfs *stream);
+long jftell(struct jfs *stream);
 void jrewind(struct jfs *stream);
 FILE *jfsopen(struct jfs *stream, const char *mode);
 
diff -rN -u old-libjio/trans.c new-libjio/trans.c
--- old-libjio/trans.c	2005-03-10 15:15:11.586705907 -0300
+++ new-libjio/trans.c	2005-03-10 03:34:11.000000000 -0300
@@ -278,9 +278,10 @@
 	 * same spots and we could end up with interleaved writes, that could
 	 * break atomicity warantees if we need to rollback */
 	if (!(ts->flags & J_NOLOCK)) {
+		off_t lr;
 		for (op = ts->op; op != NULL; op = op->next) {
-			rv = plockf(ts->fs->fd, F_LOCKW, op->offset, op->len);
-			if (rv == -1)
+			lr = plockf(ts->fs->fd, F_LOCKW, op->offset, op->len);
+			if (lr == -1)
 				/* note it can fail with EDEADLK */
 				goto unlink_exit;
 			op->locked = 1;
@@ -345,7 +346,8 @@
 		curpos += op->len;
 	}
 
-	/* compute and save the checksum */
+	/* compute and save the checksum (curpos is always small, so there's
+	 * no overflow possibility when we convert to size_t) */
 	if (!checksum(fd, curpos, &csum))
 		goto unlink_exit;
 


