diff options
author | Volker Lendecke <vl@samba.org> | 2014-06-29 11:31:18 +0200 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2014-06-30 22:28:15 +0200 |
commit | 2282128ed03d06b16c019d9f3294ca0ea46f029f (patch) | |
tree | ec82fe6d551b2600da5b70e11ef2d7bcacc3083d /source3/locking/brlock.c | |
parent | 3c2f4e328be51740ce67568fe886c5f5e745ed4f (diff) | |
download | samba-2282128ed03d06b16c019d9f3294ca0ea46f029f.tar.gz samba-2282128ed03d06b16c019d9f3294ca0ea46f029f.tar.xz samba-2282128ed03d06b16c019d9f3294ca0ea46f029f.zip |
smbd: Factor out brl_delete_lock_struct
memmove calculations are never nice, and this is going to be used in
validate_lock_entries soon :-)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/locking/brlock.c')
-rw-r--r-- | source3/locking/brlock.c | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/source3/locking/brlock.c b/source3/locking/brlock.c index eb305a55d4..ba26a99fed 100644 --- a/source3/locking/brlock.c +++ b/source3/locking/brlock.c @@ -999,6 +999,17 @@ NTSTATUS brl_lock(struct messaging_context *msg_ctx, return ret; } +static void brl_delete_lock_struct(struct lock_struct *locks, + unsigned num_locks, + unsigned del_idx) +{ + if (del_idx >= num_locks) { + return; + } + memmove(&locks[del_idx], &locks[del_idx+1], + sizeof(*locks) * (num_locks - del_idx - 1)); +} + /**************************************************************************** Unlock a range of bytes - Windows semantics. ****************************************************************************/ @@ -1066,12 +1077,7 @@ bool brl_unlock_windows_default(struct messaging_context *msg_ctx, unlock_continue: #endif - /* Actually delete the lock. */ - if (i < br_lck->num_locks - 1) { - memmove(&locks[i], &locks[i+1], - sizeof(*locks)*((br_lck->num_locks-1) - i)); - } - + brl_delete_lock_struct(locks, br_lck->num_locks, i); br_lck->num_locks -= 1; br_lck->modified = True; |