]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
vfs_fake_acls: Reduce indentation in fake_acls_lstat()
authorVolker Lendecke <vl@samba.org>
Sat, 4 Oct 2025 16:32:55 +0000 (18:32 +0200)
committerRalph Boehme <slow@samba.org>
Fri, 10 Oct 2025 08:23:37 +0000 (08:23 +0000)
Use an early return

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_fake_acls.c

index de232203ff5773c34da814a7e7f147cdf30a75fb..bb1ed25cdff239ff572353ca91aad0ed912472fc 100644 (file)
@@ -189,6 +189,9 @@ static int fake_acls_lstat(vfs_handle_struct *handle,
 {
        int ret = -1;
        struct in_pathref_data *prd = NULL;
+       struct smb_filename *smb_fname_base = NULL;
+       SMB_STRUCT_STAT sbuf = {0};
+       NTSTATUS status;
 
        SMB_VFS_HANDLE_GET_DATA(handle,
                                prd,
@@ -196,55 +199,50 @@ static int fake_acls_lstat(vfs_handle_struct *handle,
                                return -1);
 
        ret = SMB_VFS_NEXT_LSTAT(handle, smb_fname);
-       if (ret == 0) {
-               struct smb_filename *smb_fname_base = NULL;
-               SMB_STRUCT_STAT sbuf = { 0 };
-               NTSTATUS status;
-
-               /*
-                * Ensure synthetic_pathref()
-                * can't recurse into fake_acls_lstat().
-                * synthetic_pathref() doesn't care
-                * about the uid/gid values, it only
-                * wants a valid/invalid stat answer
-                * and we know smb_fname exists as
-                * the SMB_VFS_NEXT_LSTAT() returned
-                * zero above.
-                */
-               if (prd->calling_pathref_fsp) {
-                       return 0;
-               }
+       if (ret != 0) {
+               return ret;
+       }
 
-               /* Recursion guard. */
-               prd->calling_pathref_fsp = true;
-               status = synthetic_pathref(talloc_tos(),
-                                          handle->conn->cwd_fsp,
-                                          smb_fname->base_name,
-                                          NULL,
-                                          &sbuf,
-                                          smb_fname->twrp,
-                                          0, /* we want stat, not lstat. */
-                                          &smb_fname_base);
-               /* End recursion guard. */
-               prd->calling_pathref_fsp = false;
-               if (NT_STATUS_IS_OK(status)) {
-                       /*
-                        * This isn't quite right (calling fgetxattr not
-                        * lgetxattr), but for the test purposes of this
-                        * module (fake NT ACLs from windows clients), it is
-                        * close enough.  We removed the l*xattr functions
-                        * because linux doesn't support using them, but we
-                        * could fake them in xattr_tdb if we really wanted
-                        * to. We ignore errors because the link might not
-                        * point anywhere */
-                       fake_acls_fuidgid(handle,
-                                         smb_fname_base->fsp,
-                                         &smb_fname->st.st_ex_uid,
-                                         &smb_fname->st.st_ex_gid);
-               }
-               TALLOC_FREE(smb_fname_base);
+       /*
+        * Ensure synthetic_pathref() can't recurse into
+        * fake_acls_lstat().  synthetic_pathref() doesn't care about
+        * the uid/gid values, it only wants a valid/invalid stat
+        * answer and we know smb_fname exists as the
+        * SMB_VFS_NEXT_LSTAT() returned zero above.
+        */
+       if (prd->calling_pathref_fsp) {
+               return 0;
        }
 
+       /* Recursion guard. */
+       prd->calling_pathref_fsp = true;
+       status = synthetic_pathref(talloc_tos(),
+                                  handle->conn->cwd_fsp,
+                                  smb_fname->base_name,
+                                  NULL,
+                                  &sbuf,
+                                  smb_fname->twrp,
+                                  0, /* we want stat, not lstat. */
+                                  &smb_fname_base);
+       /* End recursion guard. */
+       prd->calling_pathref_fsp = false;
+       if (NT_STATUS_IS_OK(status)) {
+               /*
+                * This isn't quite right (calling fgetxattr not
+                * lgetxattr), but for the test purposes of this
+                * module (fake NT ACLs from windows clients), it is
+                * close enough.  We removed the l*xattr functions
+                * because linux doesn't support using them, but we
+                * could fake them in xattr_tdb if we really wanted
+                * to. We ignore errors because the link might not
+                * point anywhere */
+               fake_acls_fuidgid(handle,
+                                 smb_fname_base->fsp,
+                                 &smb_fname->st.st_ex_uid,
+                                 &smb_fname->st.st_ex_gid);
+       }
+       TALLOC_FREE(smb_fname_base);
+
        return ret;
 }