]> git.baikalelectronics.ru Git - kernel.git/commit
scripts: coccinelle: allow list_entry_is_head() to use pos
authorDaniel Thompson <daniel.thompson@linaro.org>
Fri, 30 Jul 2021 09:58:56 +0000 (10:58 +0100)
committerJulia Lawall <Julia.Lawall@inria.fr>
Sun, 8 Aug 2021 20:00:49 +0000 (22:00 +0200)
commit57cb3d4e5bb9c7da890ffbbc607e3fcde525829a
tree3062144ec12a5861928345dabad8431690259217
parentdd68a8be605f9ea31b3dbd131b33443a9f2f45da
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>
scripts/coccinelle/iterators/use_after_iter.cocci