

When we create the transaction file's header, we use sizeof() in memcpy and
explicit sizes in the pointer arithmetic. As the sizes are not type-dependant
but really fixed, defined in the on-disk format, this patch makes it more
coherent by using the explicit sizes everywhere.



---

 cur-root/trans.c |   14 ++++++++------
 1 files changed, 8 insertions(+), 6 deletions(-)

diff -puN trans.c~sizeof_in_arith trans.c
--- cur/trans.c~sizeof_in_arith	2004-06-05 14:25:43.405436712 -0300
+++ cur-root/trans.c	2004-06-05 14:29:56.127017192 -0300
@@ -240,22 +240,24 @@ int jtrans_commit(struct jtrans *ts)
 
 	bufp = buf_init;
 
-	memcpy(bufp, (void *) &(ts->id), sizeof(ts->id));
+	/* the sizes are put explicitly (instead of using sizeof()) because
+	 * they're really fixed and defined in the on-disk format */
+	memcpy(bufp, (void *) &(ts->id), 4);
 	bufp += 4;
 
-	memcpy(bufp, (void *) &(ts->flags), sizeof(ts->flags));
+	memcpy(bufp, (void *) &(ts->flags), 4);
 	bufp += 4;
 
-	memcpy(bufp, (void *) &(ts->len), sizeof(ts->len));
+	memcpy(bufp, (void *) &(ts->len), 4);
 	bufp += 4;
 
-	memcpy(bufp, (void *) &(ts->plen), sizeof(ts->plen));
+	memcpy(bufp, (void *) &(ts->plen), 4);
 	bufp += 4;
 
-	memcpy(bufp, (void *) &(ts->ulen), sizeof(ts->ulen));
+	memcpy(bufp, (void *) &(ts->ulen), 4);
 	bufp += 4;
 
-	memcpy(bufp, (void *) &(ts->offset), sizeof(ts->offset));
+	memcpy(bufp, (void *) &(ts->offset), 8);
 	bufp += 8;
 
 	rv = spwrite(fd, buf_init, J_DISKTFIXSIZE, 0);

_
