X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Ftdb2%2Ftransaction.c;h=604861b738e75e9c7efab447f7d26d19780a5ffc;hp=e7050bfe1ec96555ce6907d1a5c00e7441ca509a;hb=3835bb95d716cb6448913792b0d8d539877d93e9;hpb=7d6312518bd3a8e4cbad69b1f6b1800f7bcdf68c diff --git a/ccan/tdb2/transaction.c b/ccan/tdb2/transaction.c index e7050bfe..604861b7 100644 --- a/ccan/tdb2/transaction.c +++ b/ccan/tdb2/transaction.c @@ -642,8 +642,8 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, enum TDB_ERROR ecode; recovery_head = tdb_read_off(tdb, offsetof(struct tdb_header,recovery)); - if (recovery_head == TDB_OFF_ERR) { - tdb_logerr(tdb, tdb->ecode, TDB_LOG_ERROR, + if (TDB_OFF_IS_ERR(recovery_head)) { + tdb_logerr(tdb, recovery_head, TDB_LOG_ERROR, "tdb_recovery_allocate:" " failed to read recovery head"); return -1; @@ -681,9 +681,10 @@ static int tdb_recovery_allocate(struct tdb_context *tdb, the transaction) */ if (recovery_head != 0) { add_stat(tdb, frees, 1); - if (add_free_record(tdb, recovery_head, - sizeof(rec) + rec.max_len) != 0) { - tdb_logerr(tdb, tdb->ecode, TDB_LOG_ERROR, + ecode = add_free_record(tdb, recovery_head, + sizeof(rec) + rec.max_len); + if (ecode != TDB_SUCCESS) { + tdb_logerr(tdb, ecode, TDB_LOG_ERROR, "tdb_recovery_allocate:" " failed to free previous recovery area"); return -1; @@ -1108,8 +1109,8 @@ int tdb_transaction_recover(struct tdb_context *tdb) /* find the recovery area */ recovery_head = tdb_read_off(tdb, offsetof(struct tdb_header,recovery)); - if (recovery_head == TDB_OFF_ERR) { - tdb_logerr(tdb, tdb->ecode, TDB_LOG_ERROR, + if (TDB_OFF_IS_ERR(recovery_head)) { + tdb_logerr(tdb, recovery_head, TDB_LOG_ERROR, "tdb_transaction_recover:" " failed to read recovery head"); return -1; @@ -1241,7 +1242,8 @@ bool tdb_needs_recovery(struct tdb_context *tdb) /* find the recovery area */ recovery_head = tdb_read_off(tdb, offsetof(struct tdb_header,recovery)); - if (recovery_head == TDB_OFF_ERR) { + if (TDB_OFF_IS_ERR(recovery_head)) { + tdb->ecode = recovery_head; return true; }