All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry
@ 2010-08-07  9:09 ` Julia Lawall
  0 siblings, 0 replies; 23+ messages in thread
From: Julia Lawall @ 2010-08-07  9:09 UTC (permalink / raw)
  To: Mark Fasheh, Joel Becker, ocfs2-devel, linux-kernel,
	kernel-janitors

From: Julia Lawall <julia@diku.dk>

list_for_each_entry uses its first argument to move from one element to the
next, so modifying it can break the iteration.

The semantic match that finds this problem is as follows:
(http://coccinelle.lip6.fr/)

// <smpl>
@r@
iterator name list_for_each_entry;
expression x,E;
position p1,p2;
@@

list_for_each_entry@p1(x,...) { <... x =@p2 E ...> }

@@
expression x,E;
position r.p1,r.p2;
statement S;
@@

*x =@p2 E
...
list_for_each_entry@p1(x,...) S
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>

---
I don't know whether this is the right solution, but it seems plausible
considering the subsequent test on lock.  In any case, setting lock to NULL
and then going back to the top of the loop does not work.

 fs/ocfs2/dlm/dlmrecovery.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/ocfs2/dlm/dlmrecovery.c b/fs/ocfs2/dlm/dlmrecovery.c
index 9dfaac7..7084a11 100644
--- a/fs/ocfs2/dlm/dlmrecovery.c
+++ b/fs/ocfs2/dlm/dlmrecovery.c
@@ -1792,10 +1792,10 @@ static int dlm_process_recovery_data(struct dlm_ctxt *dlm,
 			for (j = DLM_GRANTED_LIST; j <= DLM_BLOCKED_LIST; j++) {
 				tmpq = dlm_list_idx_to_ptr(res, j);
 				list_for_each_entry(lock, tmpq, list) {
-					if (lock->ml.cookie != ml->cookie)
+					if (lock->ml.cookie != ml->cookie) {
 						lock = NULL;
-					else
 						break;
+					}
 				}
 				if (lock)
 					break;

^ permalink raw reply related	[flat|nested] 23+ messages in thread

end of thread, other threads:[~2011-11-17  8:43 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-07  9:09 [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry Julia Lawall
2010-08-07  9:09 ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Julia Lawall
2010-08-07  9:09 ` [Ocfs2-devel] " Julia Lawall
2010-08-12  0:03 ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of Joel Becker
2010-08-12  0:03   ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Joel Becker
2010-08-12  0:03   ` [Ocfs2-devel] " Joel Becker
2010-08-12  5:46   ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry Julia Lawall
2010-08-12  5:46     ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Julia Lawall
2010-08-12  5:46     ` [Ocfs2-devel] " Julia Lawall
2010-08-12  7:14     ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of Dan Carpenter
2010-08-12  7:14       ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Dan Carpenter
2010-08-12  7:14       ` [Ocfs2-devel] " Dan Carpenter
2010-08-12  9:31     ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of Joel Becker
2010-08-12  9:31       ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Joel Becker
2010-08-12  9:31       ` [Ocfs2-devel] " Joel Becker
2011-11-02  7:39   ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of Dan Carpenter
2011-11-02  7:39     ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Dan Carpenter
2011-11-02 17:05     ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry Sunil Mushran
2011-11-02 17:05       ` [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Sunil Mushran
2011-11-02 17:05       ` [Ocfs2-devel] " Sunil Mushran
2011-11-17  8:43       ` [Ocfs2-devel] [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of Joel Becker
2011-11-17  8:43         ` [Ocfs2-devel] [PATCH 1/2] fs/ocfs2/dlm: Eliminate update of list_for_each_entry loop cursor Joel Becker
2011-11-17  8:43         ` Joel Becker

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.