[Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr
willy at infradead.org
Mon Feb 28 20:16:23 UTC 2022
On Mon, Feb 28, 2022 at 12:10:24PM -0800, Linus Torvalds wrote:
> We can do
> typeof(pos) pos
> in the 'for ()' loop, and never use __iter at all.
> That means that inside the for-loop, we use a _different_ 'pos' than outside.
Then we can never use -Wshadow ;-( I'd love to be able to turn it on;
it catches real bugs.
> +#define list_for_each_entry(pos, head, member) \
> + for (typeof(pos) pos = list_first_entry(head, typeof(*pos), member); \
> + !list_entry_is_head(pos, head, member); \
> pos = list_next_entry(pos, member))
More information about the Intel-gfx