Re: [Intel-gfx] [PATCH 2/6] treewide: remove using list iterator after loop body as a ptr

Johannes Berg
2022-02-28T20:28:40Z

On Mon, 2022-02-28 at 20:16 +0000, Matthew Wilcox wrote:
> 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.
>

I was just going to say the same thing...

If we're willing to change the API for the macro, we could do

list_for_each_entry(type, pos, head, member)

and then actually take advantage of -Wshadow?

johannes