mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-21 18:26:47 +03:00
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
This commit is contained in:
committed by
GitHub
parent
06b8050678
commit
db7f1a91de
@@ -840,7 +840,7 @@ static kcondvar_t sem_cv;
|
||||
static int max_free_slots;
|
||||
static int free_slots;
|
||||
|
||||
static void
|
||||
static _Noreturn void
|
||||
sweep_thread(void *arg)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
#include <time.h>
|
||||
#include <unistd.h>
|
||||
|
||||
static __attribute__((noreturn)) void
|
||||
static _Noreturn void
|
||||
usage(void)
|
||||
{
|
||||
(void) fprintf(stderr,
|
||||
|
||||
+2
-2
@@ -57,7 +57,7 @@ static importargs_t g_importargs;
|
||||
static char *g_pool;
|
||||
static boolean_t g_readonly;
|
||||
|
||||
static __attribute__((noreturn)) void
|
||||
static _Noreturn void
|
||||
usage(void)
|
||||
{
|
||||
(void) fprintf(stderr,
|
||||
@@ -87,7 +87,7 @@ usage(void)
|
||||
}
|
||||
|
||||
|
||||
static __attribute__((noreturn)) __attribute__((format(printf, 3, 4))) void
|
||||
static __attribute__((format(printf, 3, 4))) _Noreturn void
|
||||
fatal(spa_t *spa, void *tag, const char *fmt, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
+5
-5
@@ -558,7 +558,7 @@ enum ztest_object {
|
||||
ZTEST_OBJECTS
|
||||
};
|
||||
|
||||
static void usage(boolean_t) __NORETURN;
|
||||
static _Noreturn void usage(boolean_t);
|
||||
static int ztest_scrub_impl(spa_t *spa);
|
||||
|
||||
/*
|
||||
@@ -622,7 +622,7 @@ static void sig_handler(int signo)
|
||||
|
||||
char *fatal_msg;
|
||||
|
||||
static __attribute__((noreturn)) __attribute__((format(printf, 2, 3))) void
|
||||
static __attribute__((format(printf, 2, 3))) _Noreturn void
|
||||
fatal(int do_perror, char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -6993,7 +6993,7 @@ ztest_resume(spa_t *spa)
|
||||
(void) zio_resume(spa);
|
||||
}
|
||||
|
||||
static void
|
||||
static _Noreturn void
|
||||
ztest_resume_thread(void *arg)
|
||||
{
|
||||
spa_t *spa = arg;
|
||||
@@ -7019,7 +7019,7 @@ ztest_resume_thread(void *arg)
|
||||
thread_exit();
|
||||
}
|
||||
|
||||
static void
|
||||
static _Noreturn void
|
||||
ztest_deadman_thread(void *arg)
|
||||
{
|
||||
ztest_shared_t *zs = arg;
|
||||
@@ -7097,7 +7097,7 @@ ztest_execute(int test, ztest_info_t *zi, uint64_t id)
|
||||
(double)functime / NANOSEC, zi->zi_funcname);
|
||||
}
|
||||
|
||||
static void
|
||||
static _Noreturn void
|
||||
ztest_thread(void *arg)
|
||||
{
|
||||
int rand;
|
||||
|
||||
Reference in New Issue
Block a user