Skip to content

Commit 21dcbc1

Browse files
Hongbo Lismfrench
authored andcommitted
smb: use LIST_HEAD() to simplify code
list_head can be initialized automatically with LIST_HEAD() instead of calling INIT_LIST_HEAD(). No functional impact. Signed-off-by: Hongbo Li <[email protected]> Reviewed-by: Dan Carpenter <[email protected]> Signed-off-by: Steve French <[email protected]>
1 parent 2ba0d89 commit 21dcbc1

File tree

4 files changed

+7
-16
lines changed

4 files changed

+7
-16
lines changed

fs/smb/client/connect.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1009,11 +1009,10 @@ clean_demultiplex_info(struct TCP_Server_Info *server)
10091009
}
10101010

10111011
if (!list_empty(&server->pending_mid_q)) {
1012-
struct list_head dispose_list;
10131012
struct mid_q_entry *mid_entry;
10141013
struct list_head *tmp, *tmp2;
1014+
LIST_HEAD(dispose_list);
10151015

1016-
INIT_LIST_HEAD(&dispose_list);
10171016
spin_lock(&server->mid_lock);
10181017
list_for_each_safe(tmp, tmp2, &server->pending_mid_q) {
10191018
mid_entry = list_entry(tmp, struct mid_q_entry, qhead);

fs/smb/client/file.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,15 +1435,14 @@ void
14351435
cifs_reopen_persistent_handles(struct cifs_tcon *tcon)
14361436
{
14371437
struct cifsFileInfo *open_file, *tmp;
1438-
struct list_head tmp_list;
1438+
LIST_HEAD(tmp_list);
14391439

14401440
if (!tcon->use_persistent || !tcon->need_reopen_files)
14411441
return;
14421442

14431443
tcon->need_reopen_files = false;
14441444

14451445
cifs_dbg(FYI, "Reopen persistent handles\n");
1446-
INIT_LIST_HEAD(&tmp_list);
14471446

14481447
/* list all files open on tree connection, reopen resilient handles */
14491448
spin_lock(&tcon->open_file_lock);
@@ -2126,9 +2125,7 @@ cifs_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
21262125
struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
21272126
struct cifsLockInfo *li, *tmp;
21282127
__u64 length = cifs_flock_len(flock);
2129-
struct list_head tmp_llist;
2130-
2131-
INIT_LIST_HEAD(&tmp_llist);
2128+
LIST_HEAD(tmp_llist);
21322129

21332130
/*
21342131
* Accessing maxBuf is racy with cifs_reconnect - need to store value

fs/smb/client/misc.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,11 @@ cifs_close_deferred_file(struct cifsInodeInfo *cifs_inode)
751751
{
752752
struct cifsFileInfo *cfile = NULL;
753753
struct file_list *tmp_list, *tmp_next_list;
754-
struct list_head file_head;
754+
LIST_HEAD(file_head);
755755

756756
if (cifs_inode == NULL)
757757
return;
758758

759-
INIT_LIST_HEAD(&file_head);
760759
spin_lock(&cifs_inode->open_file_lock);
761760
list_for_each_entry(cfile, &cifs_inode->openFileList, flist) {
762761
if (delayed_work_pending(&cfile->deferred)) {
@@ -787,9 +786,8 @@ cifs_close_all_deferred_files(struct cifs_tcon *tcon)
787786
{
788787
struct cifsFileInfo *cfile;
789788
struct file_list *tmp_list, *tmp_next_list;
790-
struct list_head file_head;
789+
LIST_HEAD(file_head);
791790

792-
INIT_LIST_HEAD(&file_head);
793791
spin_lock(&tcon->open_file_lock);
794792
list_for_each_entry(cfile, &tcon->openFileList, tlist) {
795793
if (delayed_work_pending(&cfile->deferred)) {
@@ -819,11 +817,10 @@ cifs_close_deferred_file_under_dentry(struct cifs_tcon *tcon, const char *path)
819817
{
820818
struct cifsFileInfo *cfile;
821819
struct file_list *tmp_list, *tmp_next_list;
822-
struct list_head file_head;
823820
void *page;
824821
const char *full_path;
822+
LIST_HEAD(file_head);
825823

826-
INIT_LIST_HEAD(&file_head);
827824
page = alloc_dentry_path();
828825
spin_lock(&tcon->open_file_lock);
829826
list_for_each_entry(cfile, &tcon->openFileList, tlist) {

fs/smb/client/smb2file.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,9 +196,7 @@ smb2_unlock_range(struct cifsFileInfo *cfile, struct file_lock *flock,
196196
struct cifsInodeInfo *cinode = CIFS_I(d_inode(cfile->dentry));
197197
struct cifsLockInfo *li, *tmp;
198198
__u64 length = 1 + flock->fl_end - flock->fl_start;
199-
struct list_head tmp_llist;
200-
201-
INIT_LIST_HEAD(&tmp_llist);
199+
LIST_HEAD(tmp_llist);
202200

203201
/*
204202
* Accessing maxBuf is racy with cifs_reconnect - need to store value

0 commit comments

Comments
 (0)