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
+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;