linux/scripts/coccinelle/iterators
Daniel Thompson e71ec0bc06 scripts: coccinelle: allow list_entry_is_head() to use pos
Currently use_after_iter.cocci generates false positives for code of the
following form:
~~~
	list_for_each_entry(d, &ddata->irq_list, node) {
		if (irq == d->irq)
			break;
	}

	if (list_entry_is_head(d, &ddata->irq_list, node))
		return IRQ_NONE;
~~~
[This specific example comes from drivers/power/supply/cpcap-battery.c]

Most list macros use list_entry_is_head() as loop exit condition meaning it
is not unsafe to reuse pos (a.k.a. d) in the code above.

Let's avoid reporting these cases.

Signed-off-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Julia Lawall <Julia.Lawall@inria.fr>
2021-08-08 22:00:49 +02:00
..
device_node_continue.cocci treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505 2019-06-19 17:11:22 +02:00
fen.cocci treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505 2019-06-19 17:11:22 +02:00
for_each_child.cocci coccinelle: iterators: Add for_each_child.cocci script 2020-10-15 22:28:10 +02:00
itnull.cocci treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505 2019-06-19 17:11:22 +02:00
list_entry_update.cocci treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 505 2019-06-19 17:11:22 +02:00
use_after_iter.cocci scripts: coccinelle: allow list_entry_is_head() to use pos 2021-08-08 22:00:49 +02:00