smb: use LIST_HEAD() to simplify code
authorHongbo Li <lihongbo22@huawei.com>
Wed, 21 Aug 2024 06:56:37 +0000 (14:56 +0800)
committerSteve French <stfrench@microsoft.com>
Sun, 15 Sep 2024 15:42:45 +0000 (10:42 -0500)
list_head can be initialized automatically with LIST_HEAD()
instead of calling INIT_LIST_HEAD(). No functional impact.

Signed-off-by: Hongbo Li <lihongbo22@huawei.com>
Reviewed-by: Dan Carpenter <dan.carpenter@linaro.org>
Signed-off-by: Steve French <stfrench@microsoft.com>
fs/smb/client/connect.c
fs/smb/client/file.c
fs/smb/client/misc.c
fs/smb/client/smb2file.c

index 098d51d0044c04605e38cec1cc32b2367d396109..08a41c7aaf723f5122e8b0ca53d8888936e7de31 100644 (file)
@@ -1009,11 +1009,10 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
        }
 
        if (!list_empty(&server->pending_mid_q)) {
-               struct list_head dispose_list;
                struct mid_q_entry *mid_entry;
                struct list_head *tmp, *tmp2;
+               LIST_HEAD(dispose_list);
 
-               INIT_LIST_HEAD(&dispose_list);
                spin_lock(&server->mid_lock);
                list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
                        mid_entry = list_entry(tmp, struct mid_q_entry, qhead);
index 2d387485f05ba0577b22ebbee3a8ea7eea016193..0fb2b09503068724d9c7ab66752e06f3c62da917 100644 (file)
@@ -1435,7 +1435,7 @@ void
 cifs_reopen_persistent_handles(struct cifs_tcon *tcon)
 {
        struct cifsFileInfo *open_file, *tmp;
-       struct list_head tmp_list;
+       LIST_HEAD(tmp_list);
 
        if (!tcon->use_persistent || !tcon->need_reopen_files)
                return;
@@ -1443,7 +1443,6 @@ cifs_reopen_persistent_handles(struct cifs_tcon *tcon)
        tcon->need_reopen_files = false;
 
        cifs_dbg(FYI, "Reopen persistent handles\n");
-       INIT_LIST_HEAD(&tmp_list);
 
        /* list all files open on tree connection, reopen resilient handles  */
        spin_lock(&tcon->open_file_lock);
@@ -2126,9 +2125,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
        struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
        struct cifsLockInfo *li, *tmp;
        __u64 length = cifs_flock_len(flock);
-       struct list_head tmp_llist;
-
-       INIT_LIST_HEAD(&tmp_llist);
+       LIST_HEAD(tmp_llist);
 
        /*
         * Accessing maxBuf is racy with cifs_reconnect - need to store value
index c6f11e6f9eb995b6e809ee18c320d1ec2854f9f8..dab526191b07425747b92cacfbb0a45bd048e58f 100644 (file)
@@ -751,12 +751,11 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)
 {
        struct cifsFileInfo *cfile = NULL;
        struct file_list *tmp_list, *tmp_next_list;
-       struct list_head file_head;
+       LIST_HEAD(file_head);
 
        if (cifs_inode == NULL)
                return;
 
-       INIT_LIST_HEAD(&file_head);
        spin_lock(&cifs_inode->open_file_lock);
        list_for_each_entry(cfile, &cifs_inode->openFileList, flist) {
                if (delayed_work_pending(&cfile->deferred)) {
@@ -787,9 +786,8 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon)
 {
        struct cifsFileInfo *cfile;
        struct file_list *tmp_list, *tmp_next_list;
-       struct list_head file_head;
+       LIST_HEAD(file_head);
 
-       INIT_LIST_HEAD(&file_head);
        spin_lock(&tcon->open_file_lock);
        list_for_each_entry(cfile, &tcon->openFileList, tlist) {
                if (delayed_work_pending(&cfile->deferred)) {
@@ -819,11 +817,10 @@ cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, const char *path)
 {
        struct cifsFileInfo *cfile;
        struct file_list *tmp_list, *tmp_next_list;
-       struct list_head file_head;
        void *page;
        const char *full_path;
+       LIST_HEAD(file_head);
 
-       INIT_LIST_HEAD(&file_head);
        page = alloc_dentry_path();
        spin_lock(&tcon->open_file_lock);
        list_for_each_entry(cfile, &tcon->openFileList, tlist) {
index e6319f248816b3a9d6504624d1e9f2079399a1b7..e301349b0078d18792721256f4eda67bf41e6255 100644 (file)
@@ -196,9 +196,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
        struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
        struct cifsLockInfo *li, *tmp;
        __u64 length = 1 + flock->fl_end - flock->fl_start;
-       struct list_head tmp_llist;
-
-       INIT_LIST_HEAD(&tmp_llist);
+       LIST_HEAD(tmp_llist);
 
        /*
         * Accessing maxBuf is racy with cifs_reconnect - need to store value