Fix GCC 12 compilation errors

Squelch false positives reported by GCC 12 with UBSan.

Reviewed-by: Richard Yao <richard.yao@alumni.stonybrook.edu>
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: szubersk <szuberskidamian@gmail.com>
Closes #14150
This commit is contained in:
szubersk
2022-11-30 20:27:28 +10:00
committed by Brian Behlendorf
parent 3a6d89ae52
commit 3c1e1933b6
9 changed files with 125 additions and 4 deletions
+1 -1
View File
@@ -276,7 +276,7 @@ static size_t compress_parents_parallel(const blake3_ops_t *ops,
const uint8_t *child_chaining_values, size_t num_chaining_values,
const uint32_t key[8], uint8_t flags, uint8_t *out)
{
const uint8_t *parents_array[MAX_SIMD_DEGREE_OR_2];
const uint8_t *parents_array[MAX_SIMD_DEGREE_OR_2] = {0};
size_t parents_array_len = 0;
while (num_chaining_values - (2 * parents_array_len) >= 2) {
+2 -1
View File
@@ -170,7 +170,8 @@ static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
/*
* Silence infinite recursion warning which was added to -Wall in gcc 12.1
*/
#if defined(HAVE_INFINITE_RECURSION)
#if defined(__GNUC__) && !defined(__clang__) && \
defined(HAVE_KERNEL_INFINITE_RECURSION)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Winfinite-recursion"
#endif
+17
View File
@@ -229,7 +229,24 @@ zio_crypt_key_init(uint64_t crypt, zio_crypt_key_t *key)
ASSERT(key != NULL);
ASSERT3U(crypt, <, ZIO_CRYPT_FUNCTIONS);
/*
* 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
keydata_len = zio_crypt_table[crypt].ci_keylen;
#if defined(__GNUC__) && !defined(__clang__) && \
((!defined(_KERNEL) && defined(ZFS_UBSAN_ENABLED)) || \
defined(CONFIG_UBSAN))
#pragma GCC diagnostic pop
#endif
memset(key, 0, sizeof (zio_crypt_key_t));
rw_init(&key->zk_salt_lock, NULL, RW_DEFAULT, NULL);