diff options
author | Nikola Pajkovsky <npajkovs@redhat.com> | 2013-04-30 22:15:49 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-05-01 11:12:58 -0400 |
commit | 41239fe82d85c135684b09f1e65622d6c1dbe8dc (patch) | |
tree | c7c44c3f87444d9636bc911ce98401ab974c21dd /ipc/msg.c | |
parent | 6062a8dc0517bce23e3c2f7d2fea5e22411269a3 (diff) |
ipc/msg.c: use list_for_each_entry_[safe] for list traversing
The ipc/msg.c code does its list operations by hand and it open-codes the
accesses, instead of using for_each_entry_[safe].
Signed-off-by: Nikola Pajkovsky <npajkovs@redhat.com>
Cc: Stanislav Kinsbursky <skinsbursky@parallels.com>
Cc: "Eric W. Biederman" <ebiederm@xmission.com>
Cc: Peter Hurley <peter@hurleysoftware.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'ipc/msg.c')
-rw-r--r-- | ipc/msg.c | 35 |
1 files changed, 8 insertions, 27 deletions
@@ -238,14 +238,9 @@ static inline void ss_del(struct msg_sender *mss) | |||
238 | 238 | ||
239 | static void ss_wakeup(struct list_head *h, int kill) | 239 | static void ss_wakeup(struct list_head *h, int kill) |
240 | { | 240 | { |
241 | struct list_head *tmp; | 241 | struct msg_sender *mss, *t; |
242 | 242 | ||
243 | tmp = h->next; | 243 | list_for_each_entry_safe(mss, t, h, list) { |
244 | while (tmp != h) { | ||
245 | struct msg_sender *mss; | ||
246 | |||
247 | mss = list_entry(tmp, struct msg_sender, list); | ||
248 | tmp = tmp->next; | ||
249 | if (kill) | 244 | if (kill) |
250 | mss->list.next = NULL; | 245 | mss->list.next = NULL; |
251 | wake_up_process(mss->tsk); | 246 | wake_up_process(mss->tsk); |
@@ -254,14 +249,9 @@ static void ss_wakeup(struct list_head *h, int kill) | |||
254 | 249 | ||
255 | static void expunge_all(struct msg_queue *msq, int res) | 250 | static void expunge_all(struct msg_queue *msq, int res) |
256 | { | 251 | { |
257 | struct list_head *tmp; | 252 | struct msg_receiver *msr, *t; |
258 | |||
259 | tmp = msq->q_receivers.next; | ||
260 | while (tmp != &msq->q_receivers) { | ||
261 | struct msg_receiver *msr; | ||
262 | 253 | ||
263 | msr = list_entry(tmp, struct msg_receiver, r_list); | 254 | list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { |
264 | tmp = tmp->next; | ||
265 | msr->r_msg = NULL; | 255 | msr->r_msg = NULL; |
266 | wake_up_process(msr->r_tsk); | 256 | wake_up_process(msr->r_tsk); |
267 | smp_mb(); | 257 | smp_mb(); |
@@ -279,7 +269,7 @@ static void expunge_all(struct msg_queue *msq, int res) | |||
279 | */ | 269 | */ |
280 | static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) | 270 | static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) |
281 | { | 271 | { |
282 | struct list_head *tmp; | 272 | struct msg_msg *msg, *t; |
283 | struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); | 273 | struct msg_queue *msq = container_of(ipcp, struct msg_queue, q_perm); |
284 | 274 | ||
285 | expunge_all(msq, -EIDRM); | 275 | expunge_all(msq, -EIDRM); |
@@ -287,11 +277,7 @@ static void freeque(struct ipc_namespace *ns, struct kern_ipc_perm *ipcp) | |||
287 | msg_rmid(ns, msq); | 277 | msg_rmid(ns, msq); |
288 | msg_unlock(msq); | 278 | msg_unlock(msq); |
289 | 279 | ||
290 | tmp = msq->q_messages.next; | 280 | list_for_each_entry_safe(msg, t, &msq->q_messages, m_list) { |
291 | while (tmp != &msq->q_messages) { | ||
292 | struct msg_msg *msg = list_entry(tmp, struct msg_msg, m_list); | ||
293 | |||
294 | tmp = tmp->next; | ||
295 | atomic_dec(&ns->msg_hdrs); | 281 | atomic_dec(&ns->msg_hdrs); |
296 | free_msg(msg); | 282 | free_msg(msg); |
297 | } | 283 | } |
@@ -604,14 +590,9 @@ static int testmsg(struct msg_msg *msg, long type, int mode) | |||
604 | 590 | ||
605 | static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg) | 591 | static inline int pipelined_send(struct msg_queue *msq, struct msg_msg *msg) |
606 | { | 592 | { |
607 | struct list_head *tmp; | 593 | struct msg_receiver *msr, *t; |
608 | |||
609 | tmp = msq->q_receivers.next; | ||
610 | while (tmp != &msq->q_receivers) { | ||
611 | struct msg_receiver *msr; | ||
612 | 594 | ||
613 | msr = list_entry(tmp, struct msg_receiver, r_list); | 595 | list_for_each_entry_safe(msr, t, &msq->q_receivers, r_list) { |
614 | tmp = tmp->next; | ||
615 | if (testmsg(msg, msr->r_msgtype, msr->r_mode) && | 596 | if (testmsg(msg, msr->r_msgtype, msr->r_mode) && |
616 | !security_msg_queue_msgrcv(msq, msg, msr->r_tsk, | 597 | !security_msg_queue_msgrcv(msq, msg, msr->r_tsk, |
617 | msr->r_msgtype, msr->r_mode)) { | 598 | msr->r_msgtype, msr->r_mode)) { |