From 60c2953a9d5fa12494a8a767c30913398affe453 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 9 Apr 2013 21:07:23 +0200 Subject: vfs_fake_perms: Slightly streamline code Do an early error return Signed-off-by: Volker Lendecke Reviewed-by: Jeremy Allison --- source3/modules/vfs_fake_perms.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) (limited to 'source3') diff --git a/source3/modules/vfs_fake_perms.c b/source3/modules/vfs_fake_perms.c index 4cda7ea160..a447f311c3 100644 --- a/source3/modules/vfs_fake_perms.c +++ b/source3/modules/vfs_fake_perms.c @@ -35,16 +35,18 @@ static int fake_perms_stat(vfs_handle_struct *handle, int ret = -1; ret = SMB_VFS_NEXT_STAT(handle, smb_fname); - if (ret == 0) { - if (S_ISDIR(smb_fname->st.st_ex_mode)) { - smb_fname->st.st_ex_mode = S_IFDIR | S_IRWXU; - } else { - smb_fname->st.st_ex_mode = S_IRWXU; - } - smb_fname->st.st_ex_uid = handle->conn->session_info->unix_token->uid; - smb_fname->st.st_ex_gid = handle->conn->session_info->unix_token->gid; + if (ret != 0) { + return ret; } + if (S_ISDIR(smb_fname->st.st_ex_mode)) { + smb_fname->st.st_ex_mode = S_IFDIR | S_IRWXU; + } else { + smb_fname->st.st_ex_mode = S_IRWXU; + } + smb_fname->st.st_ex_uid = handle->conn->session_info->unix_token->uid; + smb_fname->st.st_ex_gid = handle->conn->session_info->unix_token->gid; + return ret; } @@ -53,15 +55,18 @@ static int fake_perms_fstat(vfs_handle_struct *handle, files_struct *fsp, SMB_ST int ret = -1; ret = SMB_VFS_NEXT_FSTAT(handle, fsp, sbuf); - if (ret == 0) { - if (S_ISDIR(sbuf->st_ex_mode)) { - sbuf->st_ex_mode = S_IFDIR | S_IRWXU; - } else { - sbuf->st_ex_mode = S_IRWXU; - } - sbuf->st_ex_uid = handle->conn->session_info->unix_token->uid; - sbuf->st_ex_gid = handle->conn->session_info->unix_token->gid; + if (ret != 0) { + return ret; } + + if (S_ISDIR(sbuf->st_ex_mode)) { + sbuf->st_ex_mode = S_IFDIR | S_IRWXU; + } else { + sbuf->st_ex_mode = S_IRWXU; + } + sbuf->st_ex_uid = handle->conn->session_info->unix_token->uid; + sbuf->st_ex_gid = handle->conn->session_info->unix_token->gid; + return ret; } -- cgit