[zfs-2.2.8] GCC: Fix array subscript check

Fix a zfs-2.2.8 GCC check on Fedora 42:

module/zfs/ddt.c:445:9: warning: array subscript -1 is below array
bounds of 'ddt_stat_t[64]' {aka 'struct ddt_stat[64]'} [-Warray-bounds=]
  445 |         ddt_stat_add(&ddh->ddh_stat[bucket], &dds, neg);

Signed-off-by: Tony Hutter <hutter2@llnl.gov>
This commit is contained in:
Tony Hutter 2025-05-27 15:34:43 -07:00
parent 5b93750f6f
commit 93af497120

View File

@ -438,7 +438,8 @@ ddt_stat_update(ddt_t *ddt, ddt_entry_t *dde, uint64_t neg)
ddt_stat_generate(ddt, dde, &dds);
bucket = highbit64(dds.dds_ref_blocks) - 1;
ASSERT(bucket >= 0);
if (unlikely(bucket >= 0)) /* if() needed for GCC bounds check */
ASSERT(bucket >= 0);
ddh = &ddt->ddt_histogram[dde->dde_type][dde->dde_class];