diff options
author | Tony Hutter <[email protected]> | 2017-06-28 10:05:16 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2017-06-28 10:05:16 -0700 |
commit | 682ce104cdd80db4b67eea09eb0a90324c5f98ee (patch) | |
tree | 3fa2067633f5c089685600f25601af0f791bfcaf /config | |
parent | cda0317e4d2a1277b328e4fc42ee3699bbe46c12 (diff) |
GCC 7.1 fixes
GCC 7.1 with will warn when we're not checking the snprintf()
return code in cases where the buffer could be truncated. This
patch either checks the snprintf return code (where applicable),
or simply disables the warnings (ztest.c).
Reviewed-by: Chunwei Chen <[email protected]>
Reviewed-by: Brian Behlendorf <[email protected]>
Signed-off-by: Tony Hutter <[email protected]>
Closes #6253
Diffstat (limited to 'config')
-rw-r--r-- | config/user-no-format-truncation.m4 | 22 | ||||
-rw-r--r-- | config/user.m4 | 1 |
2 files changed, 23 insertions, 0 deletions
diff --git a/config/user-no-format-truncation.m4 b/config/user-no-format-truncation.m4 new file mode 100644 index 000000000..4426907ee --- /dev/null +++ b/config/user-no-format-truncation.m4 @@ -0,0 +1,22 @@ +dnl # +dnl # Check if gcc supports -Wno-format-truncation option. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_NO_FORMAT_TRUNCATION], [ + AC_MSG_CHECKING([for -Wno-format-truncation support]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Wno-format-truncation" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], + [ + NO_FORMAT_TRUNCATION=-Wno-format-truncation + AC_MSG_RESULT([yes]) + ], + [ + NO_FORMAT_TRUNCATION= + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" + AC_SUBST([NO_FORMAT_TRUNCATION]) +]) diff --git a/config/user.m4 b/config/user.m4 index 079e2e73b..21ff7143a 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -17,6 +17,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_RUNSTATEDIR ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV + ZFS_AC_CONFIG_USER_NO_FORMAT_TRUNCATION ZFS_AC_TEST_FRAMEWORK |