Skip to content

Commit

Permalink
iscsi-target: Use list_first_entry() where appropriate
Browse files Browse the repository at this point in the history
Instead of using the obfuscated pattern of

	list_for_each_entry(var, list, ...)
		break;

to set var to the first entry of a list, use the straightforward

	var = list_first_entry(list, ...);

Reported-by: Joern Engel <joern@logfs.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Signed-off-by: Nicholas Bellinger <nab@linux-iscsi.org>
  • Loading branch information
Roland Dreier authored and Nicholas Bellinger committed Nov 7, 2012
1 parent 48c2567 commit 1f981de
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
3 changes: 1 addition & 2 deletions drivers/target/iscsi/iscsi_target_tq.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,7 @@ static struct iscsi_thread_set *iscsi_get_ts_from_inactive_list(void)
return NULL;
}

list_for_each_entry(ts, &inactive_ts_list, ts_list)
break;
ts = list_first_entry(&inactive_ts_list, struct iscsi_thread_set, ts_list);

list_del(&ts->ts_list);
iscsit_global->inactive_ts--;
Expand Down
8 changes: 4 additions & 4 deletions drivers/target/iscsi/iscsi_target_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -500,8 +500,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_immediate_queue(struct iscsi_conn *c
spin_unlock_bh(&conn->immed_queue_lock);
return NULL;
}
list_for_each_entry(qr, &conn->immed_queue_list, qr_list)
break;
qr = list_first_entry(&conn->immed_queue_list,
struct iscsi_queue_req, qr_list);

list_del(&qr->qr_list);
if (qr->cmd)
Expand Down Expand Up @@ -575,8 +575,8 @@ struct iscsi_queue_req *iscsit_get_cmd_from_response_queue(struct iscsi_conn *co
return NULL;
}

list_for_each_entry(qr, &conn->response_queue_list, qr_list)
break;
qr = list_first_entry(&conn->response_queue_list,
struct iscsi_queue_req, qr_list);

list_del(&qr->qr_list);
if (qr->cmd)
Expand Down

0 comments on commit 1f981de

Please sign in to comment.