]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Simplify is_visible_fsp()
authorVolker Lendecke <vl@samba.org>
Wed, 7 Dec 2022 09:49:47 +0000 (10:49 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 12 Dec 2022 21:16:33 +0000 (21:16 +0000)
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 <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/dir.c

index 96885f89d9efc2fa3e65f684f04fe4f214b9fecf..eb263132adf7f2cbb1cafb0bb4c3d047c5e67201 100644 (file)
@@ -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;
                }
        }