Use _Noreturn (C11; GNU89) properly
commitdb7f1a91def6bbaf72dd3e9ad31255efb0bf81ab
authorAlejandro Colomar <Colomar.6.4.3@GMail.com>
Sat, 5 Mar 2022 00:25:22 +0000 (5 01:25 +0100)
committerGitHub <noreply@github.com>
Sat, 5 Mar 2022 00:25:22 +0000 (4 16:25 -0800)
tree1817651092cca3f549bf229436993cb10736706d
parent06b805067833902613de1871fa01e29fc80c8247
Use _Noreturn (C11; GNU89) properly

A function that returns with no value is a different thing from a
function that doesn't return at all.  Those are two orthogonal
concepts, commonly confused.

pthread_create(3) expects a pointer to a start routine that has a
very precise prototype:

    void *(*start_routine)(void *);

However, other thread functions, such as kernel ones, expect:

    void (*start_routine)(void *);

Providing a different one is incorrect, and has only been working
because the ABIs happen to produce a compatible function.

We should use '_Noreturn void', since it's the natural type, and
then provide a '_Noreturn void *' wrapper for pthread functions.

For consistency, replace most cases of __NORETURN or
__attribute__((noreturn)) by _Noreturn.  _Noreturn is understood
by -std=gnu89, so it should be safe to use everywhere.

Ref: https://github.com/openzfs/zfs/pull/13110#discussion_r808450136
Ref: https://software.codidact.com/posts/285972
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Co-authored-by: Ahelenia ZiemiaƄska <nabijaczleweli@nabijaczleweli.xyz>
Signed-off-by: Alejandro Colomar <alx.manpages@gmail.com>
Closes #13120
30 files changed:
cmd/raidz_test/raidz_test.c
cmd/zgenhostid/zgenhostid.c
cmd/zhack/zhack.c
cmd/ztest/ztest.c
config/always-compiler-options.m4
config/zfs-build.m4
include/libuutil.h
include/os/linux/spl/sys/thread.h
include/sys/zfs_context.h
lib/libspl/include/sys/feature_tests.h
lib/libuutil/uu_pname.c
lib/libzpool/Makefile.am
lib/libzpool/kernel.c
lib/libzpool/taskq.c
module/lua/ldo.c
module/zfs/arc.c
module/zfs/dbuf.c
module/zfs/dmu_recv.c
module/zfs/dmu_redact.c
module/zfs/dmu_send.c
module/zfs/mmp.c
module/zfs/spa.c
module/zfs/txg.c
module/zfs/vdev_initialize.c
module/zfs/vdev_rebuild.c
module/zfs/vdev_removal.c
module/zfs/vdev_trim.c
module/zfs/zthr.c
tests/zfs-tests/cmd/mkbusy/mkbusy.c
tests/zfs-tests/cmd/mkfile/mkfile.c