git » libjio » commit afede6e

Fix transaction lenght checking.

author Alberto Bertogli
2005-03-10 06:29:40 UTC
committer Alberto Bertogli
2007-07-15 13:49:00 UTC
parent bc045cb06187302205adc29c156c564ff846c649

Fix transaction lenght checking.

If we don't cast to a bigger value, there is no way the check can be positive.
Also, initialize the lenght to 0.

Signed-off-by: Alberto Bertogli <albertito@gmail.com>

trans.c +2 -1

diff --git a/trans.c b/trans.c
index 0132f19..a09ff85 100644
--- a/trans.c
+++ b/trans.c
@@ -102,6 +102,7 @@ void jtrans_init(struct jfs *fs, struct jtrans *ts)
 	ts->flags = fs->flags;
 	ts->op = NULL;
 	ts->numops = 0;
+	ts->len = 0;
 	pthread_mutexattr_init(&attr);
 	pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
 	pthread_mutex_init( &(ts->lock), &attr);
@@ -146,7 +147,7 @@ int jtrans_add(struct jtrans *ts, const void *buf, size_t count, off_t offset)
 		return 0;
 	}
 
-	if (ts->len + count > MAX_TSIZE) {
+	if ((long long) ts->len + count > MAX_TSIZE) {
 		pthread_mutex_unlock(&(ts->lock));
 		return 0;
 	}