git: kern: Use __builtin_return_address(0) to fix -Warray-bounds warnings
Aaron LI
aly at crater.dragonflybsd.org
Tue Oct 13 04:50:40 PDT 2026
commit c5b78520dd7e00f2e2c8ca8de060e75cf17c0ce7
Author: Aaron LI <aly at aaronly.me>
Date: Tue Oct 13 10:47:50 2026 +0800
kern: Use __builtin_return_address(0) to fix -Warray-bounds warnings
Fix the following -Warray-bounds warnings from GCC 12.5:
```
In function '_lockmgr_assert',
inlined from 'lockmgr_shared' at /usr/src/sys/kern/kern_lock.c:117:2:
/usr/src/sys/kern/kern_lock.c:97:17: warning: array subscript -1 is outside array bounds of 'struct lock[0]' [-Warray-bounds]
97 | panic("lockmgr %s from %p: called from interrupt, ipi, "
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
98 | "or hard code section",
| ~~~~~~~~~~~~~~~~~~~~~~~
99 | lkp->lk_wmesg, ((int **)&lkp)[-1]);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/src/sys/kern/kern_slaballoc.c: In function 'kmem_slab_alloc':
/usr/src/sys/kern/kern_slaballoc.c:1750:9: warning: array subscript -1 is outside array bounds of 'vm_size_t[1]' {aka 'long unsigned int[1]'} [-Warray-bounds]
1750 | panic("kmem_slab_alloc: bad flags %08x (%p)",
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1751 | flags, ((int **)&size)[-1]);
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~
```
Summary of changes:
sys/kern/kern_lock.c | 2 +-
sys/kern/kern_slaballoc.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/c5b78520dd7e00f2e2c8ca8de060e75cf17c0ce7
--
DragonFly BSD source repository
More information about the Commits
mailing list