Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clang warnings during complilation of 2.3.0-rc2 with 6.11.3 #16660

Closed
kentdobias opened this issue Oct 17, 2024 · 1 comment · Fixed by #16665
Closed

Clang warnings during complilation of 2.3.0-rc2 with 6.11.3 #16660

kentdobias opened this issue Oct 17, 2024 · 1 comment · Fixed by #16665
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)

Comments

@kentdobias
Copy link
Contributor

System information

Type Version/Name
Distribution Name Arch Linux
Distribution Version
Kernel Version 6.11.3
Architecture x86_64
OpenZFS Version 2.3.0-rc2

Describe the problem you're observing

When building the linux kernel using clang and with zfs bult-in, there are many warnings relating to type redefinitions and casts. These don't cause build errors, everything functions fine, but kernel builds are best when they are quiet.

Include any warning/errors/backtraces from the system logs

These patterns of type redefinition involving kstat_t and abd_t appear in many files, one example:

In file included from fs/zfs/zfs/dmu_object.c:27:
In file included from ./include/zfs/sys/dbuf.h:31:
In file included from ./include/zfs/sys/dmu.h:46:
In file included from ./include/zfs/sys/zfs_context.h:64:
./include/zfs/os/linux/spl/sys/kstat.h:82:24: warning: redefinition of typedef 'kstat_t' is a C11 feature [-Wtypedef-redefinition]
   82 | typedef struct kstat_s kstat_t;
      |                        ^
./include/zfs/os/linux/spl/sys/taskq.h:42:24: note: previous definition is here
   42 | typedef struct kstat_s kstat_t;
      |                        ^
In file included from fs/zfs/zfs/dmu_object.c:27:
In file included from ./include/zfs/sys/dbuf.h:31:
In file included from ./include/zfs/sys/dmu.h:50:
In file included from ./include/zfs/sys/zio_compress.h:34:
./include/zfs/sys/abd.h:68:3: warning: redefinition of typedef 'abd_t' is a C11 feature [-Wtypedef-redefinition]
   68 | } abd_t;
      |   ^
./include/zfs/os/linux/zfs/sys/abd_os.h:44:20: note: previous definition is here
   44 | typedef struct abd abd_t;
      |                    ^

This pattern of casting appears in many files, one example:

fs/zfs/zfs/spa.c:9200:27: warning: cast from 'void (*)(void *) __attribute__((noreturn))' to 'thread_func_t' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict]
 9200 |                 spa->spa_async_thread = thread_create(NULL, 0,
      |                                         ^~~~~~~~~~~~~~~~~~~~~~
 9201 |                     spa_async_thread, spa, 0, &p0, TS_RUN, maxclsyspri);
      |                     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./include/zfs/os/linux/spl/sys/thread.h:53:32: note: expanded from macro 'thread_create'
   53 |         __thread_create(stk, stksize, (thread_func_t)func, #func,       \
      |                                       ^~~~~~~~~~~~~~~~~~~
@kentdobias kentdobias added the Type: Defect Incorrect behavior (e.g. crash, hang) label Oct 17, 2024
@Harry-Chen
Copy link
Contributor

AFAIK Linux starts to use -std=gnu11 from 5.15. So I am curious why clang would complain that something "is a C11 feature".

kusumi added a commit to kusumi/zfs that referenced this issue Oct 19, 2024
Some compiler/versions warn these typedefs according to openzfs#16660.

The platform specific header sys/abd_os.h shouldn't define or use abd_t,
as it's defined in its non-platform specific consumer sys/abd.h.
Do the same as what FreeBSD header does.

Signed-off-by: Tomohiro Kusumi <[email protected]>
kusumi added a commit to kusumi/zfs that referenced this issue Oct 19, 2024
Some compiler/versions warn these typedefs according to openzfs#16660.

The platform specific header sys/abd_os.h shouldn't define or use abd_t,
as it's defined in its non-platform specific consumer sys/abd.h.
Do the same as what FreeBSD header does.

Closes: openzfs#16660

Signed-off-by: Tomohiro Kusumi <[email protected]>
kusumi added a commit to kusumi/zfs that referenced this issue Oct 19, 2024
Some compiler/versions warn these typedefs according to openzfs#16660.

The platform specific header sys/abd_os.h shouldn't define or use abd_t,
as it's defined in its non-platform specific consumer sys/abd.h.
Do the same as what FreeBSD header does.

Signed-off-by: Tomohiro Kusumi <[email protected]>
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Oct 21, 2024
Some compiler/versions warn these typedefs according to openzfs#16660.

The platform specific header sys/abd_os.h shouldn't define or use abd_t,
as it's defined in its non-platform specific consumer sys/abd.h.
Do the same as what FreeBSD header does.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes openzfs#16660 
Closes openzfs#16665
behlendorf pushed a commit to behlendorf/zfs that referenced this issue Oct 21, 2024
Some compiler/versions warn these typedefs according to openzfs#16660.

The platform specific header sys/abd_os.h shouldn't define or use abd_t,
as it's defined in its non-platform specific consumer sys/abd.h.
Do the same as what FreeBSD header does.

Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tomohiro Kusumi <[email protected]>
Closes openzfs#16660 
Closes openzfs#16665
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Defect Incorrect behavior (e.g. crash, hang)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants