diff options
author | Alejandro Colomar <[email protected]> | 2022-03-05 01:25:22 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2022-03-04 16:25:22 -0800 |
commit | db7f1a91def6bbaf72dd3e9ad31255efb0bf81ab (patch) | |
tree | 1817651092cca3f549bf229436993cb10736706d /tests/zfs-tests | |
parent | 06b805067833902613de1871fa01e29fc80c8247 (diff) |
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 <[email protected]>
Co-authored-by: Ahelenia ZiemiaĆska <[email protected]>
Signed-off-by: Alejandro Colomar <[email protected]>
Closes #13120
Diffstat (limited to 'tests/zfs-tests')
-rw-r--r-- | tests/zfs-tests/cmd/mkbusy/mkbusy.c | 4 | ||||
-rw-r--r-- | tests/zfs-tests/cmd/mkfile/mkfile.c | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/tests/zfs-tests/cmd/mkbusy/mkbusy.c b/tests/zfs-tests/cmd/mkbusy/mkbusy.c index 50a4f90a2..c32f1ecdc 100644 --- a/tests/zfs-tests/cmd/mkbusy/mkbusy.c +++ b/tests/zfs-tests/cmd/mkbusy/mkbusy.c @@ -31,14 +31,14 @@ #include <string.h> -static __attribute__((noreturn)) void +static _Noreturn void usage(char *progname) { (void) fprintf(stderr, "Usage: %s <dirname|filename>\n", progname); exit(1); } -static __attribute__((noreturn)) void +static _Noreturn void fail(char *err) { perror(err); diff --git a/tests/zfs-tests/cmd/mkfile/mkfile.c b/tests/zfs-tests/cmd/mkfile/mkfile.c index 673cbf9e0..f59a01efa 100644 --- a/tests/zfs-tests/cmd/mkfile/mkfile.c +++ b/tests/zfs-tests/cmd/mkfile/mkfile.c @@ -44,7 +44,7 @@ #define FILE_MODE (S_ISVTX + S_IRUSR + S_IWUSR) -static void usage(void) __attribute__((noreturn)); +static _Noreturn void usage(void); int main(int argc, char **argv) |