summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2012-12-13 21:58:00 +0100
committerStefan Metzmacher <metze@samba.org>2012-12-21 11:55:15 +0100
commit0f4e7a1401998746a6818b9469ab369d70418ac1 (patch)
tree2f8735779b98173cc622de4dbcb52f8d5bec45ac /lib
parent116ec13bb0718eb1de1ac1f4410d5c33f1db616f (diff)
downloadsamba-0f4e7a1401998746a6818b9469ab369d70418ac1.tar.gz
samba-0f4e7a1401998746a6818b9469ab369d70418ac1.tar.bz2
samba-0f4e7a1401998746a6818b9469ab369d70418ac1.zip
tdb: Slightly simplify tdb_lock_list
Avoid an else {} branch when we can do an early return Reviewed-by: Rusty Russell <rusty@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/tdb/common/lock.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/lib/tdb/common/lock.c b/lib/tdb/common/lock.c
index 74ead7be05..333af1bebb 100644
--- a/lib/tdb/common/lock.c
+++ b/lib/tdb/common/lock.c
@@ -348,20 +348,20 @@ static int tdb_lock_list(struct tdb_context *tdb, int list, int ltype,
if (tdb->allrecord_lock.count) {
tdb->ecode = TDB_ERR_LOCK;
- ret = -1;
- } else {
- /* Only check when we grab first data lock. */
- check = !have_data_locks(tdb);
- ret = tdb_nest_lock(tdb, lock_offset(list), ltype, waitflag);
+ return -1;
+ }
- if (ret == 0 && check && tdb_needs_recovery(tdb)) {
- tdb_nest_unlock(tdb, lock_offset(list), ltype, false);
+ /* Only check when we grab first data lock. */
+ check = !have_data_locks(tdb);
+ ret = tdb_nest_lock(tdb, lock_offset(list), ltype, waitflag);
- if (tdb_lock_and_recover(tdb) == -1) {
- return -1;
- }
- return tdb_lock_list(tdb, list, ltype, waitflag);
+ if (ret == 0 && check && tdb_needs_recovery(tdb)) {
+ tdb_nest_unlock(tdb, lock_offset(list), ltype, false);
+
+ if (tdb_lock_and_recover(tdb) == -1) {
+ return -1;
}
+ return tdb_lock_list(tdb, list, ltype, waitflag);
}
return ret;
}