diff options
author | Volker Lendecke <vl@samba.org> | 2013-10-15 10:01:54 +0000 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2013-10-15 23:44:37 +0200 |
commit | 4d85f91a5b309fac76ed8b0ed2a18132c18b2659 (patch) | |
tree | 87c2df00ca8b979fe6afbda6cbae2fe46badd1f4 | |
parent | 0f71730d1bd1e60b439a45e56d5e68423706c897 (diff) | |
download | samba-4d85f91a5b309fac76ed8b0ed2a18132c18b2659.tar.gz samba-4d85f91a5b309fac76ed8b0ed2a18132c18b2659.tar.bz2 samba-4d85f91a5b309fac76ed8b0ed2a18132c18b2659.zip |
smbd: Make find_oplock_types return bool
smb_panic() does not take a printf style argument. This improves debug
output by easily printing the index that we fell over. Also, doing
smb_panic deep down is bad style IMHO.
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
-rw-r--r-- | source3/smbd/open.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 9c8b31d080..a893c59b9e 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -1209,7 +1209,7 @@ static NTSTATUS send_break_message(files_struct *fsp, * Do internal consistency checks on the share mode for a file. */ -static void find_oplock_types(files_struct *fsp, +static bool find_oplock_types(files_struct *fsp, int oplock_request, const struct share_mode_lock *lck, struct share_mode_entry **pp_batch, @@ -1230,7 +1230,7 @@ static void find_oplock_types(files_struct *fsp, delay_for_exclusive_oplocks(). */ if ((oplock_request & INTERNAL_OPEN_ONLY) || is_stat_open(fsp->access_mask)) { - return; + return true; } for (i=0; i<d->num_share_modes; i++) { @@ -1254,7 +1254,9 @@ static void find_oplock_types(files_struct *fsp, continue; } if (*pp_ex_or_batch || *pp_batch || *got_level2 || *got_no_oplock) { - smb_panic("Bad batch oplock entry."); + DEBUG(0, ("Bad batch oplock entry %u.", + (unsigned)i)); + return false; } *pp_batch = e; } @@ -1266,7 +1268,9 @@ static void find_oplock_types(files_struct *fsp, } /* Exclusive or batch - can only be one. */ if (*pp_ex_or_batch || *got_level2 || *got_no_oplock) { - smb_panic("Bad exclusive or batch oplock entry."); + DEBUG(0, ("Bad exclusive or batch oplock " + "entry %u.", (unsigned)i)); + return false; } *pp_ex_or_batch = e; } @@ -1278,7 +1282,9 @@ static void find_oplock_types(files_struct *fsp, "oplock\n")); continue; } - smb_panic("Bad levelII oplock entry."); + DEBUG(0, ("Bad levelII oplock entry %u.", + (unsigned)i)); + return false; } *got_level2 = true; } @@ -1290,11 +1296,14 @@ static void find_oplock_types(files_struct *fsp, "entry\n")); continue; } - smb_panic("Bad no oplock entry."); + DEBUG(0, ("Bad no oplock entry %u.", + (unsigned)i)); + return false; } *got_no_oplock = true; } } + return true; } static bool delay_for_oplock(files_struct *fsp, @@ -2284,8 +2293,12 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, return NT_STATUS_SHARING_VIOLATION; } - find_oplock_types(fsp, 0, lck, &batch_entry, &exclusive_entry, - &got_level2_oplock, &got_a_none_oplock); + if (!find_oplock_types(fsp, 0, lck, + &batch_entry, &exclusive_entry, + &got_level2_oplock, + &got_a_none_oplock)) { + smb_panic("find_oplock_types failed"); + } if (delay_for_oplock(fsp, req->mid, 0, batch_entry) || delay_for_oplock(fsp, req->mid, 0, exclusive_entry)) { @@ -2372,13 +2385,12 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn, } /* Get the types we need to examine. */ - find_oplock_types(fsp, - oplock_request, - lck, - &batch_entry, - &exclusive_entry, - &got_level2_oplock, - &got_a_none_oplock); + if (!find_oplock_types(fsp, oplock_request, lck, + &batch_entry, &exclusive_entry, + &got_level2_oplock, + &got_a_none_oplock)) { + smb_panic("find_oplock_types failed"); + } if (has_delete_on_close(lck, fsp->name_hash)) { TALLOC_FREE(lck); |