Skip to content

Commit e71ec0b

Browse files
Daniel ThompsonJuliaLawall
authored andcommitted
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 <[email protected]> Signed-off-by: Julia Lawall <[email protected]>
1 parent 9eec079 commit e71ec0b

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

scripts/coccinelle/iterators/use_after_iter.cocci

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,8 @@ hlist_for_each_entry_safe(c,...) S
123123
|
124124
list_remove_head(x,c,...)
125125
|
126+
list_entry_is_head(c,...)
127+
|
126128
sizeof(<+...c...+>)
127129
|
128130
&c->member

0 commit comments

Comments
 (0)