From: Volker Lendecke Date: Wed, 7 Dec 2022 09:49:47 +0000 (+0100) Subject: smbd: Simplify is_visible_fsp() X-Git-Tag: talloc-2.4.0~357 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f30f5dd24537bc6bb252a141d4f0b6773302335f;p=thirdparty%2Fsamba.git smbd: Simplify is_visible_fsp() We don't need the wrapping if-statement, we check for the individual flags. The compiler should be smart enough so that this is not a difference in execution speed. Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/dir.c b/source3/smbd/dir.c index 96885f89d9e..eb263132adf 100644 --- a/source3/smbd/dir.c +++ b/source3/smbd/dir.c @@ -1423,42 +1423,30 @@ bool is_visible_fsp(struct files_struct *fsp) return true; } - if (hide_unreadable || - hide_unwriteable || - hide_special || - (hide_new_files_timeout != 0)) - { - /* Honour _hide unreadable_ option */ - if (hide_unreadable && - !user_can_read_fsp(fsp)) - { - DBG_DEBUG("file %s is unreadable.\n", - fsp_str_dbg(fsp)); - return false; - } - /* Honour _hide unwriteable_ option */ - if (hide_unwriteable && - !user_can_write_fsp(fsp)) - { - DBG_DEBUG("file %s is unwritable.\n", - fsp_str_dbg(fsp)); - return false; - } - /* Honour _hide_special_ option */ - if (hide_special && file_is_special(fsp->conn, fsp->fsp_name)) { - DBG_DEBUG("file %s is special.\n", - fsp_str_dbg(fsp)); - return false; - } + /* Honour _hide unreadable_ option */ + if (hide_unreadable && !user_can_read_fsp(fsp)) { + DBG_DEBUG("file %s is unreadable.\n", fsp_str_dbg(fsp)); + return false; + } - if ((hide_new_files_timeout != 0) && - !S_ISDIR(fsp->fsp_name->st.st_ex_mode)) { - double age = timespec_elapsed( - &fsp->fsp_name->st.st_ex_mtime); + /* Honour _hide unwriteable_ option */ + if (hide_unwriteable && !user_can_write_fsp(fsp)) { + DBG_DEBUG("file %s is unwritable.\n", fsp_str_dbg(fsp)); + return false; + } - if (age < (double)hide_new_files_timeout) { - return false; - } + /* Honour _hide_special_ option */ + if (hide_special && file_is_special(fsp->conn, fsp->fsp_name)) { + DBG_DEBUG("file %s is special.\n", fsp_str_dbg(fsp)); + return false; + } + + if ((hide_new_files_timeout != 0) && + !S_ISDIR(fsp->fsp_name->st.st_ex_mode)) { + double age = timespec_elapsed(&fsp->fsp_name->st.st_ex_mtime); + + if (age < (double)hide_new_files_timeout) { + return false; } }