Re: [RFC 2/3] headers: introduce linux/struct_types.h

From: Arnd Bergmann
Date: Tue Dec 07 2021 - 12:07:36 EST


On Tue, Dec 7, 2021 at 4:32 PM Matthew Wilcox <willy@xxxxxxxxxxxxx> wrote:

> > #define __SWAITQUEUE_INITIALIZER(name) { \
> > .task = current, \
> > .task_list = LIST_HEAD_INIT((name).task_list), \
>
> swait.h doesn't need to include <linux/struct_types.h> ?

I should probably add it for consistency, also in some other places.
At the moment it works without that because the new header is pulled
in through linux/spinlock.h.

> > -
> > #define XARRAY_INIT(name, flags) { \
> > .xa_lock = __SPIN_LOCK_UNLOCKED(name.xa_lock), \
> > .xa_flags = flags, \
>
> I think this is going to break:
>
> (cd tools/testing/radix-tree; make)

I've tried addressing this now, but I first ran into a different problem
that exists in linux-next but not in mainline as of today:

cc -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address
-fsanitize=undefined -c -o main.o main.c
In file included from ./linux/xarray.h:2,
from ./linux/../../../../include/linux/radix-tree.h:21,
from ./linux/radix-tree.h:5,
from main.c:10:
./linux/../../../../include/linux/xarray.h: In function ‘xas_find_chunk’:
./linux/../../../../include/linux/xarray.h:1669:9: warning: implicit
declaration of function ‘find_next_bit’
[-Wimplicit-function-declaration]
1669 | return find_next_bit(addr, XA_CHUNK_SIZE, offset);
| ^~~~~~~~~~~~~
cc -I. -I../../include -g -Og -Wall -D_LGPL_SOURCE -fsanitize=address
-fsanitize=undefined -c -o xarray.o xarray.c
In file included from ./linux/xarray.h:2,
from ./linux/../../../../include/linux/radix-tree.h:21,
from ./linux/radix-tree.h:5,
from test.h:4,
from xarray.c:8:
./linux/../../../../include/linux/xarray.h: In function ‘xas_find_chunk’:
./linux/../../../../include/linux/xarray.h:1669:9: warning: implicit
declaration of function ‘find_next_bit’
[-Wimplicit-function-declaration]
1669 | return find_next_bit(addr, XA_CHUNK_SIZE, offset);
| ^~~~~~~~~~~~~
In file included from ../../include/linux/bitmap.h:7,
from ../../../lib/xarray.c:9,
from xarray.c:16:
../../include/linux/find.h: At top level:
../../include/linux/find.h:31:15: error: conflicting types for ‘find_next_bit’
31 | unsigned long find_next_bit(const unsigned long *addr,
unsigned long size,
| ^~~~~~~~~~~~~
In file included from ./linux/xarray.h:2,
from ./linux/../../../../include/linux/radix-tree.h:21,
from ./linux/radix-tree.h:5,
from test.h:4,
from xarray.c:8:
./linux/../../../../include/linux/xarray.h:1669:9: note: previous
implicit declaration of ‘find_next_bit’ was here
1669 | return find_next_bit(addr, XA_CHUNK_SIZE, offset);
| ^~~~~~~~~~~~~
make: *** [<builtin>: xarray.o] Error 1

It's clearly broken after Yury's recent bitops.h cleanup, but I can't
quite find my way
through the maze of tools/testing headers to fix it.

Arnd