Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754388AbbLRPed (ORCPT ); Fri, 18 Dec 2015 10:34:33 -0500 Received: from m50-133.163.com ([123.125.50.133]:52311 "EHLO m50-133.163.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753871AbbLRPe0 (ORCPT ); Fri, 18 Dec 2015 10:34:26 -0500 From: Geliang Tang To: Marek Lindner , Simon Wunderlich , Antonio Quartulli , "David S. Miller" Cc: Geliang Tang , b.a.t.m.a.n@lists.open-mesh.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/14] batman-adv: use list_for_each_entry_safe Date: Fri, 18 Dec 2015 23:33:31 +0800 Message-Id: X-Mailer: git-send-email 2.5.0 In-Reply-To: References: In-Reply-To: References: X-CM-TRANSID: DdGowEDp7UhjJ3RWN+qHAA--.1180S3 X-Coremail-Antispam: 1Uf129KBjvJXoW7Zw4Uuw1UCrykKry7Ar4DCFg_yoW8Ww45pr y5GFy3Gr48Jwn7Wrs5JFW5ur1rtr4UG34xKay5Ca4rtFsrKryaga4ayF1ruFy5tFWUKws8 GF4DKFWYyr4UuwUanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07UOiSLUUUUU= X-Originating-IP: [116.77.150.30] X-CM-SenderInfo: 5jhoxtpqjwt0rj6rljoofrz/1tbiowXUmVUL3cXvZQAAsn Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1824 Lines: 56 Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang --- net/batman-adv/icmp_socket.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index bcabb5e..841239c 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -104,25 +104,21 @@ static int batadv_socket_open(struct inode *inode, struct file *file) static int batadv_socket_release(struct inode *inode, struct file *file) { - struct batadv_socket_client *socket_client = file->private_data; - struct batadv_socket_packet *socket_packet; - struct list_head *list_pos, *list_pos_tmp; + struct batadv_socket_client *client = file->private_data; + struct batadv_socket_packet *packet, *tmp; - spin_lock_bh(&socket_client->lock); + spin_lock_bh(&client->lock); /* for all packets in the queue ... */ - list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) { - socket_packet = list_entry(list_pos, - struct batadv_socket_packet, list); - - list_del(list_pos); - kfree(socket_packet); + list_for_each_entry_safe(packet, tmp, &client->queue_list, list) { + list_del(&packet->list); + kfree(packet); } - batadv_socket_client_hash[socket_client->index] = NULL; - spin_unlock_bh(&socket_client->lock); + batadv_socket_client_hash[client->index] = NULL; + spin_unlock_bh(&client->lock); - kfree(socket_client); + kfree(client); module_put(THIS_MODULE); return 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/