git: ufs,ext2fs: Fix -Warray-bounds warnings from GCC 12.5
Aaron LI
aly at crater.dragonflybsd.org
Tue Oct 13 23:15:09 PDT 2026
commit 4fcf2e1bacc201e0111c60a5d2991eb19724949e
Author: Aaron LI <aly at aaronly.me>
Date: Wed Oct 14 12:28:42 2026 +0800
ufs,ext2fs: Fix -Warray-bounds warnings from GCC 12.5
The code of using 'struct dirtemplate' in ufs_dirempty() and
ext2_dirempty() was added in 1983 the 4.4BSD era, with the intention of
reducing stack use then [1]. However, this optimization is no longer
need now as we have larger stack space, so revert to use the real
'struct direct' or 'struct ext2fs_direct_2' to silence the warnings.
While there, adjust the MINDIRSIZ definition and rename 'count' to
'resid' to clean up the code a bit.
[1] cleanup dirempty to cut down on stack space used and speed up a tad
https://github.com/weiss/original-bsd/commit/de69dc11a62d21d77105282cc2d8b0cac21e1587
GCC 12.5 warnings example:
```
/usr/src/sys/vfs/ufs/ufs_lookup.c: In function 'ufs_dirempty':
/usr/src/sys/vfs/ufs/ufs_lookup.c:1076:23: warning: array subscript 'struct direct[0]' is partly outside array bounds of 'struct dirtemplate[1]' [-Warray-bounds]
1076 | if (dp->d_reclen == 0)
| ^~
/usr/src/sys/vfs/ufs/ufs_lookup.c:1061:28: note: object 'dbuf' of size 24
1061 | struct dirtemplate dbuf;
| ^~~~
```
Summary of changes:
sys/vfs/ext2fs/ext2_lookup.c | 15 ++++++---------
sys/vfs/ufs/ufs_lookup.c | 15 ++++++---------
2 files changed, 12 insertions(+), 18 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/4fcf2e1bacc201e0111c60a5d2991eb19724949e
--
DragonFly BSD source repository
More information about the Commits
mailing list