From 3c2f4e328be51740ce67568fe886c5f5e745ed4f Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Sun, 29 Jun 2014 11:22:13 +0200 Subject: [PATCH] smbd: Simplify validate_lock_entries ... saves >100 bytes object code :-) Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/locking/brlock.c | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index e0e042d91b0..eb305a55d43 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -1711,45 +1711,46 @@ static bool validate_lock_entries(TALLOC_CTX *mem_ctx, unsigned int i; unsigned int num_valid_entries = 0; struct lock_struct *locks = *pplocks; + unsigned int num_entries = *pnum_entries; TALLOC_CTX *frame; struct server_id *ids; bool *exists; - if (*pnum_entries == 0) { + if (num_entries == 0) { return true; } frame = talloc_stackframe(); - ids = talloc_array(frame, struct server_id, *pnum_entries); + ids = talloc_array(frame, struct server_id, num_entries); if (ids == NULL) { DEBUG(0, ("validate_lock_entries: " "talloc_array(struct server_id, %u) failed\n", - *pnum_entries)); + num_entries)); talloc_free(frame); return false; } - exists = talloc_array(frame, bool, *pnum_entries); + exists = talloc_array(frame, bool, num_entries); if (exists == NULL) { DEBUG(0, ("validate_lock_entries: " "talloc_array(bool, %u) failed\n", - *pnum_entries)); + num_entries)); talloc_free(frame); return false; } - for (i = 0; i < *pnum_entries; i++) { + for (i = 0; i < num_entries; i++) { ids[i] = locks[i].context.pid; } - if (!serverids_exist(ids, *pnum_entries, exists)) { + if (!serverids_exist(ids, num_entries, exists)) { DEBUG(3, ("validate_lock_entries: serverids_exists failed\n")); talloc_free(frame); return false; } - for (i = 0; i < *pnum_entries; i++) { + for (i = 0; i < num_entries; i++) { if (exists[i]) { num_valid_entries++; continue; @@ -1768,7 +1769,7 @@ static bool validate_lock_entries(TALLOC_CTX *mem_ctx, } TALLOC_FREE(frame); - if (num_valid_entries != *pnum_entries) { + if (num_valid_entries != num_entries) { struct lock_struct *new_lock_data = NULL; if (num_valid_entries) { @@ -1781,7 +1782,7 @@ static bool validate_lock_entries(TALLOC_CTX *mem_ctx, } num_valid_entries = 0; - for (i = 0; i < *pnum_entries; i++) { + for (i = 0; i < num_entries; i++) { struct lock_struct *lock_data = &locks[i]; if (lock_data->context.smblctx && lock_data->context.tid) { -- 2.11.4.GIT