Commit fb1f23eab6a9cd7d94d47b66f56df77b370a3954
Committed by
Antonio Quartulli
1 parent
925a6f3790
batman-adv: use list_for_each_entry_safe
Use list_for_each_entry_safe() instead of list_for_each_safe() to simplify the code. Signed-off-by: Geliang Tang <geliangtang@163.com> Acked-by: Antonio Quartulli <a@unstable.cc> Reviewed-by: Sven Eckelmann <sven@narfation.org> Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch> Signed-off-by: Antonio Quartulli <a@unstable.cc>
Showing 1 changed file with 9 additions and 13 deletions Side-by-side Diff
net/batman-adv/icmp_socket.c
... | ... | @@ -104,25 +104,21 @@ |
104 | 104 | |
105 | 105 | static int batadv_socket_release(struct inode *inode, struct file *file) |
106 | 106 | { |
107 | - struct batadv_socket_client *socket_client = file->private_data; | |
108 | - struct batadv_socket_packet *socket_packet; | |
109 | - struct list_head *list_pos, *list_pos_tmp; | |
107 | + struct batadv_socket_client *client = file->private_data; | |
108 | + struct batadv_socket_packet *packet, *tmp; | |
110 | 109 | |
111 | - spin_lock_bh(&socket_client->lock); | |
110 | + spin_lock_bh(&client->lock); | |
112 | 111 | |
113 | 112 | /* for all packets in the queue ... */ |
114 | - list_for_each_safe(list_pos, list_pos_tmp, &socket_client->queue_list) { | |
115 | - socket_packet = list_entry(list_pos, | |
116 | - struct batadv_socket_packet, list); | |
117 | - | |
118 | - list_del(list_pos); | |
119 | - kfree(socket_packet); | |
113 | + list_for_each_entry_safe(packet, tmp, &client->queue_list, list) { | |
114 | + list_del(&packet->list); | |
115 | + kfree(packet); | |
120 | 116 | } |
121 | 117 | |
122 | - batadv_socket_client_hash[socket_client->index] = NULL; | |
123 | - spin_unlock_bh(&socket_client->lock); | |
118 | + batadv_socket_client_hash[client->index] = NULL; | |
119 | + spin_unlock_bh(&client->lock); | |
124 | 120 | |
125 | - kfree(socket_client); | |
121 | + kfree(client); | |
126 | 122 | module_put(THIS_MODULE); |
127 | 123 | |
128 | 124 | return 0; |