Skip to content

Commit

Permalink
Silence -Wattribute-warning in zfs_log_xvattr()
Browse files Browse the repository at this point in the history
Silence the warnings about writing beyond the end of a the field.
In this instance the behavior is done intentionally and restructuring
the function would be disruptive for relatively little gain.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
  • Loading branch information
behlendorf committed Jun 21, 2022
1 parent 936a4e4 commit eadde04
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
23 changes: 23 additions & 0 deletions config/always-compiler-options.m4
Expand Up @@ -227,6 +227,29 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_INFINITE_RECURSION], [
AC_SUBST([INFINITE_RECURSION])
])

dnl #
dnl # Check if cc supports -Wattribute-warning.
dnl #
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_ATTRIBUTE_WARNING], [
AC_MSG_CHECKING([whether $CC supports -Wattribute-warning])
saved_flags="$CFLAGS"
CFLAGS="$CFLAGS -Werror -Wattribute-warning"
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
ATTRIBUTE_WARNING=-Wattribute-warning
AC_DEFINE([HAVE_ATTRIBUTE_WARNING], 1,
[Define if compiler supports -Wattribute-warning])
AC_MSG_RESULT([yes])
], [
ATTRIBUTE_WARNING=
AC_MSG_RESULT([no])
])
CFLAGS="$saved_flags"
AC_SUBST([ATTRIBUTE_WARNING])
])

dnl #
dnl # Check if cc supports -fno-omit-frame-pointer option.
dnl #
Expand Down
1 change: 1 addition & 0 deletions config/zfs-build.m4
Expand Up @@ -210,6 +210,7 @@ AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
AC_SUBST(CPU_COUNT)
ZFS_AC_CONFIG_ALWAYS_CC_NO_CLOBBERED
ZFS_AC_CONFIG_ALWAYS_CC_ATTRIBUTE_WARNING
ZFS_AC_CONFIG_ALWAYS_CC_INFINITE_RECURSION
ZFS_AC_CONFIG_ALWAYS_CC_IMPLICIT_FALLTHROUGH
ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
Expand Down
7 changes: 7 additions & 0 deletions module/zfs/zfs_log.c
Expand Up @@ -104,6 +104,10 @@ zfs_log_create_txtype(zil_create_t type, vsecattr_t *vsecp, vattr_t *vap)
* records a single 64 bit integer which has the bits to set on
* replay for the xvattr.
*/
#if defined(HAVE_ATTRIBUTE_WARNING)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wattribute-warning"
#endif
static void
zfs_log_xvattr(lr_attr_t *lrattr, xvattr_t *xvap)
{
Expand Down Expand Up @@ -189,6 +193,9 @@ zfs_log_xvattr(lr_attr_t *lrattr, xvattr_t *xvap)
*attrs |= (xoap->xoa_projinherit == 0) ? 0 :
XAT0_PROJINHERIT;
}
#if defined(HAVE_ATTRIBUTE_WARNING)
#pragma GCC diagnostic pop
#endif

static void *
zfs_log_fuid_ids(zfs_fuid_info_t *fuidp, void *start)
Expand Down

0 comments on commit eadde04

Please sign in to comment.