Skip to content

Commit 908514f

Browse files
committed
Fix GCC and Clang errors on Ubuntu 22.10
Make the code compile on Ubuntu Kinetic. - Clang 15 doesn't support `-fno-ipa-sra` anymore. - Squelch false positives. Signed-off-by: szubersk <[email protected]>
1 parent c23738c commit 908514f

File tree

8 files changed

+63
-4
lines changed

8 files changed

+63
-4
lines changed

cmd/zfs/zfs_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ usage(boolean_t requested)
548548
show_properties = B_TRUE;
549549

550550
if (show_properties) {
551-
(void) fprintf(fp,
551+
(void) fprintf(fp, "%s",
552552
gettext("\nThe following properties are supported:\n"));
553553

554554
(void) fprintf(fp, "\n\t%-14s %s %s %s\n\n",

cmd/zpool/zpool_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -548,7 +548,7 @@ usage(boolean_t requested)
548548
(strcmp(current_command->name, "get") == 0) ||
549549
(strcmp(current_command->name, "list") == 0))) {
550550

551-
(void) fprintf(fp,
551+
(void) fprintf(fp, "%s",
552552
gettext("\nthe following properties are supported:\n"));
553553

554554
(void) fprintf(fp, "\n\t%-19s %s %s\n\n",

config/always-compiler-options.m4

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,3 +268,33 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA], [
268268
CFLAGS="$saved_flags"
269269
AC_SUBST([NO_IPA_SRA])
270270
])
271+
272+
dnl #
273+
dnl # Check if kernel cc supports -fno-ipa-sra option.
274+
dnl #
275+
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA], [
276+
AC_MSG_CHECKING([whether $KERNEL_CC supports -fno-ipa-sra])
277+
278+
saved_cc="$CC"
279+
saved_flags="$CFLAGS"
280+
CFLAGS="$CFLAGS -Werror -fno-ipa-sra"
281+
282+
AS_IF([ test -n "$KERNEL_CC" ], [
283+
CC="$KERNEL_CC"
284+
])
285+
AS_IF([ test -n "$KERNEL_LLVM" ], [
286+
CC="clang"
287+
])
288+
289+
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
290+
KERNEL_NO_IPA_SRA=-fno-ipa-sra
291+
AC_MSG_RESULT([yes])
292+
], [
293+
KERNEL_NO_IPA_SRA=
294+
AC_MSG_RESULT([no])
295+
])
296+
297+
CC="$saved_cc"
298+
CFLAGS="$saved_flags"
299+
AC_SUBST([NO_IPA_SRA])
300+
])

config/zfs-build.m4

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ AC_DEFUN([ZFS_AC_DEBUG], [
8181
AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [
8282
DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline $NO_IPA_SRA"
8383
84-
KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline $NO_IPA_SRA"
84+
KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline $KERNEL_NO_IPA_SRA"
8585
KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y"
8686
8787
DEBUGINFO_ZFS="_with_debuginfo"
@@ -217,6 +217,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
217217
ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_ZERO_LENGTH
218218
ZFS_AC_CONFIG_ALWAYS_CC_NO_OMIT_FRAME_POINTER
219219
ZFS_AC_CONFIG_ALWAYS_CC_NO_IPA_SRA
220+
ZFS_AC_CONFIG_ALWAYS_KERNEL_CC_NO_IPA_SRA
220221
ZFS_AC_CONFIG_ALWAYS_CC_ASAN
221222
ZFS_AC_CONFIG_ALWAYS_CC_UBSAN
222223
ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD

lib/libnvpair/libnvpair.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ nvprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
199199
return (1); \
200200
}
201201

202+
#if defined(__GNUC__) && !defined(__clang__)
203+
#pragma GCC diagnostic push
204+
#pragma GCC diagnostic ignored "-Wformat-overflow"
205+
#endif
202206
NVLIST_PRTFUNC(boolean, int, int, "%d")
203207
NVLIST_PRTFUNC(boolean_value, boolean_t, int, "%d")
204208
NVLIST_PRTFUNC(byte, uchar_t, uchar_t, "0x%2.2x")
@@ -213,6 +217,9 @@ NVLIST_PRTFUNC(uint64, uint64_t, u_longlong_t, "0x%llx")
213217
NVLIST_PRTFUNC(double, double, double, "0x%f")
214218
NVLIST_PRTFUNC(string, char *, char *, "%s")
215219
NVLIST_PRTFUNC(hrtime, hrtime_t, hrtime_t, "0x%llx")
220+
#if defined(__GNUC__) && !defined(__clang__)
221+
#pragma GCC diagnostic pop
222+
#endif
216223

217224
/*
218225
* Generate functions to print array-valued nvlist members.

lib/libzfs/libzfs_sendrecv.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1007,8 +1007,15 @@ send_print_verbose(FILE *fout, const char *tosnap, const char *fromsnap,
10071007
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
10081008
"incremental\t%s\t%s"), fromsnap, tosnap);
10091009
} else {
1010+
#if defined(__GNUC__) && !defined(__clang__)
1011+
#pragma GCC diagnostic push
1012+
#pragma GCC diagnostic ignored "-Wformat-overflow"
1013+
#endif
10101014
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
10111015
"full\t%s"), tosnap);
1016+
#if defined(__GNUC__) && !defined(__clang__)
1017+
#pragma GCC diagnostic pop
1018+
#endif
10121019
}
10131020
(void) fprintf(fout, "\t%llu", (longlong_t)size);
10141021
} else {
@@ -1028,8 +1035,15 @@ send_print_verbose(FILE *fout, const char *tosnap, const char *fromsnap,
10281035
if (size != 0) {
10291036
char buf[16];
10301037
zfs_nicebytes(size, buf, sizeof (buf));
1038+
#if defined(__GNUC__) && !defined(__clang__)
1039+
#pragma GCC diagnostic push
1040+
#pragma GCC diagnostic ignored "-Wformat-overflow"
1041+
#endif
10311042
(void) fprintf(fout, dgettext(TEXT_DOMAIN,
10321043
" estimated size is %s"), buf);
1044+
#if defined(__GNUC__) && !defined(__clang__)
1045+
#pragma GCC diagnostic pop
1046+
#endif
10331047
}
10341048
}
10351049
(void) fprintf(fout, "\n");

module/icp/algs/blake3/blake3.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ static size_t compress_parents_parallel(const blake3_ops_t *ops,
276276
const uint8_t *child_chaining_values, size_t num_chaining_values,
277277
const uint32_t key[8], uint8_t flags, uint8_t *out)
278278
{
279-
const uint8_t *parents_array[MAX_SIMD_DEGREE_OR_2];
279+
const uint8_t *parents_array[MAX_SIMD_DEGREE_OR_2] = {0};
280280
size_t parents_array_len = 0;
281281

282282
while (num_chaining_values - (2 * parents_array_len) >= 2) {

module/os/linux/zfs/zio_crypt.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,14 @@ zio_crypt_key_init(uint64_t crypt, zio_crypt_key_t *key)
229229
ASSERT(key != NULL);
230230
ASSERT3U(crypt, <, ZIO_CRYPT_FUNCTIONS);
231231

232+
#if defined(__GNUC__) && !defined(__clang__)
233+
#pragma GCC diagnostic push
234+
#pragma GCC diagnostic ignored "-Warray-bounds"
235+
#endif
232236
keydata_len = zio_crypt_table[crypt].ci_keylen;
237+
#if defined(__GNUC__) && !defined(__clang__)
238+
#pragma GCC diagnostic pop
239+
#endif
233240
memset(key, 0, sizeof (zio_crypt_key_t));
234241
rw_init(&key->zk_salt_lock, NULL, RW_DEFAULT, NULL);
235242

0 commit comments

Comments
 (0)