From a78894ee642d423a244fc0dcbc518c57a458a2db Mon Sep 17 00:00:00 2001 From: Jian Yu Date: Sat, 10 Aug 2024 00:07:59 -0700 Subject: [PATCH] LU-18127 autoconf: fix configure tests -Warray-bounds errors Kernel commit v5.17-rc3-1-ge6148767825c (Makefile: Enable -Warray-bounds) enabled -Warray-bounds option, which caused Lustre configure tests hit false failures as follows: build/conftest.c: In function 'main': build/conftest.c:228:39: error: array subscript 0 is outside array bounds of 'struct inode_operations[0]' [-Werror=array-bounds] 228 | ((struct inode_operations *)1)->get_acl((struct inode *)NULL, 0, false); | ^~ cc1: all warnings being treated as errors This patch fixes the "struct inode_operations" related configure tests to avoid the above failures. The -Warray-bounds option was disabled by the following kernel commits: - v5.19-rc1-28-gf0be87c42cbd (gcc-12: disable '-Warray-bounds' universally for now) - v6.2-rc3-9-g5a41237ad1d4 (gcc: disable -Warray-bounds for gcc-11 too) - v6.3-rc7-202-g0da6e5fd6c37 (gcc: disable '-Warray-bounds' for gcc-13 too) Test-Parameters: mdtcount=4 mdscount=2 \ clientdistro=ubuntu2204 testlist=sanity Test-Parameters: mdtcount=4 mdscount=2 \ env=SANITY_EXCEPT="27J 103a 244a" \ clientdistro=sles15sp6 testlist=sanity Test-Parameters: optional mdtcount=4 mdscount=2 \ clientdistro=ubuntu2404 testlist=sanity Change-Id: Iee73962ffc117a2f98e8f339462820aff2278815 Signed-off-by: Jian Yu Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/55989 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Qian Yingjin Reviewed-by: Oleg Drokin --- lustre/autoconf/lustre-core.m4 | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index d1ca415..49ba06b 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -923,10 +923,11 @@ AC_DEFUN([LC_SRC_IOPS_RENAME_WITH_FLAGS], [ LB2_LINUX_TEST_SRC([iops_rename_with_flags], [ #include ],[ + struct inode_operations *iops = NULL; struct inode *i1 = NULL, *i2 = NULL; struct dentry *d1 = NULL, *d2 = NULL; - int rc; - rc = ((struct inode_operations *)0)->rename(i1, d1, i2, d2, 0); + + iops->rename(i1, d1, i2, d2, 0); ]) ]) # LC_IOPS_RENAME_WITH_FLAGS AC_DEFUN([LC_IOPS_RENAME_WITH_FLAGS], [ @@ -1391,10 +1392,11 @@ AC_DEFUN([LC_SRC_SYMLINK_OPS_USE_NAMEIDATA], [ #include #include ],[ + struct inode_operations *iops = NULL; struct nameidata *nd = NULL; - ((struct inode_operations *)0)->follow_link(NULL, nd); - ((struct inode_operations *)0)->put_link(NULL, nd, NULL); + iops->follow_link(NULL, nd); + iops->put_link(NULL, nd, NULL); ]) ]) AC_DEFUN([LC_SYMLINK_OPS_USE_NAMEIDATA], [ @@ -2262,9 +2264,10 @@ AC_DEFUN([LC_SRC_INODEOPS_ENHANCED_GETATTR], [ LB2_LINUX_TEST_SRC([getattr_path], [ #include ],[ + struct inode_operations *iops = NULL; struct path path; - ((struct inode_operations *)1)->getattr(&path, NULL, 0, 0); + iops->getattr(&path, NULL, 0, 0); ]) ]) AC_DEFUN([LC_INODEOPS_ENHANCED_GETATTR], [ @@ -3323,7 +3326,9 @@ AC_DEFUN([LC_SRC_HAVE_GET_ACL_RCU_ARG], [ LB2_LINUX_TEST_SRC([get_acl_rcu_argument], [ #include ],[ - ((struct inode_operations *)1)->get_acl((struct inode *)NULL, 0, false); + struct inode_operations *iops = NULL; + + iops->get_acl((struct inode *)NULL, 0, false); ],[-Werror]) ]) AC_DEFUN([LC_HAVE_GET_ACL_RCU_ARG], [ @@ -4095,9 +4100,10 @@ AC_DEFUN([LC_SRC_HAVE_ACL_WITH_DENTRY], [ LB2_LINUX_TEST_SRC([acl_with_dentry], [ #include ],[ + struct inode_operations *iops = NULL; struct dentry *dentry = NULL; - ((struct inode_operations *)1)->get_acl(NULL, dentry, 0); + iops->get_acl(NULL, dentry, 0); (void)dentry; ],[-Werror]) ]) @@ -4145,8 +4151,9 @@ AC_DEFUN([LC_SRC_HAVE_MNT_IDMAP_ARG], [ #include #include ],[ - ((struct inode_operations *)1)->getattr((struct mnt_idmap *)NULL, - NULL, NULL, 0, 0); + struct inode_operations *iops = NULL; + + iops->getattr((struct mnt_idmap *)NULL, NULL, NULL, 0, 0); ],[-Werror]) ]) AC_DEFUN([LC_HAVE_MNT_IDMAP_ARG], [ -- 1.8.3.1