From 1b0de05f81372eeda9a2a38142553ead7e88a431 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Fri, 13 Oct 2023 08:59:42 -0500 Subject: [PATCH] LU-17193 build: fix gcc-12 compiler warnings MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Building on el9.2 hit a couple of new errors in configure, ex: ((struct inode_operations *)1)->fileattr_get() hits: error: array subscript 0 is outside array bounds of ‘struct inode_operations[0]’ A few instances of QCTL_COPY() should be QCTL_COPY_NO_PNAME() as the zero-length array to hold the pool name is not allocated in these cases. Signed-off-by: Shaun Tancheff Change-Id: I72bda8b46c51dbd42fb42bf569ba29572526acfe Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/52687 Tested-by: jenkins Tested-by: Maloo Reviewed-by: James Simmons Reviewed-by: xinliang Reviewed-by: Oleg Drokin --- lnet/autoconf/lustre-lnet.m4 | 3 --- lustre/autoconf/lustre-core.m4 | 36 ++++++++++++++------------- lustre/include/uapi/linux/lustre/lustre_idl.h | 20 ++++++++------- lustre/lmv/lmv_obd.c | 2 +- lustre/lov/lov_obd.c | 2 +- lustre/mdc/mdc_request.c | 2 +- 6 files changed, 33 insertions(+), 32 deletions(-) diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index c28c69a..bda97a5 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -1014,9 +1014,6 @@ AC_DEFUN([LN_SRC_HAVE_ORACLE_OFED_EXTENSIONS], [ .relaxed = 0 }; (void)param; - ],[ - AC_DEFINE(HAVE_ORACLE_OFED_EXTENSIONS, 1, - [if Oracle OFED Extensions are enabled]) ]) ]) AC_DEFUN([LN_HAVE_ORACLE_OFED_EXTENSIONS], [ diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index b6e673d..d71694c 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -778,9 +778,6 @@ AC_DEFUN([LC_SRC_VFS_RENAME_5ARGS], [ #include ],[ vfs_rename(NULL, NULL, NULL, NULL, NULL); - ], [ - AC_DEFINE(HAVE_VFS_RENAME_5ARGS, 1, - [kernel has vfs_rename with 5 args]) ]) ]) AC_DEFUN([LC_VFS_RENAME_5ARGS], [ @@ -3167,8 +3164,10 @@ AC_DEFUN([LC_SRC_HAVE_USER_NAMESPACE_ARG], [ LB2_LINUX_TEST_SRC([inode_ops_has_user_namespace_argument], [ #include ],[ - ((struct inode_operations *)1)->getattr((struct user_namespace *)NULL, - NULL, NULL, 0, 0); + struct inode_operations *iops = NULL; + struct user_namespace *user_ns = NULL; + + iops->getattr(user_ns, NULL, NULL, 0, 0); ],[-Werror]) ]) AC_DEFUN([LC_HAVE_USER_NAMESPACE_ARG], [ @@ -3189,19 +3188,21 @@ AC_DEFUN([LC_HAVE_USER_NAMESPACE_ARG], [ # first few iterations, so don't commit to a particular signature # here. Hopefully we will only want to support the final version. # -AC_DEFUN([LC_HAVE_FILEATTR_GET], [ -tmp_flags="$EXTRA_KCFLAGS" -EXTRA_KCFLAGS="-Werror" -LB_CHECK_COMPILE([if 'inode_operations' has fileattr_get (and fileattr_set)], -fileattr_set, [ - #include -],[ - ((struct inode_operations *)1)->fileattr_get(NULL, NULL); -],[ - AC_DEFINE(HAVE_FILEATTR_GET, 1, - ['inode_operations' has fileattr_get and fileattr_set]) +AC_DEFUN([LC_SRC_HAVE_FILEATTR_GET], [ + LB2_LINUX_TEST_SRC([fileattr_set], [ + #include + ],[ + struct inode_operations *iops = NULL; + iops->fileattr_get(NULL, NULL); + ],[-Werror]) ]) -EXTRA_KCFLAGS="$tmp_flags" +AC_DEFUN([LC_HAVE_FILEATTR_GET], [ + AC_MSG_CHECKING([if 'inode_operations' has fileattr_get (and fileattr_set)]) + LB2_LINUX_TEST_RESULT([fileattr_set], [ + AC_DEFINE(HAVE_FILEATTR_GET, 1, + ['inode_operations' has fileattr_get and fileattr_set]) + ]) + ]) # LC_HAVE_FILEATTR_GET # LC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC @@ -4194,6 +4195,7 @@ AC_DEFUN([LC_PROG_LINUX_SRC], [ # 5.13 LC_SRC_HAVE_COPY_PAGE_FROM_ITER_ATOMIC + LC_SRC_HAVE_FILEATTR_GET # 5.15 LC_SRC_HAVE_GET_ACL_RCU_ARG diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 044361a..d2eb486 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -1549,11 +1549,7 @@ struct obd_quotactl { #define Q_COPY(out, in, member) (out)->member = (in)->member -/* NOTE: - * - in and out maybe a type of struct if_quotactl or struct obd_quotactl - * - in and out need not be of the same type. - */ -#define __QCTL_COPY(out, in, need_pname) \ +#define QCTL_COPY_NO_PNAME(out, in) \ do { \ Q_COPY(out, in, qc_cmd); \ Q_COPY(out, in, qc_type); \ @@ -1561,7 +1557,16 @@ do { \ Q_COPY(out, in, qc_stat); \ Q_COPY(out, in, qc_dqinfo); \ Q_COPY(out, in, qc_dqblk); \ - if (need_pname && LUSTRE_Q_CMD_IS_POOL(in->qc_cmd)) { \ +} while (0) + +/* NOTE: + * - in and out maybe a type of struct if_quotactl or struct obd_quotactl + * - in and out need not be of the same type. + */ +#define QCTL_COPY(out, in) \ +do { \ + QCTL_COPY_NO_PNAME(out, in); \ + if (LUSTRE_Q_CMD_IS_POOL(in->qc_cmd)) { \ size_t len = strnlen(in->qc_poolname, LOV_MAXPOOLNAME); \ \ memcpy(out->qc_poolname, in->qc_poolname, len); \ @@ -1569,9 +1574,6 @@ do { \ } \ } while (0) -#define QCTL_COPY(out, in) __QCTL_COPY(out, in, true) -#define QCTL_COPY_NO_PNAME(out, in) __QCTL_COPY(out, in, false) - /* Body of quota request used for quota acquire/release RPCs between quota * master (aka QMT) and slaves (ak QSD). */ struct quota_body { diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 15ad904..8a6fb6c 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -957,7 +957,7 @@ static int lmv_iocontrol(unsigned int cmd, struct obd_export *exp, QCTL_COPY(oqctl, qctl); rc = obd_quotactl(tgt->ltd_exp, oqctl); if (rc == 0) { - QCTL_COPY(qctl, oqctl); + QCTL_COPY_NO_PNAME(qctl, oqctl); qctl->qc_valid = QC_MDTIDX; qctl->obd_uuid = tgt->ltd_uuid; } diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 1376bb7..1a49e77 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1076,7 +1076,7 @@ static int lov_iocontrol(unsigned int cmd, struct obd_export *exp, int len, QCTL_COPY(oqctl, qctl); rc = obd_quotactl(tgt->ltd_exp, oqctl); if (rc == 0) { - QCTL_COPY(qctl, oqctl); + QCTL_COPY_NO_PNAME(qctl, oqctl); qctl->qc_valid = QC_OSTIDX; qctl->obd_uuid = tgt->ltd_uuid; } diff --git a/lustre/mdc/mdc_request.c b/lustre/mdc/mdc_request.c index 8485fc5..dec052c 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -2283,7 +2283,7 @@ static int mdc_iocontrol(unsigned int cmd, struct obd_export *exp, int len, QCTL_COPY(oqctl, qctl); rc = obd_quotactl(exp, oqctl); if (rc == 0) { - QCTL_COPY(qctl, oqctl); + QCTL_COPY_NO_PNAME(qctl, oqctl); qctl->qc_valid = QC_MDTIDX; qctl->obd_uuid = obd->u.cli.cl_target_uuid; } -- 1.8.3.1