aboutsummaryrefslogtreecommitdiffstats
path: root/module/lua
diff options
context:
space:
mode:
authorRyan Libby <[email protected]>2020-12-15 09:20:48 -0800
committerGitHub <[email protected]>2020-12-15 09:20:48 -0800
commitd8a09b3a041c8983ce51106ae7f92a11142f8470 (patch)
treef6fdb3ee6cc2e68e5fe35e453a9236d4c7f8f3b9 /module/lua
parent956f94010f3163d7104d0674c9b0d7f68038702e (diff)
lua: avoid gcc -Wreturn-local-addr bug
Avoid a bug with gcc's -Wreturn-local-addr warning with some obfuscation. In buggy versions of gcc, if a return value is an expression that involves the address of a local variable, and even if that address is legally converted to a non-pointer type, a warning may be emitted and the value of the address may be replaced with zero. Howerver, buggy versions don't emit the warning or replace the value when simply returning a local variable of non-pointer type. https://gcc.gnu.org/bugzilla/show_bug.cgi?id=90737 Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Libby <[email protected]> Closes #11337
Diffstat (limited to 'module/lua')
-rw-r--r--module/lua/ldo.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/module/lua/ldo.c b/module/lua/ldo.c
index 0344a29fd..474fe659b 100644
--- a/module/lua/ldo.c
+++ b/module/lua/ldo.c
@@ -33,14 +33,16 @@
#if defined (_KERNEL) && defined(__linux__)
#include <asm/current.h>
static intptr_t stack_remaining(void) {
- char local;
- return (intptr_t)(&local - (char *)current->stack);
+ intptr_t local;
+ local = (intptr_t)&local - (intptr_t)current->stack;
+ return local;
}
#elif defined (_KERNEL) && defined(__FreeBSD__)
#include <sys/pcpu.h>
static intptr_t stack_remaining(void) {
- char local;
- return (intptr_t)(&local - (char *)curthread->td_kstack);
+ intptr_t local;
+ local = (intptr_t)&local - (intptr_t)curthread->td_kstack;
+ return local;
}
#else
static intptr_t stack_remaining(void) {