All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor
@ 2010-08-07  9:09 ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-07  9:09 UTC (permalink / raw)
  To: Artem Bityutskiy, David Woodhouse, linux-mtd, 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 variable re1 is already
used within the loop as a temporary variable, and is not live here.

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>

---
 drivers/mtd/ubi/cdev.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 4dfa6b9..3d2d1a6 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -798,18 +798,18 @@ static int rename_volumes(struct ubi_device *ubi,
 			goto out_free;
 		}
 
-		re = kzalloc(sizeof(struct ubi_rename_entry), GFP_KERNEL);
-		if (!re) {
+		re1 = kzalloc(sizeof(struct ubi_rename_entry), GFP_KERNEL);
+		if (!re1) {
 			err = -ENOMEM;
 			ubi_close_volume(desc);
 			goto out_free;
 		}
 
-		re->remove = 1;
-		re->desc = desc;
-		list_add(&re->list, &rename_list);
+		re1->remove = 1;
+		re1->desc = desc;
+		list_add(&re1->list, &rename_list);
 		dbg_msg("will remove volume %d, name \"%s\"",
-			re->desc->vol->vol_id, re->desc->vol->name);
+			re1->desc->vol->vol_id, re1->desc->vol->name);
 	}
 
 	mutex_lock(&ubi->device_mutex);

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

* [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry
@ 2010-08-07  9:09 ` Julia Lawall
  0 siblings, 0 replies; 8+ messages in thread
From: Julia Lawall @ 2010-08-07  9:09 UTC (permalink / raw)
  To: Artem Bityutskiy, David Woodhouse, linux-mtd, 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 variable re1 is already
used within the loop as a temporary variable, and is not live here.

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>

---
 drivers/mtd/ubi/cdev.c |   12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/mtd/ubi/cdev.c b/drivers/mtd/ubi/cdev.c
index 4dfa6b9..3d2d1a6 100644
--- a/drivers/mtd/ubi/cdev.c
+++ b/drivers/mtd/ubi/cdev.c
@@ -798,18 +798,18 @@ static int rename_volumes(struct ubi_device *ubi,
 			goto out_free;
 		}
 
-		re = kzalloc(sizeof(struct ubi_rename_entry), GFP_KERNEL);
-		if (!re) {
+		re1 = kzalloc(sizeof(struct ubi_rename_entry), GFP_KERNEL);
+		if (!re1) {
 			err = -ENOMEM;
 			ubi_close_volume(desc);
 			goto out_free;
 		}
 
-		re->remove = 1;
-		re->desc = desc;
-		list_add(&re->list, &rename_list);
+		re1->remove = 1;
+		re1->desc = desc;
+		list_add(&re1->list, &rename_list);
 		dbg_msg("will remove volume %d, name \"%s\"",
-			re->desc->vol->vol_id, re->desc->vol->name);
+			re1->desc->vol->vol_id, re1->desc->vol->name);
 	}
 
 	mutex_lock(&ubi->device_mutex);

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

* Re: [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor
  2010-08-07  9:09 ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry Julia Lawall
  (?)
@ 2010-08-08 10:25   ` Artem Bityutskiy
  -1 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-08 10:25 UTC (permalink / raw)
  To: Julia Lawall; +Cc: David Woodhouse, linux-mtd, linux-kernel, kernel-janitors

On Sat, 2010-08-07 at 11:09 +0200, Julia Lawall wrote:
> 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 variable re1 is already
> used within the loop as a temporary variable, and is not live here.

Looks good, thanks, I'll push it to the UBI tree a bit later.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)


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

* Re: [PATCH 2/2] drivers/mtd/ubi: Eliminate update of
@ 2010-08-08 10:25   ` Artem Bityutskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-08 10:25 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, David Woodhouse, linux-kernel

On Sat, 2010-08-07 at 11:09 +0200, Julia Lawall wrote:
> 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 variable re1 is already
> used within the loop as a temporary variable, and is not live here.

Looks good, thanks, I'll push it to the UBI tree a bit later.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)


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

* Re: [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor
@ 2010-08-08 10:25   ` Artem Bityutskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-08 10:25 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, David Woodhouse, linux-kernel

On Sat, 2010-08-07 at 11:09 +0200, Julia Lawall wrote:
> 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 variable re1 is already
> used within the loop as a temporary variable, and is not live here.

Looks good, thanks, I'll push it to the UBI tree a bit later.

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

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

* Re: [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor
  2010-08-07  9:09 ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry Julia Lawall
  (?)
@ 2010-08-24 12:52   ` Artem Bityutskiy
  -1 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-24 12:52 UTC (permalink / raw)
  To: Julia Lawall; +Cc: David Woodhouse, linux-mtd, linux-kernel, kernel-janitors

On Sat, 2010-08-07 at 11:09 +0200, Julia Lawall wrote:
> 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 variable re1 is already
> used within the loop as a temporary variable, and is not live here.
> 
> 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>

Pushed to ubi-2.6.git tree. This won't be seen in linux-next for some
time though, but I'll make it visible in linux-next at some point soon.

Thanks!

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)


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

* Re: [PATCH 2/2] drivers/mtd/ubi: Eliminate update of
@ 2010-08-24 12:52   ` Artem Bityutskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-24 12:52 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, David Woodhouse, linux-kernel

On Sat, 2010-08-07 at 11:09 +0200, Julia Lawall wrote:
> 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 variable re1 is already
> used within the loop as a temporary variable, and is not live here.
> 
> 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>

Pushed to ubi-2.6.git tree. This won't be seen in linux-next for some
time though, but I'll make it visible in linux-next at some point soon.

Thanks!

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)


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

* Re: [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor
@ 2010-08-24 12:52   ` Artem Bityutskiy
  0 siblings, 0 replies; 8+ messages in thread
From: Artem Bityutskiy @ 2010-08-24 12:52 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-mtd, kernel-janitors, David Woodhouse, linux-kernel

On Sat, 2010-08-07 at 11:09 +0200, Julia Lawall wrote:
> 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 variable re1 is already
> used within the loop as a temporary variable, and is not live here.
> 
> 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>

Pushed to ubi-2.6.git tree. This won't be seen in linux-next for some
time though, but I'll make it visible in linux-next at some point soon.

Thanks!

-- 
Best Regards,
Artem Bityutskiy (Артём Битюцкий)

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

end of thread, other threads:[~2010-08-24 12:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-08-07  9:09 [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor Julia Lawall
2010-08-07  9:09 ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry Julia Lawall
2010-08-08 10:25 ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor Artem Bityutskiy
2010-08-08 10:25   ` Artem Bityutskiy
2010-08-08 10:25   ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of Artem Bityutskiy
2010-08-24 12:52 ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of list_for_each_entry loop cursor Artem Bityutskiy
2010-08-24 12:52   ` Artem Bityutskiy
2010-08-24 12:52   ` [PATCH 2/2] drivers/mtd/ubi: Eliminate update of Artem Bityutskiy

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.