Skip to content

Commit

Permalink
Handle false array-bounds warning
Browse files Browse the repository at this point in the history
Signed-off-by: Paul Dagnelie <[email protected]>
  • Loading branch information
pcd1193182 committed Oct 10, 2024
1 parent 0ddbdfd commit 41aa23c
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions module/zfs/spa.c
Original file line number Diff line number Diff line change
Expand Up @@ -4867,8 +4867,26 @@ spa_load_chain_map(spa_t *spa)
KM_SLEEP);
for (zap_cursor_init(&zc, os, chain_map_zap);
zap_cursor_retrieve(&zc, &attr) == 0; zap_cursor_advance(&zc)) {

/*
* Workaround for GCC 12+ with UBSan enabled deficencies.
*
* GCC 12+ invoked with -fsanitize=undefined incorrectly reports
* the code below as violating -Warray-bounds
*/
#if defined(__GNUC__) && !defined(__clang__) && \
((!defined(_KERNEL) && defined(ZFS_UBSAN_ENABLED)) || \
defined(CONFIG_UBSAN))
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Warray-bounds"
#endif
uint64_t pool_guid = ((uint64_t *)attr.za_name)[0];
uint64_t os_guid = ((uint64_t *)attr.za_name)[1];
#if defined(__GNUC__) && !defined(__clang__) && \
((!defined(_KERNEL) && defined(ZFS_UBSAN_ENABLED)) || \
defined(CONFIG_UBSAN))
#pragma GCC diagnostic pop
#endif
error = zap_lookup_uint64(os, chain_map_zap,
(uint64_t *)attr.za_name, 2, sizeof (uint64_t),
sizeof (*szcmv) / sizeof (uint64_t),
Expand Down

0 comments on commit 41aa23c

Please sign in to comment.