diff options
author | Ryan Libby <rlibby@FreeBSD.org> | 2020-12-27 22:33:13 +0000 |
---|---|---|
committer | Ryan Libby <rlibby@FreeBSD.org> | 2020-12-27 22:33:13 +0000 |
commit | f2d48b5e2c3b45850585e4d7aee324fe148afbf2 (patch) | |
tree | 575fd83a58075e72409549a59660856616726ab9 /sys/contrib/openzfs/module/lua | |
parent | 21ce674e3c7e9dad485b0d84634616f0b535a17f (diff) | |
download | src-f2d48b5e2c3b45850585e4d7aee324fe148afbf2.tar.gz src-f2d48b5e2c3b45850585e4d7aee324fe148afbf2.zip |
Merge commit d8a09b3a0 from openzfs git (by Ryan Libby):
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 <behlendorf1@llnl.gov>
Signed-off-by: Ryan Libby <rlibby@FreeBSD.org>
Closes #11337
Diffstat (limited to 'sys/contrib/openzfs/module/lua')
-rw-r--r-- | sys/contrib/openzfs/module/lua/ldo.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sys/contrib/openzfs/module/lua/ldo.c b/sys/contrib/openzfs/module/lua/ldo.c index 0344a29fd8e8..474fe659bcef 100644 --- a/sys/contrib/openzfs/module/lua/ldo.c +++ b/sys/contrib/openzfs/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) { |