diff options
author | Daniel Thompson <daniel.thompson@linaro.org> | 2021-07-30 09:11:50 +0100 |
---|---|---|
committer | Daniel Thompson <daniel.thompson@linaro.org> | 2021-07-30 09:12:09 +0100 |
commit | 9bb0854dd87bdd8c491fe9e3bfa510d523b41259 (patch) | |
tree | 9a7022ec59894df2e71f63a1671d02adef9ea483 | |
parent | 2734d6c1b1a089fb593ef6a23d4b70903526fe0c (diff) |
scripts: coccinelle: allow list_entry_is_head() to use posmisc/coccinelle_allow_list_entry_is_head
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>
-rw-r--r-- | scripts/coccinelle/iterators/use_after_iter.cocci | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/scripts/coccinelle/iterators/use_after_iter.cocci b/scripts/coccinelle/iterators/use_after_iter.cocci index 9be48b520879..676edd562eef 100644 --- a/scripts/coccinelle/iterators/use_after_iter.cocci +++ b/scripts/coccinelle/iterators/use_after_iter.cocci @@ -123,6 +123,8 @@ hlist_for_each_entry_safe(c,...) S | list_remove_head(x,c,...) | +list_entry_is_head(c,...) +| sizeof(<+...c...+>) | &c->member |