smbd: Use direct struct initialization
authorVolker Lendecke <vl@samba.org>
Thu, 16 May 2024 10:03:46 +0000 (12:03 +0200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 22 May 2024 04:23:29 +0000 (04:23 +0000)
Make sure all fields in the target struct are initialized

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
source3/locking/locking.c

index 25735a3083dd186690730e0d19f7cda5b281b501..41b54b14c6b718c24f08abd2880d9b432f7b5519 100644 (file)
@@ -95,14 +95,16 @@ void init_strict_lock_struct(files_struct *fsp,
 {
        SMB_ASSERT(lock_type == READ_LOCK || lock_type == WRITE_LOCK);
 
-       plock->context.smblctx = smblctx;
-        plock->context.tid = fsp->conn->cnum;
-        plock->context.pid = messaging_server_id(fsp->conn->sconn->msg_ctx);
-        plock->start = start;
-        plock->size = size;
-        plock->fnum = fsp->fnum;
-        plock->lock_type = lock_type;
-        plock->lock_flav = lp_posix_cifsu_locktype(fsp);
+       *plock = (struct lock_struct) {
+               .context.smblctx = smblctx,
+               .context.tid = fsp->conn->cnum,
+               .context.pid = messaging_server_id(fsp->conn->sconn->msg_ctx),
+               .start = start,
+               .size = size,
+               .fnum = fsp->fnum,
+               .lock_type = lock_type,
+               .lock_flav = lp_posix_cifsu_locktype(fsp),
+       };
 }
 
 bool strict_lock_check_default(files_struct *fsp, struct lock_struct *plock)