Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932925AbbLRPkI (ORCPT ); Fri, 18 Dec 2015 10:40:08 -0500 Received: from m50-135.163.com ([123.125.50.135]:52213 "EHLO m50-135.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754039AbbLRPeF (ORCPT ); Fri, 18 Dec 2015 10:34:05 -0500 From: Geliang Tang To: Ilya Dryomov , "Yan, Zheng" , Sage Weil , "David S. Miller" Cc: Geliang Tang , ceph-devel@vger.kernel.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/14] libceph: use list_for_each_entry_safe Date: Fri, 18 Dec 2015 23:33:30 +0800 Message-Id: <40510e6829654a5a4726650c63bf00d88c037593.1450451516.git.geliangtang@163.com> X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-CM-TRANSID: D9GowAAnDuRiJ3RWv0OjAw--.24426S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw48Kry8tF4kAryrJF15CFg_yoW8JFWkpF Z8C3y3GFWkJw1fuF48XF9rWFyFvF13Gry2qryjk3WrKF15Gw48tF17GFyrXFyYyrWxuan0 gw48KF1UZrs2krJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UOmRUUUUUU= X-Originating-IP: [116.77.150.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiMAPUmVWBTMa8CwAAsX Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1493 Lines: 49 Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang --- net/ceph/messenger.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/net/ceph/messenger.c b/net/ceph/messenger.c index 9981039..c664b7f 100644 --- a/net/ceph/messenger.c +++ b/net/ceph/messenger.c @@ -3361,9 +3361,8 @@ 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; + LIST_HEAD(head); + struct ceph_msg_data *data, *next; dout("%s %p\n", __func__, m); WARN_ON(!list_empty(&m->list_head)); @@ -3376,12 +3375,9 @@ 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_splice_init(&m->data, &head); + list_for_each_entry_safe(data, next, &head, links) { + list_del_init(&data->links); ceph_msg_data_destroy(data); } m->data_length = 0; -- 2.5.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/