Switch from _Noreturn to __attribute__((noreturn))

Parts of the Linux kernel build system struggle with _Noreturn.  This
results in the following warnings when building on RHEL 8.5, and likely
other environments.  Switch to using the __attribute__((noreturn)).

  warning: objtool: dbuf_free_range()+0x2b8:
    return with modified stack frame
  warning: objtool: dbuf_free_range()+0x0:
    stack state mismatch: cfa1=7+40 cfa2=7+8
  ...
  WARNING: EXPORT symbol "arc_buf_size" [zfs.ko] version generation
    failed, symbol will not be versioned.
  WARNING: EXPORT symbol "spa_open" [zfs.ko] version generation
    failed, symbol will not be versioned.
  ...

Additionally, __thread_exit() has been renamed spl_thread_exit() and
made a static inline function.  This was needed because the kernel
will generate a warning for symbols which are __attribute__((noreturn))
and then exported with EXPORT_SYMBOL.

While we could continue to use _Noreturn in user space I've also
switched it to __attribute__((noreturn)) purely for consistency
throughout the code base.

Reviewed-by: Ryan Moeller <freqlabs@FreeBSD.org>
Reviewed-by: Brian Atkinson <batkinson@lanl.gov>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #13238
This commit is contained in:
Brian Behlendorf
2022-03-23 08:51:00 -07:00
committed by GitHub
parent b73505c7e0
commit 460748d4ae
29 changed files with 71 additions and 74 deletions
+1 -1
View File
@@ -839,7 +839,7 @@ static kcondvar_t sem_cv;
static int max_free_slots;
static int free_slots;
static _Noreturn void
static __attribute__((noreturn)) void
sweep_thread(void *arg)
{
int err = 0;
+1 -1
View File
@@ -499,7 +499,7 @@ usage_prop_cb(int prop, void *cb)
* that command. Otherwise, iterate over the entire command table and display
* a complete usage message.
*/
static _Noreturn void
static __attribute__((noreturn)) void
usage(boolean_t requested)
{
int i;
+1 -1
View File
@@ -36,7 +36,7 @@
#include <time.h>
#include <unistd.h>
static _Noreturn void
static __attribute__((noreturn)) void
usage(void)
{
(void) fprintf(stderr,
+2 -2
View File
@@ -57,7 +57,7 @@ static importargs_t g_importargs;
static char *g_pool;
static boolean_t g_readonly;
static _Noreturn void
static __attribute__((noreturn)) void
usage(void)
{
(void) fprintf(stderr,
@@ -87,7 +87,7 @@ usage(void)
}
static __attribute__((format(printf, 3, 4))) _Noreturn void
static __attribute__((format(printf, 3, 4))) __attribute__((noreturn)) void
fatal(spa_t *spa, void *tag, const char *fmt, ...)
{
va_list ap;
+1 -1
View File
@@ -518,7 +518,7 @@ print_vdev_prop_cb(int prop, void *cb)
* that command. Otherwise, iterate over the entire command table and display
* a complete usage message.
*/
static _Noreturn void
static __attribute__((noreturn)) void
usage(boolean_t requested)
{
FILE *fp = requested ? stdout : stderr;
+6 -6
View File
@@ -558,7 +558,7 @@ enum ztest_object {
ZTEST_OBJECTS
};
static _Noreturn void usage(boolean_t);
static __attribute__((noreturn)) void usage(boolean_t requested);
static int ztest_scrub_impl(spa_t *spa);
/*
@@ -622,7 +622,7 @@ static void sig_handler(int signo)
char *fatal_msg;
static __attribute__((format(printf, 2, 3))) _Noreturn void
static __attribute__((format(printf, 2, 3))) __attribute__((noreturn)) void
fatal(int do_perror, char *message, ...)
{
va_list args;
@@ -831,7 +831,7 @@ fini_options(void)
short_opts = NULL;
}
static void
static __attribute__((noreturn)) void
usage(boolean_t requested)
{
char option[80];
@@ -6994,7 +6994,7 @@ ztest_resume(spa_t *spa)
(void) zio_resume(spa);
}
static _Noreturn void
static __attribute__((noreturn)) void
ztest_resume_thread(void *arg)
{
spa_t *spa = arg;
@@ -7020,7 +7020,7 @@ ztest_resume_thread(void *arg)
thread_exit();
}
static _Noreturn void
static __attribute__((noreturn)) void
ztest_deadman_thread(void *arg)
{
ztest_shared_t *zs = arg;
@@ -7098,7 +7098,7 @@ ztest_execute(int test, ztest_info_t *zi, uint64_t id)
(double)functime / NANOSEC, zi->zi_funcname);
}
static _Noreturn void
static __attribute__((noreturn)) void
ztest_thread(void *arg)
{
int rand;