]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Remove a few unnecessary NULL checks
authorVolker Lendecke <vl@samba.org>
Sat, 13 Sep 2025 09:47:42 +0000 (11:47 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 21 Oct 2025 17:33:29 +0000 (17:33 +0000)
These functions are only called from smbd_do_setfilepathinfo() which
has checked with SMB_ASSERT(fsp != NULL).

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

index 1d0580c0283dacea32f4d46b86040f1e11df7b3c..6f4888124635a28627b7cf547bf641aeabf17ed2 100644 (file)
@@ -4084,19 +4084,6 @@ static NTSTATUS smb_info_set_ea(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (fsp == NULL) {
-               /*
-                * The only way fsp can be NULL here is if
-                * smb_fname points at a symlink and
-                * and we're in POSIX context.
-                * Ensure this is the case.
-                *
-                * In this case we cannot set the EA.
-                */
-               SMB_ASSERT(smb_fname->flags & SMB_FILENAME_POSIX_PATH);
-               return NT_STATUS_ACCESS_DENIED;
-       }
-
        status = set_ea(conn, fsp, ea_list);
 
        return status;
@@ -4114,10 +4101,6 @@ static NTSTATUS smb_set_file_full_ea_info(connection_struct *conn,
        struct ea_list *ea_list = NULL;
        NTSTATUS status;
 
-       if (fsp == NULL) {
-               return NT_STATUS_INVALID_HANDLE;
-       }
-
        if (!lp_ea_support(SNUM(conn))) {
                DEBUG(10, ("smb_set_file_full_ea_info - ea_len = %u but "
                        "EA's not supported.\n",
@@ -4684,7 +4667,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                return NT_STATUS_NOT_SUPPORTED;
        }
 
-       if (fsp && fsp->base_fsp) {
+       if (fsp->base_fsp) {
                /* newname must be a stream name. */
                if (newname[0] != ':') {
                        return NT_STATUS_NOT_SUPPORTED;
@@ -4783,7 +4766,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                }
        }
 
-       if (fsp != NULL && fsp->fsp_flags.is_fsa) {
+       if (fsp->fsp_flags.is_fsa) {
                DBG_DEBUG("SMB_FILE_RENAME_INFORMATION (%s) %s -> %s\n",
                          fsp_fnum_dbg(fsp),
                          fsp_str_dbg(fsp),
@@ -4846,10 +4829,6 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn,
                return NT_STATUS_INVALID_PARAMETER;
        }
 
-       if (fsp == NULL) {
-               return NT_STATUS_INVALID_HANDLE;
-       }
-
        status = check_any_access_fsp(fsp, FILE_WRITE_ATTRIBUTES);
        if (!NT_STATUS_IS_OK(status)) {
                return status;