Skip to content

Commit

Permalink
libceph: use list_for_each_entry_safe
Browse files Browse the repository at this point in the history
Use list_for_each_entry_safe() instead of list_for_each_safe() to
simplify the code.

Signed-off-by: Geliang Tang <geliangtang@163.com>
[idryomov@gmail.com: nuke call to list_splice_init() as well]
Signed-off-by: Ilya Dryomov <idryomov@gmail.com>
  • Loading branch information
Geliang Tang authored and Ilya Dryomov committed Jan 21, 2016
1 parent 99c88e6 commit 10bcee1
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions net/ceph/messenger.c
Original file line number Diff line number Diff line change
Expand Up @@ -3358,9 +3358,7 @@ static void ceph_msg_free(struct ceph_msg *m)
static void ceph_msg_release(struct kref *kref)
{
struct ceph_msg *m = container_of(kref, struct ceph_msg, kref);
LIST_HEAD(data);
struct list_head *links;
struct list_head *next;
struct ceph_msg_data *data, *next;

dout("%s %p\n", __func__, m);
WARN_ON(!list_empty(&m->list_head));
Expand All @@ -3373,12 +3371,8 @@ static void ceph_msg_release(struct kref *kref)
m->middle = NULL;
}

list_splice_init(&m->data, &data);
list_for_each_safe(links, next, &data) {
struct ceph_msg_data *data;

data = list_entry(links, struct ceph_msg_data, links);
list_del_init(links);
list_for_each_entry_safe(data, next, &m->data, links) {
list_del_init(&data->links);
ceph_msg_data_destroy(data);
}
m->data_length = 0;
Expand Down

0 comments on commit 10bcee1

Please sign in to comment.