From c0e6586405d2ceb8af9b4252ced83dea931ab8aa Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sat, 24 Sep 2005 02:37:22 +0000 Subject: r10460: fixed portability of transaction code to systems with integer alignment constraints (like sparc) (This used to be commit bce35ad237a55376b6af98416eec92a7c4b422a6) --- source4/lib/tdb/common/transaction.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) (limited to 'source4') diff --git a/source4/lib/tdb/common/transaction.c b/source4/lib/tdb/common/transaction.c index 75e91c56cc..5f281ca4da 100644 --- a/source4/lib/tdb/common/transaction.c +++ b/source4/lib/tdb/common/transaction.c @@ -628,7 +628,7 @@ static int transaction_setup_recovery(struct tdb_context *tdb, struct list_struct *rec; tdb_off_t recovery_offset, recovery_max_size; tdb_off_t old_map_size = tdb->transaction->old_map_size; - u32 magic; + u32 magic, tailer; /* check that the recovery area has enough space @@ -666,8 +666,8 @@ static int transaction_setup_recovery(struct tdb_context *tdb, tdb->ecode = TDB_ERR_CORRUPT; return -1; } - ((u32 *)p)[0] = el->offset; - ((u32 *)p)[1] = el->length; + memcpy(p, &el->offset, 4); + memcpy(p+4, &el->length, 4); if (DOCONV()) { tdb_convert(p, 8); } @@ -683,7 +683,8 @@ static int transaction_setup_recovery(struct tdb_context *tdb, } /* and the tailer */ - *(u32 *)p = sizeof(*rec) + recovery_max_size; + tailer = sizeof(*rec) + recovery_max_size; + memcpy(p, &tailer, 4); CONVERT(p); /* write the recovery data to the recovery area */ @@ -926,8 +927,8 @@ int tdb_transaction_recover(struct tdb_context *tdb) if (DOCONV()) { tdb_convert(p, 8); } - ofs = ((u32 *)p)[0]; - len = ((u32 *)p)[1]; + memcpy(&ofs, p, 4); + memcpy(&len, p+4, 4); if (tdb->methods->tdb_write(tdb, ofs, p+8, len) == -1) { free(data); -- cgit