Skip to contentSkip to conversation

leds: pca9532: fix device_node_continue.cocci warnings

PATCH In review Julia Lawall 2 participants 5 messages Dec 29, 2016 – Dec 30, 2016

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 leds: pca9532: fix device_node_continue.cocci warnings

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

---

I haven't looked at the context in detail, but given the rule, I assume that there is an iterator, such as for_each_child_of_node, and these iterators do a put on each iteration, so none is needed in the loop body.

tree:   https://github.com/manabian/linux-lpc lpc18xx_43xx_devel
head:   9ee5f58bbb16c08da223c4b4933457e0eb72268d
commit: c58957273142be779f62c17fae389ce9c134139f [44/55] leds: pca9532: use
 leds-pca9532.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/leds/leds-pca9532.c +0 -3
@@ -473,7 +473,6 @@ pca9532_of_populate_pdata(struct device
 
 		res = of_property_read_u32(child, "reg", &reg);
 		if ((res != 0) || (reg >= maxleds)) {
-			of_node_put(child);
 			continue;
 		}
 
@@ -484,8 +483,6 @@ pca9532_of_populate_pdata(struct device
 		of_property_read_u32(child, "type", &pdata->leds[reg].type);
 		of_property_read_string(child, "linux,default-trigger",
 					&pdata->leds[reg].default_trigger);
-
-		of_node_put(child);
 	}
 
 	return pdata;
#1 lore raw

Hi Julia,

This patch doesn't apply to current for-next branch of linux-leds.git.

Best regards,
Jacek Anaszewski

Quoted 40 lines · Julia Lawall

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

---

I haven't looked at the context in detail, but given the rule, I assume that there is an iterator, such as for_each_child_of_node, and these iterators do a put on each iteration, so none is needed in the loop body.

tree:   https://github.com/manabian/linux-lpc lpc18xx_43xx_devel
head:   9ee5f58bbb16c08da223c4b4933457e0eb72268d
commit: c58957273142be779f62c17fae389ce9c134139f [44/55] leds: pca9532: use
 leds-pca9532.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/leds/leds-pca9532.c +0 -3
@@ -473,7 +473,6 @@ pca9532_of_populate_pdata(struct device
 
 		res = of_property_read_u32(child, "reg", &reg);
 		if ((res != 0) || (reg >= maxleds)) {
-			of_node_put(child);
 			continue;
 		}
 
@@ -484,8 +483,6 @@ pca9532_of_populate_pdata(struct device
 		of_property_read_u32(child, "type", &pdata->leds[reg].type);
 		of_property_read_string(child, "linux,default-trigger",
 					&pdata->leds[reg].default_trigger);
-
-		of_node_put(child);
 	}
 
 	return pdata;
#2 lore raw
Quoted 4 lines · Jacek Anaszewski

Hi Julia,

This patch doesn't apply to current for-next branch of linux-leds.git.

The information about where it comes from is below the ---. It's automatically send to me by kbuild, so I don't know anything more than that. I recall from the original message that the code was committed around an hour ago.

julia

Quoted 46 lines

Best regards,
Jacek Anaszewski

Quoted 40 lines · Julia Lawall

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

---

I haven't looked at the context in detail, but given the rule, I assume that there is an iterator, such as for_each_child_of_node, and these iterators do a put on each iteration, so none is needed in the loop body.

tree:   https://github.com/manabian/linux-lpc lpc18xx_43xx_devel
head:   9ee5f58bbb16c08da223c4b4933457e0eb72268d
commit: c58957273142be779f62c17fae389ce9c134139f [44/55] leds: pca9532: use
 leds-pca9532.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/leds/leds-pca9532.c +0 -3
@@ -473,7 +473,6 @@ pca9532_of_populate_pdata(struct device
 
 		res = of_property_read_u32(child, "reg", &reg);
 		if ((res != 0) || (reg >= maxleds)) {
-			of_node_put(child);
 			continue;
 		}
 
@@ -484,8 +483,6 @@ pca9532_of_populate_pdata(struct device
 		of_property_read_u32(child, "type", &pdata->leds[reg].type);
 		of_property_read_string(child, "linux,default-trigger",
 					&pdata->leds[reg].default_trigger);
-
-		of_node_put(child);
 	}
 
 	return pdata;
#3 lore raw
Quoted 6 lines · Julia Lawall
Quoted 2 lines · Jacek Anaszewski

Hi Julia,

Quoted 7 lines
Quoted 2 lines

This patch doesn't apply to current for-next branch of linux-leds.git.

The information about where it comes from is below the ---. It's automatically send to me by kbuild, so I don't know anything more than that. I recall from the original message that the code was committed around an hour ago.

In mainline as well as in linux-next we have only the following patch touching pca9532_of_populate_pdata() (it adds the function):

commit fa4191a609f219262a18dd8b02ab7dc30896b707

Author: Phil Reid <[email protected]>
Date:   Tue Jun 14 15:36:17 2016 +0800

leds: pca9532: Add device tree support

This patch adds basic device tree support for the pca9532 LEDs.

It doesn't have the problems the kbuild detected in
https://github.com/manabian/linux-lpc lpc18xx_43xx_devel. The git history for leds-pca9532.c in that repository is different from the one in mainline.

I don't see a point in reporting problems in repositories other than mainline or linux-next.

Best regards,
Jacek Anaszewski

Quoted 45 lines
Quoted 44 lines · Julia Lawall
Quoted 40 lines

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

---

I haven't looked at the context in detail, but given the rule, I assume that there is an iterator, such as for_each_child_of_node, and these iterators do a put on each iteration, so none is needed in the loop body.

tree:   https://github.com/manabian/linux-lpc lpc18xx_43xx_devel
head:   9ee5f58bbb16c08da223c4b4933457e0eb72268d
commit: c58957273142be779f62c17fae389ce9c134139f [44/55] leds: pca9532: use
 leds-pca9532.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/leds/leds-pca9532.c +0 -3
@@ -473,7 +473,6 @@ pca9532_of_populate_pdata(struct device
 
 		res = of_property_read_u32(child, "reg", &reg);
 		if ((res != 0) || (reg >= maxleds)) {
-			of_node_put(child);
 			continue;
 		}
 
@@ -484,8 +483,6 @@ pca9532_of_populate_pdata(struct device
 		of_property_read_u32(child, "type", &pdata->leds[reg].type);
 		of_property_read_string(child, "linux,default-trigger",
 					&pdata->leds[reg].default_trigger);
-
-		of_node_put(child);
 	}
 
 	return pdata;
Signature · 2 lines
Best regards,
Jacek Anaszewski
#4 lore raw
Quoted 30 lines · Jacek Anaszewski
Quoted 6 lines · Julia Lawall
Quoted 2 lines · Jacek Anaszewski

Hi Julia,

Quoted 7 lines
Quoted 2 lines

This patch doesn't apply to current for-next branch of linux-leds.git.

The information about where it comes from is below the ---. It's automatically send to me by kbuild, so I don't know anything more than that. I recall from the original message that the code was committed around an hour ago.

In mainline as well as in linux-next we have only the following patch touching pca9532_of_populate_pdata() (it adds the function):

commit fa4191a609f219262a18dd8b02ab7dc30896b707

Author: Phil Reid <[email protected]>
Date:   Tue Jun 14 15:36:17 2016 +0800

leds: pca9532: Add device tree support

This patch adds basic device tree support for the pca9532 LEDs.

Quoted 7 lines

It doesn't have the problems the kbuild detected in
https://github.com/manabian/linux-lpc lpc18xx_43xx_devel. The git history for leds-pca9532.c in that repository is different from the one in mainline.

I don't see a point in reporting problems in repositories other than mainline or linux-next.

I think you can let Fengguang know which trees you want monitored:

[email protected]

julia

Quoted 55 lines

Best regards,
Jacek Anaszewski

Quoted 40 lines
Quoted 40 lines · Julia Lawall
Quoted 38 lines

Device node iterators put the previous value of the index variable, so an explicit put causes a double put.

Generated by: scripts/coccinelle/iterators/device_node_continue.cocci

---

I haven't looked at the context in detail, but given the rule, I assume that there is an iterator, such as for_each_child_of_node, and these iterators do a put on each iteration, so none is needed in the loop body.

tree:   https://github.com/manabian/linux-lpc lpc18xx_43xx_devel
head:   9ee5f58bbb16c08da223c4b4933457e0eb72268d
commit: c58957273142be779f62c17fae389ce9c134139f [44/55] leds: pca9532: use
 leds-pca9532.c |    3 ---
 1 file changed, 3 deletions(-)
drivers/leds/leds-pca9532.c +0 -3
@@ -473,7 +473,6 @@ pca9532_of_populate_pdata(struct device
 
 		res = of_property_read_u32(child, "reg", &reg);
 		if ((res != 0) || (reg >= maxleds)) {
-			of_node_put(child);
 			continue;
 		}
 
@@ -484,8 +483,6 @@ pca9532_of_populate_pdata(struct device
 		of_property_read_u32(child, "type", &pdata->leds[reg].type);
 		of_property_read_string(child, "linux,default-trigger",
 					&pdata->leds[reg].default_trigger);
-
-		of_node_put(child);
 	}
 
Quoted 5 lines
Quoted 4 lines

drivers/leds/leds-pca9532.c pca9532_of_populate_pdata(struct device · line 488

Quoted 2 lines
drivers/leds/leds-pca9532.c +0 -0
 	return pdata;

--
Best regards,
Jacek Anaszewski