From: Volker Lendecke Date: Sat, 31 Jan 2026 10:59:34 +0000 (+0100) Subject: smbd: Save a few lines with direct smb_file_time initialization X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1b5d10db647f9b1f7f1bc16b89a522101554233f;p=thirdparty%2Fsamba.git smbd: Save a few lines with direct smb_file_time initialization Signed-off-by: Volker Lendecke Reviewed-by: Anoop C S --- diff --git a/source3/modules/vfs_recycle.c b/source3/modules/vfs_recycle.c index bfea7ef75f4..15356b8fc0f 100644 --- a/source3/modules/vfs_recycle.c +++ b/source3/modules/vfs_recycle.c @@ -425,12 +425,10 @@ static void recycle_do_touch(vfs_handle_struct *handle, bool touch_mtime) { struct smb_filename *smb_fname_tmp = NULL; - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); int ret, err; NTSTATUS status; - init_smb_file_time(&ft); - status = synthetic_pathref(talloc_tos(), handle->conn->cwd_fsp, smb_fname->base_name, diff --git a/source3/smbd/close.c b/source3/smbd/close.c index 31daea801cf..3ce7403c52d 100644 --- a/source3/smbd/close.c +++ b/source3/smbd/close.c @@ -732,11 +732,9 @@ void set_close_write_time(struct files_struct *fsp, struct timespec ts) */ static NTSTATUS update_write_time_on_close(struct files_struct *fsp) { - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); NTSTATUS status; - init_smb_file_time(&ft); - if (is_omit_timespec(&fsp->close_write_time)) { return NT_STATUS_OK; } diff --git a/source3/smbd/fileio.c b/source3/smbd/fileio.c index 80c621000ff..9c46fff6003 100644 --- a/source3/smbd/fileio.c +++ b/source3/smbd/fileio.c @@ -126,9 +126,7 @@ void trigger_write_time_update_immediate(struct files_struct *fsp, bool update_mtime, bool update_ctime) { - struct smb_file_time ft; - - init_smb_file_time(&ft); + struct smb_file_time ft = smb_file_time_omit(); if (fsp->fsp_flags.posix_open) { return; @@ -200,9 +198,8 @@ void mark_file_modified(files_struct *fsp, if (fsp->fsp_flags.write_time_forced && modified_state->valid) { - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); - init_smb_file_time(&ft); ft.mtime = modified_state->st.st_ex_mtime; /* diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index 7e34cd4443e..4c97c3a2b0b 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1202,7 +1202,7 @@ NTSTATUS vfs_fstreaminfo(struct files_struct *fsp, TALLOC_CTX *mem_ctx, unsigned int *num_streams, struct stream_struct **streams); -void init_smb_file_time(struct smb_file_time *ft); +struct smb_file_time smb_file_time_omit(void); int vfs_fake_fd(void); int vfs_fake_fd_close(int fd); uint32_t vfs_get_fs_capabilities(struct connection_struct *conn, diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index a84ccb032c9..c651a07bd83 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -872,7 +872,7 @@ void reply_getatr(struct smb_request *req) void reply_setatr(struct smb_request *req) { - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); connection_struct *conn = req->conn; struct smb_filename *smb_fname = NULL; struct files_struct *dirfsp = NULL; @@ -886,7 +886,6 @@ void reply_setatr(struct smb_request *req) TALLOC_CTX *ctx = talloc_tos(); START_PROFILE(SMBsetatr); - init_smb_file_time(&ft); if (req->wct < 2) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -2362,7 +2361,7 @@ void reply_mknew(struct smb_request *req) struct smb_filename *smb_fname = NULL; char *fname = NULL; uint32_t fattr = 0; - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); struct files_struct *dirfsp = NULL; files_struct *fsp; int oplock_request = 0; @@ -2376,7 +2375,6 @@ void reply_mknew(struct smb_request *req) TALLOC_CTX *ctx = talloc_tos(); START_PROFILE(SMBcreate); - init_smb_file_time(&ft); if (req->wct < 3) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); @@ -6853,12 +6851,11 @@ void reply_readbs(struct smb_request *req) void reply_setattrE(struct smb_request *req) { connection_struct *conn = req->conn; - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); files_struct *fsp; NTSTATUS status; START_PROFILE(SMBsetattrE); - init_smb_file_time(&ft); if (req->wct < 7) { reply_nterror(req, NT_STATUS_INVALID_PARAMETER); diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index 073b78f40b8..0c878d2ca2f 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -3913,7 +3913,7 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn, files_struct *fsp, struct smb_filename *smb_fname) { - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); uint32_t raw_unixmode; mode_t unixmode; off_t size = 0; @@ -3927,8 +3927,6 @@ static NTSTATUS smb_set_file_unix_basic(connection_struct *conn, return NT_STATUS_DOS(ERRSRV, ERRaccess); } - init_smb_file_time(&ft); - if (total_data < 100) { return NT_STATUS_INVALID_PARAMETER; } diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index d162f94facf..ae1da6d318c 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -4651,12 +4651,10 @@ static NTSTATUS smb_set_file_basic_info(connection_struct *conn, struct smb_filename *smb_fname) { /* Patch to do this correctly from Paul Eggert . */ - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); uint32_t dosmode = 0; NTSTATUS status = NT_STATUS_OK; - init_smb_file_time(&ft); - if (total_data < 36) { return NT_STATUS_INVALID_PARAMETER; } @@ -4707,9 +4705,7 @@ static NTSTATUS smb_set_info_standard(connection_struct *conn, struct smb_filename *smb_fname) { NTSTATUS status; - struct smb_file_time ft; - - init_smb_file_time(&ft); + struct smb_file_time ft = smb_file_time_omit(); if (total_data < 12) { return NT_STATUS_INVALID_PARAMETER; diff --git a/source3/smbd/vfs.c b/source3/smbd/vfs.c index f9f8f0dfaef..ab61f012b24 100644 --- a/source3/smbd/vfs.c +++ b/source3/smbd/vfs.c @@ -1198,11 +1198,11 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp) return NT_STATUS_OK; } -void init_smb_file_time(struct smb_file_time *ft) +struct smb_file_time smb_file_time_omit(void) { struct timespec omit = make_omit_timespec(); - *ft = (struct smb_file_time) { + return (struct smb_file_time){ .atime = omit, .ctime = omit, .mtime = omit, diff --git a/source3/torture/cmd_vfs.c b/source3/torture/cmd_vfs.c index acd053694f0..59bb0db59a5 100644 --- a/source3/torture/cmd_vfs.c +++ b/source3/torture/cmd_vfs.c @@ -1048,7 +1048,7 @@ static NTSTATUS cmd_getwd(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, static NTSTATUS cmd_utime(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, const char **argv) { - struct smb_file_time ft; + struct smb_file_time ft = smb_file_time_omit(); struct files_struct *dirfsp = NULL; struct smb_filename *smb_fname = NULL; NTSTATUS status; @@ -1058,8 +1058,6 @@ static NTSTATUS cmd_utime(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, return NT_STATUS_OK; } - init_smb_file_time(&ft); - ft.atime = time_t_to_full_timespec(atoi(argv[2])); ft.mtime = time_t_to_full_timespec(atoi(argv[3]));