From 542d90e4b1403e0f1f6be13a1980b276a61e245f Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Wed, 25 Oct 2023 18:00:40 -0700 Subject: [PATCH] LU-17193 build: fix gcc-12 compiler warnings 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. Lustre-change: https://review.whamcloud.com/c/fs/lustre-release/+/52687 Lustre-commit: 1b0de05f81372eeda9a2a38142553ead7e88a431 Signed-off-by: Shaun Tancheff Change-Id: I72bda8b46c51dbd42fb42bf569ba29572526acfe Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/52834 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/autoconf/lustre-core.m4 | 9 ++++----- 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 +- 5 files changed, 18 insertions(+), 17 deletions(-) diff --git a/lustre/autoconf/lustre-core.m4 b/lustre/autoconf/lustre-core.m4 index f98b7b6..b3f67f3 100644 --- a/lustre/autoconf/lustre-core.m4 +++ b/lustre/autoconf/lustre-core.m4 @@ -748,9 +748,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], [ @@ -2916,8 +2913,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], [ diff --git a/lustre/include/uapi/linux/lustre/lustre_idl.h b/lustre/include/uapi/linux/lustre/lustre_idl.h index 3e592a6..462e9a4 100644 --- a/lustre/include/uapi/linux/lustre/lustre_idl.h +++ b/lustre/include/uapi/linux/lustre/lustre_idl.h @@ -1553,11 +1553,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); \ @@ -1565,7 +1561,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); \ @@ -1573,9 +1578,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 ab36f63..d6e0f13 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -942,7 +942,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 670993a..da5256a 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -1113,7 +1113,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 7961ce2..67d16e3 100644 --- a/lustre/mdc/mdc_request.c +++ b/lustre/mdc/mdc_request.c @@ -2265,7 +2265,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