From: Alex Zhuravlev Date: Mon, 15 Apr 2019 12:58:59 +0000 (+0300) Subject: LU-11233 build: support for gcc8 X-Git-Tag: 2.12.3-RC1~185 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;ds=sidebyside;h=2059acdcaee186256ce0eeae2f28b090058b0b39;p=fs%2Flustre-release.git LU-11233 build: support for gcc8 this patch covers kernel portion of Lustre Lustre-change: https://review.whamcloud.com/34660 Lustre-commit: 6601661f96325b4971d0d1cb0be0fa01cc2ddc97 Signed-off-by: Alex Zhuravlev Change-Id: I3fac8b89eef2291b5cb91ea05ee0b6ff32d11741 Reviewed-by: Andreas Dilger Reviewed-by: James Simmons Signed-off-by: Minh Diep Reviewed-on: https://review.whamcloud.com/35002 Tested-by: Jenkins Tested-by: Maloo --- diff --git a/config/lustre-build.m4 b/config/lustre-build.m4 index 7fec7bb..d64ce8a 100644 --- a/config/lustre-build.m4 +++ b/config/lustre-build.m4 @@ -362,6 +362,50 @@ AC_DEFUN([LB_CC_NO_FORMAT_TRUNCATION], [ ]) # +# Check if gcc supports -Wno-stringop-truncation +# +# To supress many warnings with gcc8 +# +AC_DEFUN([LB_CC_NO_STRINGOP_TRUNCATION], [ + AC_MSG_CHECKING([for -Wno-stringop-truncation support]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Wno-stringop-truncation" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ + EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-stringop-truncation" + AC_SUBST(EXTRA_KCFLAGS) + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" +]) + +# +# Check if gcc supports -Wno-stringop-overflow +# +# To supress many warnings with gcc8 +# +AC_DEFUN([LB_CC_NO_STRINGOP_OVERFLOW], [ + AC_MSG_CHECKING([for -Wno-stringop-overflow support]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Wno-stringop-overflow" + + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [ + EXTRA_KCFLAGS="$EXTRA_KCFLAGS -Wno-stringop-overflow" + AC_SUBST(EXTRA_KCFLAGS) + AC_MSG_RESULT([yes]) + ], [ + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" +]) + +# # LB_CONDITIONALS # # AM_CONDITIONAL instances for everything @@ -583,6 +627,8 @@ LB_PATH_DEFAULTS LB_PROG_CC LB_CC_NO_FORMAT_TRUNCATION +LB_CC_NO_STRINGOP_TRUNCATION +LB_CC_NO_STRINGOP_OVERFLOW LC_OSD_ADDON diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 3337fb8e..ae8c83f 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -659,6 +659,7 @@ repeat_fid2path: if (remote_gf != NULL) { struct getinfo_fid2path *ori_gf; char *ptr; + int len; ori_gf = (struct getinfo_fid2path *)karg; if (strlen(ori_gf->gf_u.gf_path) + 1 + @@ -667,13 +668,12 @@ repeat_fid2path: ptr = ori_gf->gf_u.gf_path; - memmove(ptr + strlen(gf->gf_u.gf_path) + 1, ptr, - strlen(ori_gf->gf_u.gf_path)); - - strncpy(ptr, gf->gf_u.gf_path, - strlen(gf->gf_u.gf_path)); - ptr += strlen(gf->gf_u.gf_path); - *ptr = '/'; + len = strlen(gf->gf_u.gf_path); + /* move the current path to the right to release space + * for closer-to-root part */ + memmove(ptr + len + 1, ptr, strlen(ori_gf->gf_u.gf_path)); + memcpy(ptr, gf->gf_u.gf_path, len); + ptr[len] = '/'; } CDEBUG(D_INFO, "%s: get path %s "DFID" rec: %llu ln: %u\n", diff --git a/lustre/mgs/mgs_handler.c b/lustre/mgs/mgs_handler.c index 096c27e..bc14d4e 100644 --- a/lustre/mgs/mgs_handler.c +++ b/lustre/mgs/mgs_handler.c @@ -742,7 +742,7 @@ static int mgs_extract_fs_pool(char *arg, char *fsname, char *poolname) /* Also make sure poolname is not to long. */ if (strlen(ptr) > LOV_MAXPOOLNAME) return -ENAMETOOLONG; - strncpy(poolname, ptr, strlen(ptr)); + strncpy(poolname, ptr, LOV_MAXPOOLNAME); /* Test if fsname is empty */ len = strlen(arg) - strlen(ptr) - 1; diff --git a/lustre/obdclass/genops.c b/lustre/obdclass/genops.c index 2bfa781..9c71703 100644 --- a/lustre/obdclass/genops.c +++ b/lustre/obdclass/genops.c @@ -445,7 +445,7 @@ struct obd_device *class_newdev(const char *type_name, const char *name, newdev->obd_conn_inprogress = 0; - strncpy(newdev->obd_uuid.uuid, uuid, strlen(uuid)); + strncpy(newdev->obd_uuid.uuid, uuid, UUID_MAX); CDEBUG(D_IOCTL, "Allocate new device %s (%p)\n", newdev->obd_name, newdev); diff --git a/lustre/osd-ldiskfs/osd_handler.c b/lustre/osd-ldiskfs/osd_handler.c index 27d02f7..26e5480 100644 --- a/lustre/osd-ldiskfs/osd_handler.c +++ b/lustre/osd-ldiskfs/osd_handler.c @@ -7585,7 +7585,7 @@ static int osd_mount(const struct lu_env *env, "force_over_512tb", NULL }; - strcat(options, opts); + strncat(options, opts, PAGE_SIZE); for (rc = 0, str = options; sout[rc]; ) { char *op = strstr(str, sout[rc]); @@ -7605,13 +7605,13 @@ static int osd_mount(const struct lu_env *env, ; } } else { - strncat(options, "user_xattr,acl", 14); + strncat(options, "user_xattr,acl", PAGE_SIZE); } /* Glom up mount options */ if (*options != '\0') - strcat(options, ","); - strlcat(options, "no_mbcache,nodelalloc", PAGE_SIZE); + strncat(options, ",", PAGE_SIZE); + strncat(options, "no_mbcache,nodelalloc", PAGE_SIZE); type = get_fs_type("ldiskfs"); if (!type) { diff --git a/lustre/ptlrpc/nodemap_storage.c b/lustre/ptlrpc/nodemap_storage.c index 33e6570..72ce072 100644 --- a/lustre/ptlrpc/nodemap_storage.c +++ b/lustre/ptlrpc/nodemap_storage.c @@ -89,7 +89,7 @@ static void nodemap_cluster_rec_init(union nodemap_rec *nr, { CLASSERT(sizeof(nr->ncr.ncr_name) == sizeof(nodemap->nm_name)); - strncpy(nr->ncr.ncr_name, nodemap->nm_name, sizeof(nodemap->nm_name)); + strncpy(nr->ncr.ncr_name, nodemap->nm_name, sizeof(nr->ncr.ncr_name)); nr->ncr.ncr_squash_uid = cpu_to_le32(nodemap->nm_squash_uid); nr->ncr.ncr_squash_gid = cpu_to_le32(nodemap->nm_squash_gid); nr->ncr.ncr_flags = cpu_to_le32( diff --git a/lustre/quota/qsd_lib.c b/lustre/quota/qsd_lib.c index 6aaed49..f2c460a 100644 --- a/lustre/quota/qsd_lib.c +++ b/lustre/quota/qsd_lib.c @@ -137,13 +137,13 @@ static int qsd_enabled_seq_show(struct seq_file *m, void *data) memset(enabled, 0, sizeof(enabled)); if (qsd_type_enabled(qsd, USRQUOTA)) - strcat(enabled, "u"); + strncat(enabled, "u", sizeof(enabled) - strlen(enabled)); if (qsd_type_enabled(qsd, GRPQUOTA)) - strcat(enabled, "g"); + strncat(enabled, "g", sizeof(enabled) - strlen(enabled)); if (qsd_type_enabled(qsd, PRJQUOTA)) - strncat(enabled, "p", 1); + strncat(enabled, "p", sizeof(enabled) - strlen(enabled)); if (strlen(enabled) == 0) - strcat(enabled, "none"); + strncat(enabled, "none", sizeof(enabled) - strlen(enabled)); seq_printf(m, "%s\n", enabled); return 0;